-- Lua Web Explorer by be2003 white = Color.new(255,255,255) gray = Color.new(127,127,127) black = Color.new(0,0,0) font = Font.createMonoSpaced() font:setPixelSizes(10,0) x = 2 y = 10 px = 0 py = 0 pw = 480 ph = 272 location = "www.google.com" clocation = location history1 = "" history2 = "" history3 = "" history4 = "" history5 = "" page = Image.createEmpty(pw,ph) page:clear(white) function printf(t) page:fontPrint(font,x,y,t,black) screen:blit(0,0,page) screen.waitVblankStart() screen:flip() end function resetPage() page:clear(white) x = 2 y = 10 px = 0 py = 0 end function historyChange(loc) history5 = history4 history4 = history3 history3 = history2 history2 = history1 history1 = loc end function parseHTTP(text,pnum) dm = 1 qm = 0 for i = 1, string.len(text) do char = string.sub(text, i, i) if x>pw then y=y+12 x=2 end if y>ph then resetPage() pnum=pnum+1 end if char == "<" then dm=1 end if char == "&" then qm=1 end if dm + qm == 0 then printf(char) x = x+8 end if dm == 1 then if char == ">" then dm=0 end end if qm == 1 then if char == ";" then qm=0 end end end screen:blit(px,py,page) screen.waitVblankStart() screen:flip() end Wlan.init() configs = Wlan.getConnectionConfigs() printf("Connections:") y = y+24 for key, value in configs do printf(key .. ": " .. value) y = y+12 end y = y+24 printf("Starting First Connection...") Wlan.useConnectionConfig(1) y = y+12 printf("Done!") printf("") y = y+24 function connectSite(location) printf("..." .. location .. "...") socket, error = Socket.connect(location, 80) while not socket:isConnected() do System.sleep(100) end y = y+12 printf("Connected To: " .. tostring(socket)) y = y+12 printf("Loading Webpage...") printf("") bytesSent = socket:send("GET / HTTP/1.1\r\n") bytesSent = socket:send("host: " .. location .. "\r\n\r\n") resetPage() end function startInput(location,clocation) keymap = Image.createEmpty(480,20) keymap:clear(gray) bmap = Image.createEmpty(480,12) bmap:clear(gray) temp = "a" tempnum = 1 while true do temp = numLetter(tempnum) pad = Controls.read() if pad:select() then screen:save("screenmenu.png") end if pad:l() then System.sleep(100) hn=hn+1 if hn==6 then hn=1 end if hn==1 then location=history1 end if hn==2 then location=history2 end if hn==3 then location=history3 end if hn==4 then location=history4 end if hn==5 then location=history5 end end if pad:triangle() then System.sleep(100) break end if pad:square() then connectSite(location) sent = 1 break end if pad:cross() then location = location .. temp System.sleep(150) end if pad:circle() then location = "" end if pad:up() then System.sleep(100) tempnum=tempnum+1 if tempnum>42 then tempnum=1 end end if pad:down() then System.sleep(100) tempnum=tempnum-1 if tempnum<1 then tempnum=42 end end keymap:clear(gray) keymap:drawLine(0,24,480,24,black) keymap:fillRect(50,3,390,14,white) keymap:fontPrint(font,4,14,"http://",black) keymap:fontPrint(font,52,14,location,black) keymap:fontPrint(font,450,14,temp,black) bmap:clear(gray) bmap:drawLine(0,0,480,0,black) bmap:fontPrint(font,2,10,"http://" .. clocation,black) screen:blit(0,0,keymap) screen:blit(0,260,bmap) screen.waitVblankStart() screen:flip() end screen:blit(px,py,page) screen.waitVblankStart() screen:flip() return location end function numLetter(tempnum) temp="a" if tempnum==1 then temp="a" end if tempnum==2 then temp="b" end if tempnum==3 then temp="c" end if tempnum==4 then temp="d" end if tempnum==5 then temp="e" end if tempnum==6 then temp="f" end if tempnum==7 then temp="g" end if tempnum==8 then temp="h" end if tempnum==9 then temp="i" end if tempnum==10 then temp="j" end if tempnum==11 then temp="k" end if tempnum==12 then temp="l" end if tempnum==13 then temp="m" end if tempnum==14 then temp="n" end if tempnum==15 then temp="o" end if tempnum==16 then temp="p" end if tempnum==17 then temp="q" end if tempnum==18 then temp="r" end if tempnum==19 then temp="s" end if tempnum==20 then temp="t" end if tempnum==21 then temp="u" end if tempnum==22 then temp="v" end if tempnum==23 then temp="w" end if tempnum==24 then temp="x" end if tempnum==25 then temp="y" end if tempnum==26 then temp="z" end if tempnum==27 then temp="0" end if tempnum==28 then temp="1" end if tempnum==29 then temp="2" end if tempnum==30 then temp="3" end if tempnum==31 then temp="4" end if tempnum==32 then temp="5" end if tempnum==33 then temp="6" end if tempnum==34 then temp="7" end if tempnum==35 then temp="8" end if tempnum==36 then temp="9" end if tempnum==37 then temp="." end if tempnum==38 then temp="/" end if tempnum==39 then temp="-" end if tempnum==40 then temp="_" end if tempnum==41 then temp="www." end if tempnum==42 then temp=".com" end return temp end function blitPage(px,py) screen:clear(white) screen:blit(px,py,page) screen:print(0,0,"",black) end sent = 0 while true do if sent == 1 then data = socket:recv() if string.len(data) > 0 then clocation = location historyChange(clocation) parseHTTP(data,1) end end pad = Controls.read() if pad:start() then break end if pad:select() then screen:save("screen.png") end if pad:triangle() then System.sleep(150) hn=0 location=startInput(location,clocation,0) printf("") end if pad:square() then connectSite(location) sent = 1 end if pad:up() then py=py+1 blitPage(px,py) end if pad:down() then if py>0 then py=py-1 blitPage(px,py) end end if pad:left() then if px<0 then px=px+1 blitPage(px,py) end end if pad:right() then if px<480-pw then px=px-1 blitPage(px,py) end end screen.waitVblankStart() screen:flip() end Wlan.term()