Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local x,y = term.getSize()
- rednet.open("top")
- local EditingValue = "";
- function rednetV()
- return "3.0 - BETA"
- end
- title = "Rednet Explorer " ..rednetV() --Add title = "name" to change the webpage's title!
- local website = "home";
- if fs.exists(".cache") then fs.delete(".cache") end
- if fs.exists(".websiteedited") then fs.delete(".websiteedited") end
- fs.makeDir(".cache")
- local cPrint = function(text)
- local x2,y2 = term.getCursorPos()
- term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
- print(text)
- end
- function reDirect(url)
- website = url
- loadWebpage()
- end
- local Address = function()
- text = "http://"
- term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), 2)
- term.clearLine()
- write(text)
- website = read()
- loadWebpage()
- end
- function done()
- term.setCursorPos(1, y)
- name = "F5 = Refresh"
- write("Press CTRL to travel the web! :D")
- term.setCursorPos(x - name:len(), y)
- write(name)
- while true do
- sleep(0) -- stop crashing
- e, k = os.pullEvent("key")
- if k == 63 then
- loadWebpage()
- break
- elseif k == 29 then
- Address()
- break
- end
- end
- end
- loadWebpage = function()
- term.clear()
- term.setCursorPos(1,1)
- cPrint(title)
- cPrint("http://" ..website.. "\n")
- if website == "home" then
- print("Welcome to RedNet explorer (3.0)! This requires you to have a wireless modem on your computer.")
- print("Host a website at: ")
- print("http://newsite! ")
- print(" -ComputerCraftFan11 ")
- elseif website == "newsite" then
- print("Unfinished")
- else
- title = "Rednet Explorer " ..rednetV()
- print("Connecting...")
- website1 = ".depagecrash"
- while true do
- http.request("http://" ..website)
- local event, url, response = os.pullEvent()
- if event == "http_success" then
- message = response.readAll()
- break
- elseif event == "http_failed" then
- break
- end
- end
- if event == "http_failed" then
- print("Unable to load webpage.")
- else
- if fs.exists(".cache/" ..website1) then fs.delete(".cache/" ..website1) end
- webpage = fs.open(".cache/" ..website1, "w")
- webpage.write(message)
- webpage.close()
- term.clear()
- term.setCursorPos(1,1)
- cPrint(title)
- cPrint("http://" ..website.. "\n")
- shell.run(".cache/" ..website1)
- end
- end
- done()
- end
- loadWebpage()
Advertisement
Add Comment
Please, Sign In to add comment