Post 10 made on Friday December 28, 2007 at 05:39 |
rvdvoort Lurking Member |
Joined: Posts: | August 2005 8 |
|
|
@snelvuur I have modified your script and also tried to add word rapping (adjust value "a" for the width of your panel). Probably not the most efficient way to do it but unfortunately I don't have any experience with Javascript. My program knowledge stops at programming in Fortran 77 many years ago ;-)
The only problem I currently have is that special characters like for example "ö" or "ü" do not show up correctly. Not sure if someone knows a solution for this problem.
====================================
var result = ""; var socket = new TCPSocket(false); var t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14; var event1,event2,tijd1,tijd2,prog1; var str1,str2,descrip1, descrip2; var patt1 = /\s+/; var woord = new Array(); var woord2 = new Array(); var a; a = 0; var descrip1=""; var descrip2="";
socket.onConnect = function() { socket.write("GET /cgi-bin/channelinfo HTTP/1.1\r\n"); socket.write("Accept: */*\r\n"); socket.write("Host: 192.168.0.9\r\n"); socket.write("\r\n"); };
socket.onData = function() { result += socket.read(5000,1000);
t1 = result.indexOf("colspan=\"3\">", 0)+12; t2 = result.indexOf("/th",t1)-1; prog1 = result.substring(t1,t2); CF.widget("program").label=prog1;
t3 = result.indexOf("class=\"time\">", 0)+13; t4 = result.indexOf("/span>",t3)-1; tijd1 = result.substring(t3,t4); CF.widget("time1").label=tijd1;
t5 = result.indexOf("class=\"event\">", 0)+14; t6 = result.indexOf("/span>",t5)-1; event1 = result.substring(t5,t6); CF.widget("eventnow").label=event1;
t7 = result.indexOf("class=\"description\">", t6)+20; t8 = result.indexOf("/span>",t7)-1; str1 = result.substring(t7,t8); woord = str1.split(patt1); for (x in woord) { a= a + woord[x].length; if (a < 50) { descrip1 = descrip1 + woord[x]+" "; a=a+1; } else { descrip1 = descrip1 + "\r\n"+woord[x]+" "; a = woord[x].length+1; } }; CF.widget("info1").label=descrip1; a=0;
t9 = result.indexOf("class=\"time\">", t8)+13; t10 = result.indexOf("/span>",t9)-1; tijd2 = result.substring(t9,t10); CF.widget("time2").label=tijd2;
t11 = result.indexOf("class=\"event\">", t8)+14; t12 = result.indexOf("/span>",t11)-1; event2 = result.substring(t11,t12); CF.widget("eventlater").label=event2;
t13 = result.indexOf("class=\"description\">", t11)+20; t14 = result.indexOf("/span>",t13)-1; str2 = result.substring(t13,t14); woord2 = str2.split(patt1); for (x in woord2) { a= a + woord2[x].length; if (a < 50) { descrip2 = descrip2 + woord2[x]+" "; a=a+1; } else { descrip2 = descrip2 + "\r\n"+woord2[x]+" "; a = woord2[x].length+1; } }; CF.widget("info2").label=descrip2; };
socket.onClose = function() { };
socket.onIOError = function(e) { };
if(socket.connected == false) { socket.connect('192.168.0.9', 80, 3000); };
|
|
|