Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- >> Variables << --
- DNSF = false
- mainOpts = { -- Will be replaced in fitire version
- "Options",
- "----------",
- "Settings",
- "Close",
- }
- run = true -- Sets main loop dependancy to true
- local dir = shell.dir().."/"
- local settings = {}
- local build = 160
- if not fs.exists("/loc/browser/userSettings") then
- local file = fs.open("/loc/browser/userSettings","w")
- local dat = {
- btnColor = colors.gray,
- bgColor = colors.lightGray,
- mainColor = colors.white
- }
- file.write(textutils.serialize(dat))
- file.close()
- end
- local file = fs.open("/loc/browser/userSettings","r")
- userSet = textutils.unserialize(file.readAll())
- file.close()
- -- >> Functions << --
- -- click
- function click()
- event, xB, xX, xY = os.pullEvent("mouse_click")
- end
- -- keyPress
- function keyPress()
- event, keyB = os.pullEvent("key_press")
- end
- -- drawMain
- function drawMain()
- term.setBackgroundColor(userSet.mainColor)
- term.clear()
- paintutils.drawLine(1,1,51,1,userSet.bgColor)
- term.setCursorPos(1,1)
- write("[^]")
- paintutils.drawLine(4,1,50,1,userSet.btnColor)
- term.setCursorPos(4,1)
- write("Click here to browse...")
- term.setBackgroundColor(colors.red)
- term.setCursorPos(51,1)
- write("X")
- end
- -- drawWebsite
- function drawWebsite(var1)
- local rawIP = inzernet.lookup(var1)
- if var1 ~= DNSF then
- local fIP = inzernet.parse(rawIP)
- local page = inzernet.GET(fIP,"index")
- inzernet.write(page)
- end
- end
- -- urlBar()
- function urlBar()
- paintutils.drawLine(4,1,50,1,userSet.btnColor)
- term.setCursorPos(4,1)
- term.setTextColor(colors.white)
- local var = read()
- return var
- end
- -- mainFunc
- function mainFunc()
- click()
- if xB == 1 and xX>=1 and xX<=3 and xY == 1 then
- dropMenu(1,2,mainOpts)
- elseif xB == 1 and xX>=4 and xX<=50 and xY == 1 then
- local url = urlBar()
- drawWebsite(url)
- elseif xB == 1 and xX==51 and xY==1 then
- run = false
- end
- end
- -- dropMenu
- function dropMenu(x,y,opts)
- for yD=y,(y+#opts)-1 do
- paintutils.drawLine(x,yD,x+10,yD,userSet.bgColor)
- end
- for k,v in pairs(opts) do
- term.setCursorPos(x,y+k-1)
- write(v)
- end
- local event, button, xPos, yPos = os.pullEvent("mouse_click")
- if xPos>=x and xPos<=x+10 and yPos>=y and yPos<=y+#opts then
- return (yPos-y)+1
- end
- end
- -- >> Startup << --
- -- Loads inzernet API for program
- os.loadAPI("/loc/browser/includes/inzernet")
- -- Startup InZernet API
- inzernet.startup()
- -- Creates webDis
- webDis = window.create(term.native(),1,2,51,18)
- -- >> Main Loop << --
- repeat
- drawMain()
- term.setBackgroundColor(colors.black)
- mainFunc()
- until run ~= true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement