1// JavaScript Document 2var browserIE = navigator.userAgent.toLowerCase().indexOf("msie") > -1; 3 4function initNav(){ 5 var imgObj; 6 for(i=0;i<navImgHoverArr.length;i++){ 7 imgObj = new Image(); 8 imgObj.src = navImgHoverArr[i]; 9 } 10} 11 12function navOver(navImgID, srcOver){ 13 document.getElementById(navImgID).src=srcOver; 14} 15function navOut(navImgID, srcOut){ 16 document.getElementById(navImgID).src=srcOut; 17} 18 19function txtboxInit(txtboxObj, initVal){ 20 if (txtboxObj.value == initVal){ 21 txtboxObj.value = ''; 22 } 23 if (txtboxObj.className.substr(txtboxObj.className.length-4,4) == "init"){ 24 //txtboxObj.className = txtboxObj.className.substr(0,txtboxObj.className.length-4);// Bug in IE 25 txtboxObj.style.color='#003366'; 26 } else if (txtboxObj.className.substr(txtboxObj.className.length-4,4) == "warn"){ 27 txtboxObj.style.color='#003366'; 28 } 29} 30 31function setStyle_func(obj, stylevar, styleval){ 32 if (navigator.userAgent.toLowerCase().indexOf("msie") > -1){ 33 obj.style[stylevar]=styleval; 34 } else { 35 obj.style[stylevar]=styleval; 36 } 37} 38 39function search_func(crit){ 40 location.href="search.asp?s="+crit; 41} 42 43function enterKeySearch_func(e, urlORfrm){ 44 var characterCode 45 if(e && e.which){ //if which property of event object is supported (NN4) 46 e = e 47 characterCode = e.which //character code is contained in NN4's which property 48 } else{ 49 e = event 50 characterCode = e.keyCode //character code is contained in IE's keyCode property 51 } 52 if (characterCode == 13){ 53 if (urlORfrm.name){ 54 urlORfrm.submit(); 55 } else { 56 location.href=urlORfrm; 57 } 58 } 59} 60 61function replaceTxt_func(txtStr,replaceSelStr,replaceWithTxt){ 62 return txtStr.split(replaceSelStr).join(replaceWithTxt); 63} 64 65// ***** JOURNEY PLANNER FUNCTIONS ****** 66 67function jpStartAgain(){ 68 location.href="jplanner1.asp"; 69} 70 71function gotoJPlanner(fromtxt,totxt){ 72 frm = document.getElementById('minijplanner'); 73 frm.addrfrom.value = fromtxt; 74 frm.addrto.value = totxt; 75 frm.submit(); 76} 77 78function jpTimesEarlier(dt){ 79 showloader_func(); 80 location.href="jplanner3.asp?planjourney=1&earlier=1&dt="+dt; 81} 82 83function jpTimesLater(dt){ 84 showloader_func(); 85 location.href="jplanner3.asp?planjourney=1&later=1&dt="+dt; 86} 87 88function showOnMap(mode,markerID,fromOSX,fromOSY,toOSX,toOSY,txt){ 89 var ptFrom = OS2LatLonWGS84_func(fromOSX,fromOSY); 90 ptFrom = new GLatLng(ptFrom.lat, ptFrom.lng); 91 var ptTo = OS2LatLonWGS84_func(toOSX,toOSY); 92 ptTo = new GLatLng(ptTo.lat, ptTo.lng); 93 if (mode == "walk"){ 94 imageUrl = "images/mapicon_walk.png"; 95 lineColor = "#817bb9"; 96 } else if (mode == "rail"){ 97 imageUrl = "images/mapicon_rail.png"; 98 lineColor = "#67bc77"; 99 } else if (mode == "bus" || mode == "coach"){ 100 imageUrl = "images/mapicon_bus.png"; 101 lineColor = "#f17278"; 102 } 103 104 map.addOverlay(new GPolyline([ptFrom, ptTo], lineColor, 6, 0.6, {geodesic:true})); 105 106 // Create our marker icon 107 var icon = new GIcon(); 108 icon.image = imageUrl 109 icon.shadow = "images/mapicon_sqshad.png"; 110 icon.iconSize = new GSize(45, 47); 111 icon.shadowSize = new GSize(60, 41); 112 icon.iconAnchor = new GPoint(0, 47); 113 //icon.infoWindowAnchor = new GPoint(5, 1); 114 115 116 addJMarker2Map(ptFrom,16,icon,markerID,imageUrl,txt); 117} 118 119 120function showloader_func(){ 121 var windowHeight = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight; 122 scroll(0, 0); 123 loaderObj = document.getElementById('loader'); 124 //loaderObj.innerHTML = "<img src='images/aniloader.gif' alt='Loading...' /> Loading..." 125 loaderObj.style.visibility='visible'; 126 loaderObj.style.position='fixed'; 127 loaderObj.style.width=document.body.clientWidth+'px'; 128 loaderObj.style.height=windowHeight+'px'; 129 130 loaderObj = document.getElementById('loaderbg'); 131 loaderObj.style.width=document.body.clientWidth+'px'; 132 loaderObj.style.height=windowHeight+'px'; 133 loaderObj.style.visibility='visible'; 134 loaderObj.style.position='fixed'; 135 //writehtml_func(); 136} 137 138function inputIsPostcode(postcodetxt){ 139 var isFullPostcode = true; 140 if (postcodetxt.length >=5 && postcodetxt.length <= 9){ 141 if (!isNaN(postcodetxt.substr(0,1))){ 142 isFullPostcode = false; 143 } 144 if (postcodetxt.indexOf(" ") == -1){ 145 postcodetxt = postcodetxt.substr(0,postcodetxt.length-3)+" "+postcodetxt.substr(postcodetxt.length-3,3); 146 } 147 postcode2ndPart = postcodetxt.substr(postcodetxt.length-3,3); 148 if (isNaN(postcode2ndPart.substr(0,1))){ // first number of second part of postcode has to be a number 149 isFullPostcode = false; 150 } 151 if (!isNaN(postcode2ndPart.substr(1,1)) || !isNaN(postcode2ndPart.substr(2,1))){ // second and third numbers of second part of postcode has to be a letters 152 isFullPostcode = false; 153 } 154 } else { 155 isFullPostcode = false; 156 } 157 return isFullPostcode; 158} 159 160function addPostcodeSpace(postcodetxt){ 161 if (postcodetxt.indexOf(" ") == -1){ 162 postcodetxt = postcodetxt.substr(0,postcodetxt.length-3)+" "+postcodetxt.substr(postcodetxt.length-3,3); 163 } 164 return postcodetxt; 165} 166 167function gotoMarker_func(pt){ 168 map.setCenter(pt, 16); 169} 170 171 172 173 174function sendmlHttpRequest(url,callback,postdata) { 175 var xmlhttp=false; 176 try { 177 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); /* for IE < 5 */ 178 } catch (e) { 179 try { 180 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 181 } catch (E) { 182 xmlhttp = false; 183 } 184 } 185 186 /* mozilla & opera */ 187 if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); 188 } 189 190 xmlhttp.open("POST",url,true); 191 xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded") 192 xmlhttp.onreadystatechange=function() { 193 if(xmlhttp.readyState == 4 && xmlhttp.status == 200) { 194 callback(xmlhttp.responseText); 195 //alert(xmlhttp.responseText); 196 } 197 } 198 xmlhttp.send(postdata); /* are sending null because we dont have any data to post */ 199} 200 201var XMLHttpFactories = [ 202 function () {return new XMLHttpRequest()}, 203 function () {return new ActiveXObject("Msxml2.XMLHTTP")}, 204 function () {return new ActiveXObject("Msxml3.XMLHTTP")}, 205 function () {return new ActiveXObject("Microsoft.XMLHTTP")} 206]; 207 208function createXMLHTTPObject() { 209 var xmlhttp = false; 210 for (var i=0;i<XMLHttpFactories.length;i++) { 211 try { 212 xmlhttp = XMLHttpFactories[i](); 213 } 214 catch (e) { 215 continue; 216 } 217 break; 218 } 219 return xmlhttp; 220} 221 222function openTimetable(pdf){ 223 if (pdf.length > 0){ 224 window.open("/data/timetables/"+pdf); 225 } 226} 227 228function listBusesResult(req){ 229 var listObj = document.getElementById('busnolist'); 230 listObj.innerHTML = req; 231} 232 233function listBuses(bustxt){ 234 sendmlHttpRequest("/listbusnos2016.asp?txt="+bustxt.value,listBusesResult, "start=1&txt="+bustxt.value) 235 var listObj = document.getElementById('busnolist'); 236 if (bustxt.value.length > 0){ 237 listObj.style.visibility='visible'; 238 listObj.style.position='relative'; 239 } else { 240 listObj.style.visibility='hidden'; 241 listObj.style.position='absolute'; 242 } 243} 244 245function refreshCaptchaImage(valImageId) { 246 var objImage = document.images[valImageId];
247 if (objImage == undefined) { 248 return; 249 } 250 var now = new Date(); 251 objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString(); 252} 253 254function jqueryOrderSelectOpts(selId) { 255 var my_options = $("#"+selId+" option"); 256 my_options.sort(function(a,b) { 257 if (a.text > b.text) return 1; 258 else if (a.text < b.text) return -1; 259 else return 0 260 }) 261 $("#"+selId).empty().append( my_options ); 262 $("select#"+selId).val(''); 263} 264 265 266 267// ***** NEXTBUSES FUNCTIONS START ******* 268var getNextBusesTimer; 269var getNextBusesCounter = 0; 270var getNextBusesCurrNaptanCode; 271var getNextBusesCurrStopName; 272var getNextBusesCurrServiceNo; 273var getNextBusesCurrDestName; 274var getNextBusesCurrResultsID; 275var getNextBusesCurrLoaderID; 276var getNextBusesUseGmapInfoWin; 277function getNextBuses(stopName, naptanCode, serviceNo, destName, resID, loaderID, useGmapInfoWin){ 278 getNextBusesCurrNaptanCode = naptanCode; 279 getNextBusesCurrStopName = stopName; 280 getNextBusesCurrServiceNo = serviceNo; 281 getNextBusesCurrDestName = destName; 282 getNextBusesCurrResultsID = resID; 283 getNextBusesCurrLoaderID = loaderID; 284 getNextBusesUseGmapInfoWin = useGmapInfoWin 285 if (useGmapInfoWin){ 286 infowindow.setContent("<div class='infowin'><div class='inner'><h3>"+stopName+" </h3><img src='/images/ajax-loader-facebook.gif' /> loading...</div></div>"); 287 sendXmlHttpRequestGet("/datanew/nextbuses//?naptan="+naptanCode+"&serviceno="+serviceNo+"&dest="+destName,getNextBusesResult,{results:document.getElementById(resID),loaderObj:document.getElementById(loaderID),naptanCode:naptanCode,serviceNo:serviceNo,dest:destName, useGmap:useGmapInfoWin, stopName:stopName},""); 288 } else { 289 getNextBusesTimer = setInterval( 290 function(){ 291 if (document.getElementById(resID) && document.getElementById(loaderID) && naptanCode != ""){ 292 document.getElementById(loaderID).innerHTML = "<img src='/images/ajax-loader-facebook.gif' /> loading..."; 293 document.getElementById(resID).innerHTML = ""; 294 sendXmlHttpRequestGet("/datanew/nextbuses//?naptan="+naptanCode+"&serviceno="+serviceNo+"&dest="+destName,callback,{results:document.getElementById(resID),loaderObj:document.getElementById(loaderID),naptanCode:naptanCode,serviceNo:serviceNo,dest:destName, useGmap:useGmapInfoWin, stopName:stopName},""); 295 clearTimeout(getNextBusesTimer); 296 } 297 } 298 ,100); 299 } 300} 301 302function getNextBusesResult(res,objs){ 303 //alert(res+"\n"+objs.loaderObj+"\n"+objs.results) 304 if (objs.useGmap){ 305 infowindow.setContent("<div class='infowin'><div class='inner'><h3>"+objs.stopName+" </h3><div id='infowin-rtresults' class='realtimeresults'>"+res+"</div></div></div>"); 306 } else { 307 objs.loaderObj.innerHTML = ""; 308 objs.loaderObj.style.display="none"; 309 getNextBusesTimer = setInterval(function(){ 310 getNextBusesCounter++; 311 objs.results.style.display="block"; 312 objs.results.innerHTML = res+"<div class='clear'></div>"; 313 if (getNextBusesCounter > 3){ 314 getNextBusesCounter = 0; 315 clearTimeout(getNextBusesTimer); 316 } 317 },100); 318 } 319} 320 321function aa(){ 322 getNextBuses(getNextBusesCurrNaptanCode, getNextBusesCurrServiceNo, getNextBusesCurrDestName, getNextBusesCurrResultsID, getNextBusesCurrLoaderID) 323} 324// ***** NEXTBUSES FUNCTIONS END ******* 325 326 327function sendXmlHttpRequestGet(url,callback,callbackParam,getdata,callbackError) { // callbackParam is an array 328 var xmlhttp=false; 329 try { 330 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); /* for IE < 5 */ 331 } catch (e) { 332 try { 333 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 334 } catch (E) { 335 xmlhttp = false; 336 } 337 } 338 339 /* mozilla & opera */ 340 if (!xmlhttp && typeof XMLHttpRequest!='undefined') { 341 xmlhttp = new XMLHttpRequest(); 342 } 343 xmlhttp.open("GET",url,true); 344 xmlhttp.onreadystatechange=function() { 345 if(xmlhttp.readyState == 4 && xmlhttp.status == 200) { 346 callback(xmlhttp.responseText, callbackParam); 347 //alert(xmlhttp.responseText); 348 } else if(xmlhttp.readyState == 4 && xmlhttp.status != 200) { 349 //alert("Error:\n"+xmlhttp.error); 350 window.status = 'http request aborted/error.'; 351 //} else if (xmlhttp.status == 500){ 352 //alert("There was an error retrieving live departure information for this station - it may not be available.") 353 } 354 } 355 xmlhttp.send(getdata); /* are sending null because we dont have any data to post */ 356}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.