Here's the pastebin to my code
Here's the code:
(some of the functions are useless, this is going through massive restructoring
if OneOS then if shell.getRunningProgram() == "startup" then --to make sure they're not running this in shell --because if they are it'll crash. OneOS.ToolBarColour = colours.lightGrey end end --Credits: --Developers: --Hithere --APIs --Special thanks to: --oeed, for OneOS, the OS Sapphari was --designed for --DEVELOPER CONFIG local waitForMessage = false -------------------------------------------------- sapphariVersionString = "1.0" sapphariVersionNumber = 1 sapphariSites = {} sapphariBlacklist = {} --TESTS: --might fix some crashes --+function error() --The script sets the news, then sets the url vars shell.run("rom/programs/http/pastebin run Jg8D7mLi") --print("--------------------------------------------------") --It would seem I don't need to kill any functions as OneOS handles that for me :D/>/> --Internal functions local sapphInt = {} function sapphInt.redrawUI() term.setBackgroundColor(colors.white) term.setTextColor(colors.black) local termX, termY = term.getSize() for i=1,2 do paintutils.drawLine(1,i,termX,i,colors.lightGray) end paintutils.drawLine(2,1,termX/3,1,colors.white) paintutils.drawLine(termX/3+2,1,termX/3+3,1,colors.green) --this is the last thing getting drawn, --we do not need to specify length. --writing on it takes care of it term.setCursorPos(termX/3+2,1) term.write("Refresh") --now it's the right length. end --this function will get the data for a site, --however, will not run it. function sapphInt.getSite(pasteID) local responce = http.get("http://pastebin.com/raw.php?i="..pasteID) if responce then return loadstring(responce.readAll()) else return false end end function sapphInt.handleMenu(typeClick, clickX, clickY) --handle the user clicking the menu print"cal1" local termX,termY=term.getSize() if typeClick == 1 then --okay, it's a left click, passes first one' if clickX>1 then --okay, in somewhere special if clickX<termX/3+1 then --okay, the user wants to change the url. term.setCursorPos(2,1) print"cal" input = read() print"dun" --we will return the input which will --be returned until the program must --end, then it will be a temporary --global variable and read by safari --again. Complicated? True. return input end end if clickX>termX/3+1 then if clickX<termX/3+8 then --need to refresh page nao return currentSite end end end end function sapphInt.decodeHumanReadableURL(HRURL) --this is where we attempt to decode a --human readable url. If fails, will tell --calling function to attempt to use the --plain url instead. if sapphariSites[HRURL] then --this must be an HRURL, so we'll give them' --the pasteID currentSite = sapphariSites[HRURL] return sapphariSites[HRURL] else currentSite = HRURL return HRURL --this must be a PasteID then end end --WEBSITE FUNCTON --sapphutils, MUST be global!!! sapphUtils = {} function sapphUtils.pullEvent(filter) print"f" termX,termY=term.getSize() print"redaw" sapphInt.redrawUI() while true do local event, p1, p2, p3, p4, p5, p6, p7 = os.pullEventRaw() --note that pullEvent yields --so we have to make sure we don't --kill the routine while it's checking --for events if event == "mouse_click" and p3==1 then print"handling" if p1 == 1 and p3 == 1 then if p2>1 and p2<termX/3+1 then print"menu" term.setCursorPos(5,5) newSiteq=true clickx=p2 clicky=p3 --okay, it'll be elseif p2>termX/3+1 and p3<termX/3+8 then newSiteq=true clickx=p2 clicky=p3 --okay, it'll be Refresh then. end end if newSiteq then print"die" coroutine.yeild() end end if filter then if event == filter then return event, p1, p2, p3, p4, p5, p6, p7 end else return event, p1, p2, p3, p4, p5, p6, p7 end --if they changed sites, we'll never get here. end end function sapphUtils.read(startx, starty, endx, endy) while true do evt, text = os.pullEvent() if evt == "key" then end end end --this must get the pasteid, not the human --redable url function sapphInt.handleWebsite(url) print"Aliv fn" local rurl = sapphInt.decodeHumanReadableURL(url) print"stil" local site = sapphInt.getSite(rurl) print"loadin sit" coSite = coroutine.create(site) end function sapphInt.handleSapphari() local site = sapphInt.handleWebsite("homepage") --coSite = coroutine.create(site) --handleWebsite does this while coroutine.status(coSite) == "suspended" do coroutine.resume(coSite) end print("it diedz") print(coroutine.status(coSite)) end --------------------------------------------------- sapphInt.handleSapphari()
Edited by Geforce Fan, 05 June 2014 - 01:56 AM.