home *** CD-ROM | disk | FTP | other *** search
- // This file was generated by Dashcode from Apple Inc.
- // You may edit this file to customize your Dashboard widget.
-
- //
- // Function: load()
- // Called by HTML body element's onload event when the widget is ready to start
- //
- var depInter;
- var arrInter;
- var detInter;
- var stationPref;
- var refreshPeriod = 120000;
- var open = -1;
-
- function load()
- {
- setupParts();
- stationPref = widget.preferenceForKey(widget.identifier+"-station");
- if (!stationPref) stationPref="HUL";
- document.getElementById("nrscode").value=stationPref;
- loadPage("dep");
- loadPage("arr");
- depInter=self.setInterval("loadPage(\"dep\")",refreshPeriod);
- arrInter=self.setInterval("loadPage(\"arr\")",refreshPeriod);
- }
-
-
- function loadPage(arr)
- {
-
- document.getElementById("indicator").src = "Images/indicator.gif"
-
- var xmlhttp = new XMLHttpRequest();
- if (xmlhttp != null)
- {
-
- xmlhttp.onreadystatechange = function()
- {
- if (xmlhttp.readyState==4)// && xmlhttp.status==200)
- {
- var ldbpage = xmlhttp.responseText;
- parseFunc(ldbpage,arr);
- }
- else
- {
-
- }
- }
- xmlhttp.open("GET","http://www.livedepartureboards.co.uk/ldb/sum"+arr+".aspx?T="+stationPref,true);
- xmlhttp.send(null);
- }
- }
-
- function parseFunc(text,arr)
- {
-
- var start;
- var end;
- var line;
- var count;
- var platforms = -1;
- var departure = new Array();
- var destination = new Array();
- var expected = new Array();
- var operator = new Array();
- var platform = new Array();
- var details = new Array();
- var display = "<table class=\"arrdep\">";
- var disp = " <br>";
- var station;
- var circlecheck;
- var information = "";
-
- if (text.indexOf("<th ><h3>PLATFORM</h3></th>") != -1) platforms=1;
-
- start=text.indexOf("class=\"arrivaltable\"");
- start=text.indexOf("<tbody>",start);
- end=text.indexOf("</tbody>",start);
-
- count=0;
- line=0;
- var st=start;
- while (count != -1)
- {
- count=text.indexOf("<tr class=\"row",st);
- circlecheck=text.substring(count,count+65);
- if (circlecheck.indexOf("*** Circular route ***") != -1) line--;
- st=count+1;
- line++;
- }
- line--;
-
- station=text.substring(text.indexOf("<title>"),text.indexOf("</title>"));
- if (station.indexOf("Error") != -1)
- {
- station=""
- }
- else
- {
- station=station.substring(station.indexOf(" - ")+3,station.indexOf(" Train Times"));
- }
- document.getElementById("station").innerHTML = station
-
- if (station != "")
- {
- var st=0;
- st=text.indexOf("<div class=\"maintmessages\">")
- if (st != -1)
- {
- information=text.substring(text.indexOf("<div>",st)+5,text.indexOf("</div>",st))
- }
- else
- {
- information="";
- }
- document.getElementById("information").innerHTML = information
-
- count=1;
- for (count=1;count<=line;count++)
- {
- departure[count]=getDept(start,end,count,text,platforms);
- }
-
- count=1;
- for (count=1;count<=line;count++)
- {
- destination[count]=getDest(start,end,count,text);
- }
-
- count=1;
- for (count=1;count<=line;count++)
- {
- expected[count]=getExpt(start,end,count,text,platforms,departure[count]);
- }
-
- count=1;
- for (count=1;count<=line;count++)
- {
- operator[count]=getOper(start,end,count,text);
- }
-
- if (platforms != -1)
- {
- count=1;
- for (count=1;count<=line;count++)
- {
- platform[count]=getPlat(start,end,count,text);
- }
- }
- }
-
- count=1;
- for (count=1;count<=line;count++)
- {
- details[count]=getDetail(start,end,count,text);
- }
-
- if (station != "")
- {
- count=1;
- for (count=1;count<=line;count++)
- {
- //display=display+"<tr onclick=\"widget.openURL('http://www.livedepartureboards.co.uk/ldb/"+details[count]+"')\">"
- display=display+"<tr style=\"height: 13px;\" onclick=\"loadDetailsPage('http://www.livedepartureboards.co.uk/ldb/"+details[count]+"','"+operator[count]+"')\">";
- if (platforms != -1)
- {
- if (expected[count].indexOf("L") != -1 || expected[count].indexOf("E") != -1)
- {
- if (expected[count].indexOf("L") != -1) display=display+"<td class=\"destplat\">"+destination[count]+"</td><td class=\"dept\">"+departure[count]+"</td><td class=\"plat\">"+platform[count]+"</td><td class=\"delay\">"+expected[count].substring(1,expected[count].length);
- if (expected[count].indexOf("E") != -1) display=display+"<td class=\"destplat\">"+destination[count]+"</td><td class=\"dept\">"+departure[count]+"</td><td class=\"plat\">"+platform[count]+"</td><td class=\"early\">"+expected[count].substring(1,expected[count].length);
- }
- else
- {
- display=display+"<td class=\"destplat\">"+destination[count]+"</td><td class=\"dept\">"+departure[count]+"</td><td class=\"plat\">"+platform[count]+"</td><td class=\"expt\">"+expected[count];
- }
- }
- else
- {
- if (expected[count].indexOf("L") != -1 || expected[count].indexOf("E") != -1)
- {
- if (expected[count].indexOf("L") != -1) display=display+"<td class=\"dest\">"+destination[count]+"</td><td class=\"dept\">"+departure[count]+"</td><td class=\"delay\">"+expected[count].substring(1,expected[count].length);
- if (expected[count].indexOf("E") != -1) display=display+"<td class=\"dest\">"+destination[count]+"</td><td class=\"dept\">"+departure[count]+"</td><td class=\"early\">"+expected[count].substring(1,expected[count].length);
- }
- else
- {
- display=display+"<td class=\"dest\">"+destination[count]+"</td><td class=\"dept\">"+departure[count]+"</td><td class=\"expt\">"+expected[count];
- }
- }
- display=display+"</td><td><img class=\"operator\" src=\"Images/Logos/"+operator[count]+".png\" height=13></td></tr><tr><td colspan=5><hr></td></tr>";
- //display=display+"</td><td><!--<img class=\"operator\" src=\"Images/Logos/"+operator[count]+".png\" width=46 height=13>--></td></tr><tr><td colspan=5><hr></td></tr>";
- }
- display=display+"</table>";
- if (arr != "arr")
- {
- document.getElementById("content").innerHTML = display;
- document.getElementById("scrollArea").object.refresh();
- }
- else
- {
- document.getElementById("content1").innerHTML = display;
- document.getElementById("scrollArea1").object.refresh();
- }
- }
- else
- {
- document.getElementById("content").innerHTML = "No information. Have you entered a valid code?";
- document.getElementById("content1").innerHTML = "No information. Have you entered a valid code?";
- }
- document.getElementById("indicator").src = "Images/ind.gif"
- }
-
- function getDept(begin,finish,number,text,platforms)
- {
- var c=1;
- var deptSt;
- var deptEn;
- var dept;
-
- deptSt=begin;
- for (c=1;c<=number;c++)
- {
- deptSt=text.indexOf("<td class=\"cellone\" >",deptSt);
- deptSt=text.indexOf("<td >",deptSt)+5;
- if (platforms != -1) deptSt=text.indexOf("<td >",deptSt)+5;
- deptEn=text.indexOf("</td>",deptSt);
- }
-
- dept=text.substring(deptSt,deptEn);
-
- if (dept.indexOf(":") != -1)
- {
- dept=dept.substring(0,2)+dept.substring(3,6);
- }
-
- return dept;
- }
-
- function getExpt(begin,finish,number,text,platforms,dept)
- {
- var c=1;
- var exptSt;
- var exptEn;
- var expt;
- var hour;
- var dhour;
- var min;
- var dmin;
- var green = -1;
-
- exptSt=begin;
- for (c=1;c<=number;c++)
- {
- exptSt=text.indexOf("<td class=\"cellone\" >",exptSt);
- exptSt=text.indexOf("<td >",exptSt)+5;
- exptSt=text.indexOf("<td >",exptSt)+5;
- if (platforms != -1) exptSt=text.indexOf("<td >",exptSt)+5;
- exptEn=text.indexOf("</td>",exptSt);
- }
-
- expt=text.substring(exptSt,exptEn);
- if (expt.indexOf(":") != -1)
- {
- if (expt.indexOf("span") != -1)
- {
- exptSt=expt.indexOf(">")+1;
- exptEn=expt.indexOf("</span>");
-
- hour=expt.substring(exptSt,exptSt+2)
- min=expt.substring(exptSt+3,exptSt+5);
- dhour=dept.substring(0,2);
- dmin=dept.substring(2,4);
-
- if (hour < dhour || hour == dhour && min < dmin) green = 1;
-
- if (green == -1) expt="L"+hour+min;
- if (green == 1) expt="E"+hour+min;
- }
- else
- {
- hour=expt.substring(0,2);
- min=expt.substring(3,5);
- dhour=dept.substring(0,2);
- dmin=dept.substring(2,4);
-
- if (hour < dhour || hour == dhour && min < dmin) green = 1;
-
- if (green == -1) expt="L"+hour+min;
- if (green == 1) expt="E"+hour+min;
- }
-
- }
-
- if (expt.indexOf("Cancelled") != -1) expt="L"+expt
- if (expt.indexOf("Delayed") != -1) expt="L"+expt
-
- return expt;
- }
-
- function getOper(begin,finish,number,text)
- {
- var c=1;
- var operSt;
- var operEn;
- var oper;
-
- operSt=begin;
- for (c=1;c<=number;c++)
- {
- operSt=text.indexOf("<td class=\"cellone\" >",operSt);
- operSt=text.indexOf("atocCode=",operSt)+9;
- operEn=text.indexOf("\">",operSt);
- }
-
- oper=text.substring(operSt,operEn);
- return oper;
- }
-
- function getDetail(begin,finish,number,text)
- {
- var c=1;
- var detaSt;
- var detaEn;
- var deta;
-
- detaSt=begin;
- for (c=1;c<=number;c++)
- {
- detaSt=text.indexOf("<td class=\"cellone\" >",detaSt);
- detaSt=text.indexOf("<a href=\"train.aspx?",detaSt)+9;
- detaEn=text.indexOf("\">",detaSt);
- }
-
- deta=text.substring(detaSt,detaEn);
- return deta;
- }
-
- function getPlat(begin,finish,number,text)
- {
- var c=1;
- var platSt;
- var platEn;
- var plat;
-
- platSt=begin;
- for (c=1;c<=number;c++)
- {
- platSt=text.indexOf("<td class=\"cellone\" >",platSt);
- platSt=text.indexOf("<td >",platSt)+5;
- platEn=text.indexOf("</td>",platSt);
- }
-
- plat=text.substring(platSt,platEn);
-
- return plat;
- }
-
- function getDest(begin,finish,number,text)
- {
- var c=1;
- var destSt;
- var destEn;
- var dest;
-
- destSt=begin;
- for (c=1;c<=number;c++)
- {
- destSt=text.indexOf("<td class=\"cellone\" >",destSt)+21;
- destEn=text.indexOf("</td>",destSt);
- }
-
- dest=text.substring(destSt,destEn);
- if (dest.substring(0,7) == "<a href")
- {
- destSt=dest.indexOf(">")+1;
- destEn=dest.indexOf("</a>");
- dest=dest.substring(destSt,destEn);
-
- }
- return dest;
- }
-
- //
- // Function: remove()
- // Called when the widget has been removed from the Dashboard
- //
- function remove()
- {
- // Stop any timers to prevent CPU usage
- // Remove any preferences as needed
- // widget.setPreferenceForKey(null, createInstancePreferenceKey("your-key"));
- clearInterval(arrInter);
- clearInterval(depInter);
- clearInterval(detInter);
- }
-
- //
- // Function: hide()
- // Called when the widget has been hidden
- //
- function hide()
- {
- // Stop any timers to prevent CPU usage
- clearInterval(arrInter);
- clearInterval(depInter);
- clearInterval(detInter);
- }
-
- //
- // Function: show()
- // Called when the widget has been shown
- //
- function show()
- {
- // Restart any timers that were stopped on hide
- loadPage("dep");
- loadPage("arr");
- depInter=self.setInterval("loadPage(\"dep\")",refreshPeriod);
- arrInter=self.setInterval("loadPage(\"arr\")",refreshPeriod);
- }
-
- //
- // Function: sync()
- // Called when the widget has been synchronized with .Mac
- //
- function sync()
- {
- // Retrieve any preference values that you need to be synchronized here
- // Use this for an instance key's value:
- // instancePreferenceValue = widget.preferenceForKey(null, createInstancePreferenceKey("your-key"));
- //
- // Or this for global key's value:
- // globalPreferenceValue = widget.preferenceForKey(null, "your-key");
- }
-
- //
- // Function: showBack(event)
- // Called when the info button is clicked to show the back of the widget
- //
- // event: onClick event from the info button
- //
- function showBack(event)
- {
- if (open != -1) closeDetails();
-
- var front = document.getElementById("front");
- var back = document.getElementById("back");
-
- if (window.widget) {
- widget.prepareForTransition("ToBack");
- }
-
- front.style.display = "none";
- back.style.display = "block";
-
- if (window.widget) {
- setTimeout('widget.performTransition();', 0);
- }
- }
-
- //
- // Function: showFront(event)
- // Called when the done button is clicked from the back of the widget
- //
- // event: onClick event from the done button
- //
- function showFront(event)
- {
- var front = document.getElementById("front");
- var back = document.getElementById("back");
-
- if (window.widget) {
- widget.prepareForTransition("ToFront");
- }
-
- front.style.display="block";
- back.style.display="none";
-
- if (window.widget) {
- setTimeout('widget.performTransition();', 0);
- }
- loadPage("dep");
- loadPage("arr");
- }
-
- if (window.widget) {
- widget.onremove = remove;
- widget.onhide = hide;
- widget.onshow = show;
- widget.onsync = sync;
- }
-
- function savePrefs(event)
- {
- stationPref=document.getElementById("nrscode").value.toUpperCase();
- document.getElementById("nrscode").value = stationPref;
- widget.setPreferenceForKey(stationPref,widget.identifier+"-station");
- showFront(event);
- }
-
- function pressNrsCode(event)
- {
- var keynumber=event.which;
- if (keynumber == 13) savePrefs(event);
- }
-
- function loadDetailsPage(details,operator)
- {
- if (open == -1) openPane();
- clearInterval(detInter);
- detInter=self.setInterval("loadDetails('"+details+"','"+operator+"')",refreshPeriod);
- setTimeout("loadDetails('"+details+"','"+operator+"')",300);
- }
-
- function loadDetails(details,operator)
- {
- var xmlhttp = new XMLHttpRequest();
- if (xmlhttp != null)
- {
-
- xmlhttp.onreadystatechange = function()
- {
- if (xmlhttp.readyState==4)// && xmlhttp.status==200)
- {
- var detailspage = xmlhttp.responseText;
- detailsDisplay(detailspage,operator);
- }
- else
- {
-
- }
- }
- xmlhttp.open("GET",details,true);
- xmlhttp.send(null);
- }
- }
-
- function detailsDisplay(detailspage,operator)
- {
- var service;
- var delaymessage;
- var title;
- var start;
- var end;
- var stop = new Array();
- var schedule = new Array();
- var expected = new Array();
- var actual = new Array();
- var display = "<table class=\"detail\"><tr><th>Station</th><th>Sched.</th><th>Expected</th><th>Actual</th></tr><tr><td colspan='4'><hr class=\"solid\"></td></tr>";
- service=detailspage.substring(detailspage.indexOf("<title>"),detailspage.indexOf("</title>"));
- if (service.indexOf("Error") != -1)
- {
- service="";
- }
- else
- {
- service=service.substring(service.indexOf(" - ")+3);
- }
- if (service.indexOf(":") != -1)
- {
- title="<table class=\"title\"><tr><td class=\"title\" style=\"width: 28px;\">"+service.substring(0,5)+"</td><td class=\"title\">"+service.substring(6)+"</td><td class=\"titleimage\"><img src=\"Images/Logos/"+operator+".png\"></td><tr><td colspan=\"3\"></td></tr></table>";
- }
- else
- {
- title="<table class=\"title\"><tr><td class=\"title\" style=\"width: 28px;\"></td><td class=\"title\">"+service+"</td><td class=\"titleimage\"><img src=\"Images/Logos/"+operator+".png\"></td><tr><td colspan=\"3\"></td></tr></table>";
- }
- document.getElementById("box").innerHTML=title;
-
- start=detailspage.indexOf("<div class=\"jpbody\">");
- delaymessage=detailspage.substring(start,detailspage.indexOf("</div>",start));
- if (delaymessage.indexOf(">This train") != -1 || delaymessage.indexOf("<br>We were") != -1)
- {
- if (delaymessage.indexOf(">This train") != -1)
- {
- delaymessage=delaymessage.substring(delaymessage.indexOf(">This train")+1,delaymessage.indexOf("<br>",delaymessage.indexOf(">This train")));
- }
- else
- {
- delaymessage=delaymessage.substring(delaymessage.indexOf(">We were")+1,delaymessage.indexOf("<br>",delaymessage.indexOf(">We were")));
- }
- }
- else
- {
- delaymessage="";
- }
- document.getElementById("detailinformation").innerHTML=delaymessage;
-
- start=detailspage.indexOf("<table class=\"arrivaltable\"");
- start=detailspage.indexOf("<tbody>",start);
- end=detailspage.indexOf("</tbody>",start);
-
- var count=0;
- var count2=0;
- var line=0;
- var st=0;
- while (count != -1)
- {
- count=detailspage.indexOf("<tr class=\"row",st);
- st=count+1;
- line++;
- }
- line--;
-
- count=1;
- for (count=1;count<=line;count++)
- {
- stop[count]=getDetailStop(start,end,count,detailspage);
- }
-
- count=1;
- for (count=1;count<=line;count++)
- {
- schedule[count]=getDetailSchedule(start,end,count,detailspage);
- }
-
- count=1;
- for (count=1;count<=line;count++)
- {
- expected[count]=getDetailExpected(start,end,count,detailspage,schedule[count]);
- if (expected[count] == "No report*") expected[count]="No rprt*";
- }
-
- count=1;
- for (count=1;count<=line;count++)
- {
- actual[count]=getDetailActual(start,end,count,detailspage,schedule[count]);
- if (actual[count] == "No report*") actual[count]="No rprt*";
- }
-
- count=1;
- for (count=1;count<=line;count++)
- {
- display=display+"<tr><td class='stop'>"+stop[count]+"</td><td class='detailtime'>"+schedule[count]+"</td>";
- var colourcode=expected[count].substring(0,1)
- switch (colourcode)
- {
- case "E":
- display=display+"<td class='detailexpgreen'>"+expected[count].substring(1)+"</td>";
- break;
- case "L":
- display=display+"<td class='detailexpred'>"+expected[count].substring(1)+"</td>";
- break;
- default:
- display=display+"<td class='detailexp'>"+expected[count]+"</td>";
- break;
- }
- var colourcode=actual[count].substring(0,1)
- switch (colourcode)
- {
- case "E":
- display=display+"<td class='detailexpgreen'>"+actual[count].substring(1)+"</td>";
- break;
- case "L":
- display=display+"<td class='detailexpred'>"+actual[count].substring(1)+"</td>";
- break;
- default:
- display=display+"<td class='detailexp'>"+actual[count]+"</td>";
- break;
- }
- if (stop[count+1] == "")
- {
- display=display+"</tr><tr><td colspan='4'></td></tr>"
- }
- else
- {
- display=display+"</tr><tr><td colspan='4'><hr></td></tr>"
- }
- }
-
- display=display+"</table>";
-
- document.getElementById("detailscontent").innerHTML=display;
- document.getElementById("detailsArea").object.refresh();
- }
-
- function getDetailStop(begin,finish,number,text)
- {
- var c=1;
- var St;
- var En;
- var ret;
- var chk;
-
- St=begin;
- for (c=1;c<=number;c++)
- {
- St=text.indexOf("<tr class=",St);
- chk=text.substring(St,St+18)
- if (chk.indexOf("row1a") != -1 || chk.indexOf("row2a") != -1)
- {
- St=text.indexOf("<td class=\"cellone",St+17);
- ret=""
- }
- else
- {
- St=text.indexOf("<td class=\"cellone",St+17);
- St=text.indexOf(">",St)+1;
- En=text.indexOf("</td>",St);
- ret=text.substring(St,En);
- }
- }
-
- if (ret.substring(0,12).indexOf("<a href") != -1)
- {
- St=ret.indexOf(">")+1;
- En=ret.indexOf("</a>");
- ret=ret.substring(St,En);
- }
- return ret;
- }
-
- function getDetailSchedule(begin,finish,number,text)
- {
- var c=1;
- var St;
- var En;
- var ret;
- var ad;
- var chk;
-
- St=begin;
- for (c=1;c<=number;c++)
- {
- St=text.indexOf("<tr class=",St);
- chk=text.substring(St,St+18)
- if (chk.indexOf("row1a") != -1 || chk.indexOf("row2a") != -1)
- {
- St=text.indexOf("<td class=\"cellone",St)+1;
- }
- else
- {
- St=text.indexOf("<td class=\"cellone",St)+1;
- St=text.indexOf("<td class=\"cellone",St);
- }
- St=text.indexOf(">",St)+1;
- if (text.substring(St,St+29).indexOf("Arr") != -1) ad="a";
- if (text.substring(St,St+29).indexOf("Dep") != -1) ad="d";
- St=text.indexOf("</div>",St)+6;
- En=text.indexOf("</td>",St);
- }
-
- ret=text.substring(St,En);
- if (ret.indexOf(":") != -1) ret=ret.substring(0,2)+ret.substring(3,5);
- return ret+ad;
- }
-
- function getDetailExpected(begin,finish,number,text,sched)
- {
- var c=1;
- var St;
- var En;
- var ret;
- var chk;
-
- St=begin;
- for (c=1;c<=number;c++)
- {
- St=text.indexOf("<tr class=",St);
- chk=text.substring(St,St+18)
- if (chk.indexOf("row1a") != -1 || chk.indexOf("row2a") != -1)
- {
- St=text.indexOf("<td class=\"cellone",St)+1;
- }
- else
- {
- St=text.indexOf("<td class=\"cellone",St)+1;
- St=text.indexOf("<td class=\"cellone",St);
- }
- St=text.indexOf("<td>",St)+4;
- En=text.indexOf("</td>",St);
- }
-
- ret=text.substring(St,En);
- if (ret.indexOf("late") != -1)
- {
- St=ret.indexOf(">")+1;
- En=ret.indexOf("</span>");
- ret=ret.substring(St,En);
- }
- if (ret.indexOf(":") != -1)
- {
- var hr=ret.substring(0,2);
- var min=ret.substring(3,5);
- var shr=sched.substring(0,2);
- var smin=sched.substring(2,4);
- if (shr > hr || shr == hr && smin > min) ret="E";
- if (shr < hr || shr == hr && smin < min) ret="L";
- ret=ret+hr+min;
- }
- if (ret.indexOf("Cancelled") != -1 || ret.indexOf("Delayed") != -1) ret="L"+ret
- if (ret == "_") ret=" ";
- return ret;
- }
-
- function getDetailActual(begin,finish,number,text,sched)
- {
- var c=1;
- var St;
- var En;
- var ret;
- var chk;
-
- St=begin;
- for (c=1;c<=number;c++)
- {
- St=text.indexOf("<tr class=",St);
- chk=text.substring(St,St+18)
- if (chk.indexOf("row1a") != -1 || chk.indexOf("row2a") != -1)
- {
- St=text.indexOf("<td class=\"cellone",St)+1;
- }
- else
- {
- St=text.indexOf("<td class=\"cellone",St)+1;
- St=text.indexOf("<td class=\"cellone",St);
- }
- St=text.indexOf("<td>",St)+4;
- St=text.indexOf("<td>",St)+4;
- En=text.indexOf("</td>",St);
- }
-
- ret=text.substring(St,En);
- if (ret.indexOf("late") != -1)
- {
- St=ret.indexOf(">")+1;
- En=ret.indexOf("</span>");
- ret=ret.substring(St,En);
- }
- if (ret.indexOf(":") != -1)
- {
- var hr=ret.substring(0,2);
- var min=ret.substring(3,5);
- var shr=sched.substring(0,2);
- var smin=sched.substring(2,4);
- if (shr > hr || smin > min) ret="E";
- if (shr < hr || smin < min) ret="L";
- ret=ret+hr+min;
- }
- if (ret.indexOf("Cancelled") != -1 || ret.indexOf("Delayed") != -1) ret="L"+ret
- if (ret == "_") ret=" ";
- return ret;
- }
-
- function openPane()
- {
- window.resizeTo(548,386);
-
- document.getElementById("details").style.visibility="visible";
-
- // Values you provide
- var itemToMove = document.getElementById("details"); // replace with ID of element to move
- var moveToLeftPosition = 280; // new left CSS value
-
- // Moving code
- var originalLeft = parseInt(document.defaultView.getComputedStyle(itemToMove, null).getPropertyValue("left"));
- var fadeHandler = function(a, c, s, f){ itemToMove.style.left = c + "px"; };
- new AppleAnimator(500, 13, originalLeft, moveToLeftPosition, fadeHandler).start();
-
- // Values you provide
- var itemToFadeIn = document.getElementById("details"); // replace with name of element to fade
-
- // Fading code
- var fadeHandler = function(a, c, s, f){ itemToFadeIn.style.opacity = c; };
- new AppleAnimator(500, 13, 0.0, 1.0, fadeHandler).start();
-
- setTimeout("openPaneAfterDelay()",500);
-
- open = 1;
- }
-
- function openPaneAfterDelay()
- {
- document.getElementById("closebutton").style.visibility="visible";
- document.getElementById("detailsArea").style.visibility="visible";
- document.getElementById("detailscontent").style.visibility="visible";
- document.getElementById("detailinformation").style.visibility="visible";
- document.getElementById("box").style.visibility="visible";
- }
-
- function closeDetails()
- {
- document.getElementById("closebutton").style.visibility="hidden";
- document.getElementById("detailsArea").style.visibility="hidden";
- document.getElementById("detailscontent").style.visibility="hidden";
- document.getElementById("detailinformation").style.visibility="hidden";
- document.getElementById("box").style.visibility="hidden";
-
-
- // Pane
- var itemToMove = document.getElementById("details"); // replace with ID of element to move
- var moveToLeftPosition = 30; // new left CSS value
- var originalLeft = parseInt(document.defaultView.getComputedStyle(itemToMove, null).getPropertyValue("left"));
- var fadeHandler = function(a, c, s, f){ itemToMove.style.left = c + "px"; };
- new AppleAnimator(500, 13, originalLeft, moveToLeftPosition, fadeHandler).start();
-
- var itemToFadeOut = document.getElementById("details"); // replace with name of element to fade
- var fadeHandler = function(a, c, s, f){ itemToFadeOut.style.opacity = c; };
- new AppleAnimator(500, 13, 1.0, 0.0, fadeHandler).start();
-
- setTimeout("closeDetailsAfterDelay()",400);
- clearInterval(detInter);
- open=-1;
- }
-
- function closeDetailsAfterDelay()
- {
- window.resizeTo(298,386)
- document.getElementById("box").innerHTML="";
- document.getElementById("detailscontent").innerHTML="";
- document.getElementById("detailsArea").object.refresh();
-
- }
-
- function term(event)
- {
- termload("http://www.heathrowairport.com/portal/page/General/Heathrow%5EGeneral%5EFlight+information%5ELive+flight+departures/","dep")
- termload("http://www.heathrowairport.com/portal/page/General/Heathrow%5EGeneral%5EFlight+information%5ELive+flight+arrivals/","arr")
- }
-
- function termload(url,ad)
- {
- if (stationPref == "HWV" || stationPref == "HXX" || stationPref == "HAF")
- {
- var xmlhttp = new XMLHttpRequest();
- if (xmlhttp != null)
- {
- xmlhttp.onreadystatechange = function()
- {
- if (xmlhttp.readyState==4)// && xmlhttp.status==200)
- {
- var ttext = xmlhttp.responseText;
- tparse(ttext,ad);
- }
- else
- {
-
- }
- }
- xmlhttp.open("GET",url,true);
- xmlhttp.send(null);
- }
- }
- }
-
- function tparse(ttext,arde)
- {
- var st;
- var en;
- var tablecontent;
- var display="<table class=\"terminal\"><tr><td style='width: 19px;'></td><td style='width: 33px;'></td><td style='width: 80px;'></td><td style='width: 58px;'></td><td style='width: 60px;'></td></tr>";
-
- st=ttext.indexOf("<table id=\"time");
- st=ttext.indexOf("<tbody>",st)+7;
- en=ttext.indexOf("</table>",st)-1;
- tablecontent=ttext.substring(st,en);
-
- display=display+tablecontent+"</table>";
-
- if (arde == "dep")
- {
- document.getElementById("content").innerHTML = display;
- document.getElementById("scrollArea").object.refresh();
- }
- else
- {
- document.getElementById("content1").innerHTML = display;
- document.getElementById("scrollArea1").object.refresh();
- }
- }
-
- function stationSearch(event)
- {
- var keynumber=event.which;
- if (keynumber == 13) stationLookup(event);
- }
-
- function stationLookup(event)
- {
- var searchString;
- var firstPipe;
- var secondPipe=0;
- var pipeContents="";
- var pipeContentsUpper="";
- var positiveArray = new Array();
- sortedArray = new Array();
- sortedCount = 0;
- var arrayCount=0;
- var menu="";
- var beginning;
-
- //Get string to search for
- searchString=document.getElementById("stationentry").value.toUpperCase();
-
- while (secondPipe != -1)
- {
- //Get position of first pipe
- firstPipe=stationList.indexOf("|",secondPipe)+1;
-
- //Get position of second pipe
- secondPipe=stationList.indexOf("|",firstPipe);
-
- //Get pipe contents
- pipeContents=stationList.substring(firstPipe,secondPipe);
-
- //Check if the pipe contents contain the string we're looking for
- pipeContentsUpper=pipeContents.toUpperCase();
- if (pipeContentsUpper.indexOf(searchString) != -1)
- {
- //if it does add the pipe contents to an array of positive matches otherwise ignore
- arrayCount++;
- positiveArray[arrayCount]=pipeContents;
- }
- }
- arrayCount--;
-
- var i=0;
- sortedCount=1;
- for (i=1;i<=arrayCount;i++)
- {
- if (searchString == positiveArray[i].substring(0,3))
- {
- sortedArray[sortedCount]=positiveArray[i];
- arrayCount=rebuildPositive(positiveArray,i,arrayCount);
- sortedCount++;
- }
- else
- {
- if (positiveArray[i].substring(4).toUpperCase() == searchString)
- {
- sortedArray[sortedCount]=positiveArray[i];
- arrayCount=rebuildPositive(positiveArray,i,arrayCount);
- sortedCount++;
- }
- }
- }
-
- var i=0;
- for (i=1;i<=arrayCount;i++)
- {
- beginning = positiveArray[i].substring(4,searchString.length+4).toUpperCase();
- if (beginning == searchString)
- {
- sortedArray[sortedCount]=positiveArray[i];
- arrayCount=rebuildPositive(positiveArray,i,arrayCount);
- sortedCount++;
- i--;
- }
- }
-
- var i=0;
- for (i=1;i<=arrayCount;i++)
- {
- sortedArray[sortedCount]=positiveArray[i];
- sortedCount++;
- }
- sortedCount--;
-
- // create a menu of the sorted results
- if (sortedCount > 0)
- {
- var i=0;
- for (i=1;i<=sortedCount;i++)
- {
- menu=menu+"<option id=\""+i+"\">"+sortedArray[i].substring(4)+"</option>";
- }
- //document.getElementById("popup").object.setEnabled(true);
- if (document.getElementById("nrscode").value == sortedArray[1].substring(0,3)) savePrefs(event);
- document.getElementById("nrscode").value = sortedArray[1].substring(0,3);
- document.getElementById("stationentry").value = sortedArray[1].substring(4);
- document.getElementById("popup").innerHTML = menu;
- }
- else
- {
- //document.getElementById("popup").object.setEnabled(false);
- document.getElementById("popup").innerHTML = menu;
- }
- }
-
- function rebuildPositive(array,i,arrayCount)
- {
- var count=1;
- arrayCount--;
- for (count=1;count<=arrayCount;count++)
- {
- if (count < i) array[count] = array[count];
- if (count >= i) array[count] = array[count+1];
- }
- return arrayCount;
- }
-
- function setStationSearch(event)
- {
- var popupValue = document.getElementById("popup");
- popupValue = popupValue.value
-
- var i=0;
- for (i=1;i<=sortedCount;i++)
- {
- if (popupValue == sortedArray[i].substring(4))
- {
- document.getElementById("nrscode").value = sortedArray[i].substring(0,3);
- document.getElementById("stationentry").value = sortedArray[i].substring(4);
- }
- }
- }
-