Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function c(...) return term.clear(...) end
- function cL(...) return term.clearLine(...) end
- function p(...) return print(...) end
- function w(...) return write(...) end
- function sbgc(...) return term.setBackgroundColor(...) end
- function stc(...) return term.setTextColor(...) end
- function scp(...) return term.setCursorPos(...) end
- function s(...) return sleep(...) end
- --This is the official provider of the prBr
- --Enter your browser in the download mode
- --Thanks.
- --browser.download=1
- anCondt = true
- cndDns = 1
- function autoConfig()
- if fs.exists("brconfig") == true then
- shell.run("brconfig")
- rednet.open(side)
- begin()
- else
- print("first time config setup")
- sleep(1)
- print("modem side")
- AtSide = tostring(read())
- print("write the dns id")
- write("dns1:")
- atDns1 = read()
- write("dns2:")
- atDns2 = read()
- print("ask for download? ")
- print("[1]yes")
- print("[2]no")
- atAks = read()
- if atAsk ~= 1 and atAsk ~= 2 then
- atAsk = 1
- end
- print("saving")
- e = fs.open("brconfig", "a")
- e.writeLine("dns1 = "..atDns1)
- e.writeLine("dns2 = "..atDns2)
- e.writeLine("Aks = "..atAsk)
- e.writeLine('side = "'..AtSide..'"')
- e.close()
- sleep(2)
- term.clear()
- autoConfig()
- end
- end
- function gui()
- sbgc(colors.green)
- c()
- scp(1,1)
- sbgc(colors.blue)
- cL()
- sbgc(colors.white)
- scp(1,2)
- cL()
- scp(2,2)
- sbgc(colors.cyan)
- p("<")
- scp(4,2)
- p(">")
- scp(6,2)
- stc(colors.black)
- p("http:// ")
- scp(42,2)
- stc(colors.white)
- p("@")
- scp(44,2)
- p("^")
- scp(46,2)
- stc(colors.yellow)
- p("*")
- scp(51,1)
- stc(colors.white)
- sbgc(colors.red)
- p("X")
- end
- function begin()
- gui()
- scp(1,1)
- sbgc(colors.blue)
- stc(colors.white)
- print("Web Browser 4.2 (*bugs reports*)")
- sleep(1)
- default = dns1
- end
- function click()
- goHome()
- while true do
- event, bu , X, Y = os.pullEvent()
- if event == "mouse_click" then
- if X == 51 and Y == 1 then
- sbgc(colors.black)
- stc(colors.white)
- scp(1,1)
- c()
- break
- elseif X>= 6 and X<=41 and Y == 2 then
- gui()
- begin()
- scp(13,2)
- stc(colors.black)
- sbgc(colors.cyan)
- p(" ")
- scp(13,2)
- id = read()
- Csha = true
- connect()
- elseif X == 2 and Y == 2 then
- comeBack()
- elseif X == 4 and Y == 2 then
- comeOn()
- elseif X == 42 and Y == 2 then
- refresh()
- elseif X == 44 and Y == 2 then
- if bu == 1 then
- goHome()
- elseif bu == 2 then
- setHome()
- end
- elseif X == 46 and Y == 2 then
- if bu == 1 then
- goFav()
- elseif bu == 2 then
- setFav()
- end
- else
- Llinky()
- end
- end
- end
- end
- function Llinky()
- if actL == true then
- Lcnt = 0
- lDone = false
- repeat
- Lcnt = Lcnt + 1
- if X >= lX[Lcnt] and X <= lXx[Lcnt] and Y == lY[Lcnt] then
- if lI[Lcnt] == "package" then
- scp(lX[Lcnt], Y)
- whatSend = read()
- id = lL[Lcnt].."="..whatSend
- begin()
- connect()
- lDone = true
- elseif lI[Lcnt] == "link" then
- id = lL[Lcnt]
- begin()
- connect()
- lDone = true
- end
- end
- until Lcnt >= lNumber or lDone == true
- end
- end
- function Llink()
- Rllink = msg:match("--browser.link=1")
- if Rllink ~= nil then
- temp = fs.open("temp2", "w")
- temp.write(msg)
- temp.close()
- shell.run("temp2")
- id = lPage
- lPp = true
- begin()
- connect()
- lPp = false
- actL = true
- fs.delete("temp2")
- end
- end
- function Rconnect()
- rednet.send(default,id)
- ids,msg = rednet.receive(5)
- if msg ~= nil then
- sbgc(colors.green)
- scp(1,3)
- cL()
- scp(1,4)
- cL()
- scp(1,5)
- cL()
- scp(1,6)
- cL()
- scp(1,7)
- cL()
- scp(1,8)
- cL()
- scp(1,9)
- cL()
- scp(1,10)
- cL()
- scp(1,11)
- cL()
- scp(1,12)
- cL()
- scp(1,13)
- cL()
- scp(1,14)
- cL()
- scp(1,15)
- cL()
- scp(1,16)
- cL()
- scp(1,17)
- cL()
- scp(1,18)
- cL()
- scp(1,19)
- cL()
- scp(1,3)
- stc(colors.black)
- print(msg)
- end
- end
- function anim()
- anCondt = false
- anF = nil
- if msg:match("--browser.anim=1") ~= nil then
- temp = fs.open("temp", "w")
- temp.write(msg)
- temp.close()
- shell.run("temp")
- nOfF = 0
- repeat
- nOfF = nOfF + 1
- id = anF[nOfF]
- Rconnect()
- s(2)
- until nOfF >= anMax
- end
- anCondt = true
- end
- function setFav()
- scp(44,3)
- sbgc(colors.yellow)
- print("Fav:")
- scp(44,4)
- print(" ")
- scp(44,4)
- Hfav = read()
- if Hfav ~= nil then
- e = fs.open("brconfig", "a")
- e.writeLine('fav = "'..Hfav..'"')
- e.close()
- autoConfig()
- end
- end
- function goFav()
- id = fav
- connect()
- end
- function setHome()
- scp(44,3)
- sbgc(colors.yellow)
- print("home:")
- scp(44,4)
- print(" ")
- scp(44,4)
- Hhome = read()
- if Hhome ~= nil then
- e = fs.open("brconfig", "a")
- e.writeLine('home = "'..Hhome..'"')
- e.close()
- autoConfig()
- end
- end
- function goHome()
- id = home
- connect()
- end
- function refresh()
- gui()
- begin()
- connect()
- end
- function comeBack()
- gui()
- begin()
- if id == id2 and id3 ~= nil then
- id = id3
- elseif id == id3 and id4 ~= nil then
- id = id4
- end
- if Csha == true then
- Csha = false
- end
- s(.2)
- connect()
- end
- function comeOn()
- gui()
- begin()
- if id4 ~= nil and id == id4 and id3 ~= nil then
- id = id3
- elseif id3 ~= nil and id == id3 and id2 ~= nil then
- id = id2
- end
- if Csha == true then
- Csha = false
- end
- s(.2)
- connect()
- end
- function connect()
- if lPp ~= true then
- actL = false
- end
- rednet.send(default, id)
- ids, msg = rednet.receive(10)
- if msg ~= nil then
- if cndDns ~= 1 then
- cndDns = 1
- end
- scp(1,3)
- stc(colors.black)
- sbgc(colors.green)
- autoDown()
- Llink()
- else
- scp(1,3)
- stc(colors.red)
- sbgc(colors.green)
- if cndDns == 1 then
- default = dns2
- cndDns = 2
- connect()
- elseif cndDns == 2 then
- default = dns1
- cndDns = 1
- print("time out")
- end
- end
- if Csha == true then
- id4 = id3
- id3 = id2
- id2 = id
- end
- end
- function autoDown()
- Fline = msg:match("--browser.download=1")
- if Fline ~= nil then
- if Aks == 1 then
- scp(10,5)
- stc(colors.black)
- sbgc(colors.yellow)
- print(" warning ")
- scp(10,6)
- print("want to download from here?")
- scp(10,7)
- print("YES NO ")
- event, bu, X, Y = os.pullEvent()
- function warnDown()
- if event == "mouse_click" then
- if X >= 10 and X <= 12 and Y == 7 then
- Rp = "1"
- elseif X >= 34 and X <= 35 and Y == 7 then
- Rp = "2"
- else
- scp(1,3)
- print("reloading")
- sleep(.2)
- sbgc(colors.green)
- scp(1,3)
- print(" ")
- cL()
- autoDown()
- end
- else
- sleep(.2)
- autoDown()
- end
- end
- warnDown()
- if Rp == "1" then
- Down()
- else
- scp(1,3)
- sbgc(colors.green)
- print(msg)
- gui()
- begin()
- end
- else
- Down()
- end
- else
- print(msg)
- if anCondt == true then
- anim()
- end
- end
- end
- function Down()
- sbgc(colors.green)
- scp(10,6)
- cL()
- scp(10,7)
- cL()
- scp(10,6)
- sbgc(colors.yellow)
- write("Local: ")
- scp(16,6)
- Dlocal = read()
- if Dlocal == nil then
- Dlocal = "download"
- end
- e = fs.open(Dlocal, "w")
- e.write(msg)
- e.close()
- scp(10,7)
- print("download sucessful")
- Rp = nil
- end
- autoConfig()
- click()
- rednet.close(side)
Advertisement
Add Comment
Please, Sign In to add comment