first commit

This commit is contained in:
Sanj 2011-08-13 18:12:40 +05:30
commit d19229d37b
116 changed files with 6916 additions and 0 deletions

59
busesfound.html Normal file
View File

@ -0,0 +1,59 @@
<!DOCTYPE html>
<html>
<head>
<title>BestBus Mumbai - Found Buses</title>
<meta name="viewport" content="user-scalable=no, width=device-width" >
<!-- <link rel="stylesheet" type="text/css" href="app.css"> -->
<link rel="stylesheet" type="text/css" href="./css/common.css">
<link rel="stylesheet" type="text/css" href="./lib/jquery/jquery.mobile.min.css">
<script type="text/javascript" src="./lib/jquery/jquery.min.js"></script>
<script type="text/javascript" src="./lib/jquery/jquery.mobile.min.js"></script>
<script type="text/javascript" src="init/areas.js"></script>
<script type="text/javascript" src="init/stopnames.js"></script>
<script type="text/javascript" src="libfns.js"></script>
<script type="text/javascript" src="cf.js"></script>
<script type="text/javascript" src="init/stopbus.js"></script>
<script type="text/javascript" src="init/busmaster.js"></script>
<script type="text/javascript" src="busesfound.js"></script>
</head>
<body onLoad='busesfoundinit();'>
<div data-role="page" data-theme="a">
<div data-role="header" data-theme="a">
<div data-role="navbar">
<!-- <div id="navigation"> -->
<ul>
<li><a href="index.html" rel="external">Find</a></li>
<li><a href="busesfound.html" rel="external" class="ui-btn-active">Routes</a></li>
<!-- <li><a href="busroute.html" rel="external">Routes</a></li> -->
<li><a href="journey.html" rel="external">Journey</a></li>
</ul>
</div><!-- /navbar -->
</div> <!-- /header -->
<div data-role="content" data-theme="c">
<div id="foundBuses">
<div id="foundBusFrom" class="bar_color"></div>
<div id="foundBusTo" class="bar_color"></div>
<div id="spacer">&nbsp;</div>
<span id="directBuses" >Finding Buses ...</span>
</div> <!-- /foundbuses -->
<div id='spacer'>&nbsp;</div>
<div style='width:98%;line-height:8px;' data-role="collapsible" data-theme="a">
<h5><span id="font-size:14px;">Recent Buses Found</h5>
<div id="recentBusesFound" class="tbl_color"></div>
</div> <!-- /collapsible -->
</div> <!-- /content -->
</div>
</body>
</html>

680
busesfound.js Normal file
View File

@ -0,0 +1,680 @@
// Find buses between start and destination stop
// Parameters: s - startstopnameid to d - deststopnameid
//
var dBugLvl = 3;
var WALKDIST = 1000; // Find stops within 1 km radius
var NEARLATLON = 0.01;
var CHECKSTOPS = 40;
var SHOWMAXSTOPS = 5;
var MAXBUSESTOSHOW = 4;
var MAXRECENTBUSESFOUND = 7;
var stopLines;
var stopBusLines;
var busMaster;
var oStartStop, oDestStop; // The stopbus info for start and dest
var startStopArea, destStopArea;
var arBusesFound = [];
var sAr, dAr; // Array of stops near start and destination
/*
$(document).ready(function() {
// var XMLFileSupport = CheckXMLHttpFile();
busesfoundinit();
return;
});
*/
function busesfoundinit() {
scrollTo(0, 0);
s = gup('s');
d = gup('d');
if(s === "" && d === "") {
s = getCookie('cStartStopNameId');
d = getCookie('cDestStopNameId');
}
if(d === "") {
alert('No Buses Found as yet. Select from the Find Bus tab');
window.location.href = "index.html";
return;
}
startStopNameId = s;
destStopNameId = d;
dBug('', ' s = ' + s + ', d = ' + d, 5);
stopBusLines = getStopBusList();
busMaster = getbusmaster();
var sStopSs = findStopId(startStopNameId).stopsrchstr;
var dStopSs = findStopId(destStopNameId).stopsrchstr;
var htmlTitle = sStopSs.stopsrchstr + ' <br>' + dStopSs;
var dirHdr = "<table class='tbl_color' id='directbuses'><tr><th>Stop name</th><th>Buses (frequency)</th></tr>";
var dirHdrClose = '</table>';
var htmlBody = '';
var dHTML = '', nHTML = '', cHTML = '';
if(startStopNameId !== '') { // start not empty, find near stops, needed for all
rAr = getStopsNear(startStopNameId);
if(rAr !== null) {
sAr = rAr.startStops;
oStartStop = rAr.stopInfo;
}
document.getElementById("foundBusFrom").innertHTML = sStopSs;
}
if(destStopNameId !== '') { // dest not empty, find near stops
rAr = getStopsNear(destStopNameId);
dAr = rAr.startStops;
oDestStop = rAr.stopInfo;
var el = "To: " + dStopSs;
document.getElementById("foundBusTo").innertHTML = el;
}
if(startStopNameId === '' && destStopNameId !== '') { // start is blank so stops at destination
htmlTitle = 'Buses at and near destination: ' + dStopSs;
// document.getElementById("foundBusTitle").innerHTML = dStopSs;
htmlStart = stopsNear(destStopNameId);
htmlBody = htmlStart;
}
else if(startStopNameId !== '' && destStopNameId === '') {
htmlTitle = 'Buses at and near start: ' + sStopSs;
htmlDest = stopsNear(startStopNameId);
htmlBody = dirHdr + htmlDest + dirHdrClose;
}
else {
var rtDb = [0, ''];
var rtNb = [0, ''];
rtDb = getDirectBuses(oStartStop, oDestStop);
dHTML = '';
if(rtDb != undefined) {
if(rtDb[0])
dHTML = rtDb[1];
else
dHTML = '<div class="hilite"> No Direct buses found</div>';
if(rtDb[0] < 3) {
rtNb = getNearBuses(startStopNameId, destStopNameId);
if(rtNb[0])
nHTML = rtNb[1];
else
if(!rtDb[0]) // no message if we found direct buses
nHTML = '<div class="hilite"> No buses from nearby stops</div>';
}
}
cHTML = '';
if(arBusesFound.length < 1) {
// if(rtDb[0]< 3 && rtNb[0] < 3) {
rtCb = conxions(startStopNameId, destStopNameId);
if(rtCb !== null && rtCb[0])
cHTML = rtCb[1];
if(rtCb === null || !rtCb[0]) // no message if we found direct buses
cHTML = '<div class="hilite"> No bus connections</div>';
/* if(cHTML != "")
fndBus = fndBus + "<br>" + cHTML
else
fndBus = fndBus + "<div id='notfound'>" + "No Connections found" + '</div>'; */
}
// var dirHdr = '', dirHdrClose = '';
if((rtDb == undefined || rtDb[0] === 0) && rtNb[0] === 0) {
dirHdr = "";
dirHdrClose = '';
}
htmlBody = dirHdr + dHTML + nHTML + dirHdrClose + cHTML;
}
// document.getElementById("foundBusTitle").innerHTML = htmlTitle;
if (startStopNameId != "")
if ( destStopNameId != "" )
document.getElementById("foundBusFrom").innerHTML = "From: " + sStopSs;
else
document.getElementById("foundBusFrom").innerHTML = "Buses at and near: " + sStopSs;
if(destStopNameId != "")
document.getElementById("foundBusTo").innerHTML = "To: " + dStopSs;
else
document.getElementById("foundBusTo").innerHTML = ""; // No dest provided, blank it
if(htmlBody == "")
htmlBody = "<br>No buses found<br>";
document.getElementById("directBuses").innerHTML = htmlBody;
addRecentBusesFound({'busesFrom':sStopSs, 'busesTo':dStopSs, 'busHtml':htmlBody});
showRecentBusesFound();
}
// Buses from exact start to dest
function getDirectBuses(oStartStop, oDestStop) {
dBug('getDirectBuses', 'start', 5);
// directBuses = "";
var nDirectBuses = 0;
rAr = directBus(oStartStop, oDestStop);
if(rAr === null)
return null;
nDirectBuses = rAr[0];
sDirectBuses = rAr[1];
dBug('getDirectBuses', nDirectBuses + ', Start: ' + oStartStop.searchstr + ', Dest: ' + oDestStop, 5);
// dirHdr = "<tr><th>Stop name</th><th>Buses</th></tr>";
// sDirectBuses = "<table id='directbuses'>" + dirHdr + "<tr><td>Direct Buses (" +
// nDirectBuses + ") </td><td>" + sDirectBuses + "</td></tr>";
sDirectBuses = "<tr><td>Direct Buses (" +
nDirectBuses + ") </td><td>" + sDirectBuses + "</td></tr>";
if(nDirectBuses)
fndBusDirect = sDirectBuses;
else
fndBusDirect = "<div id='notfound'>No direct buses found</div>";
fndBus = fndBusDirect;
for(var x=0; x<nDirectBuses; x++)
arBusesFound[arBusesFound.length] = rAr[2][x][0];
return [nDirectBuses, fndBusDirect];
}
function getNearBuses(startStop, destStop) {
// Get the lat, lon of the current stop
var STOPNAMEID = 0;
var STOPLAT = 1;
var STOPLON = 2;
var startStopIdx = 0;
var destStopIdx = 0;
var x = 0;
// Now find stops near start to stops near destination
// Check for 10 stops before and after since our stops are ordered by lat lon
// Also within 111 m, 0.001, max 5 stops;
STOPIDX = 0;
DIIDX = 0;
// Check for near buses from near start to near dest
var sNearBuses = "";
var nNearBuses = 0;
var arNearBuses = [];
for(x=0; x < sAr.length; x++) {
for(var y=0; y < dAr.length; y++) {
if(sAr[x][1].stopnameid == oStartStop.stopnameid && dAr[y][1].stopnameid == oDestStop)
continue;
rAr = directBus(sAr[x][1], dAr[y][1]);
if(rAr[0] === 0) // No direct buses found, go to the next one
continue;
// If the bus in any of the direct buses, skip it
bFound = false;
for(a=0; a<rAr[2].length; a++)
bFound = checkFoundB4(rAr[2][a][STOPIDX]);
if(bFound)
continue;
nNearBuses = rAr[0];
sBuses = rAr[1];
distStartStop = sAr[x][DIIDX];
distDestStop = dAr[y][DIIDX];
s = distStartStop > 0 ? distStartStop : 0;
d = distDestStop > 0 ? distDestStop : 0;
if(nNearBuses) {
startSearchStr = sAr[x][1].searchstr;
destSearchStr = dAr[y][1].searchstr;
if(startStop == sAr[x][STOPIDX])
arNearBuses[arNearBuses.length] = [d, '', destSearchStr,
sBuses, nNearBuses, rAr[2]];
// sNearBuses = sNearBuses + '<tr><td>To ' + destSearchStr +
// ' (' + nNearBuses + ') </td><td>' + sBuses + '</td></tr>';
else if(destStop == dAr[y][STOPIDX])
arNearBuses[arNearBuses.length] = [s, startSearchStr, '',
sBuses, nNearBuses, rAr[2]];
// sNearBuses = sNearBuses + '<tr><td>From : ' + startSearchStr +
// ' (' + nNearBuses + ') </td><td>' + sBuses + '</td></tr>';
else {
var combDist = '';
if( distStartStop > 0 || distDestStop > 0) {
s = distStartStop > 0 ? distStartStop : 0;
d = distDestStop > 0 ? distDestStop : 0;
// combDist = '(' + distFormat(s + d) + ')';
arNearBuses[arNearBuses.length] = [s+d, startSearchStr, destSearchStr,
sBuses, nNearBuses, rAr[2]];
}
}
}
}
}
arNearBuses.sort(sortDiStop);
sNearBuses = '';
// busesDone = [];
sComma = '';
sBus = '';
nNearBuses = 0;
for(x=0; x<arNearBuses.length; x++) {
// build string of buses not displayed before - leave out buses already found
nearBusList = arNearBuses[x][5];
var busFound = false;
var busesFoundInRow = 0;
for(var a=0; a<nearBusList.length; a++) {
busFound = false;
for(var b=0; b<arBusesFound.length; b++) {
if(arBusesFound[b] == nearBusList[a][0]) {
busFound = true;
busesFoundInRow++;
}
}
if(!busFound) {
url = 'journey.html?b=' + nearBusList[a][0] + '&s=' + nearBusList[a][1] + '&d=' + nearBusList[a][1] + '"> ' + nearBusList[a][0];
sBus = sBus + sComma + '<a rel="external" href="javascript:window.location.href=' + url + '"> ' + nearBusList[a][0] + "</a>" ;
arBusesFound[arBusesFound.length] = nearBusList[a][0];
}
sComma = ', ';
}
if(busesFoundInRow < nearBusList.length) {
nNearBuses++;
sNearBuses = sNearBuses + '<tr><td>' + (arNearBuses[x][1] !== "" ? 'From: ' + arNearBuses[x][1] : "");
sNearBuses = sNearBuses + (arNearBuses[x][2] !== "" ? ' To: ' + arNearBuses[x][2] : "") + ' (' + arNearBuses[x][4] + ') - ' + distFormat(arNearBuses[x][0]) + '</td><td>' + arNearBuses[x][3] + '</td></tr>';
}
if(arBusesFound.length >= MAXBUSESTOSHOW)
break;
}
/* if(!nDirectBuses)
sNearBuses = "<table id='directbuses'>" + "<tr><th>Stop name</th><th>Buses</th></tr>"
+ sNearBuses;
*/
if(nNearBuses) {
fndBus = fndBus + "<tr><td><h3>From stops near you:</h3></td></tr>";
fndBus = fndBus + sNearBuses;
}
else
fndBus = fndBus + "<div id='notfound'>No near buses found</div>";
// No direct or near buses found, look for connections
return [nNearBuses, sNearBuses];
}
function directBus(oSStop, oDStop) {
if(oSStop === undefined || oDStop === undefined)
return null;
dBug("directBus", "start", 5);
var sDirectBus = '';
var nDirectBus = 0;
var startBuses = '';
var destBuses = '';
var x = 0;
// Get the buses at the start and destination stops
arStartBus = oSStop.busList.split(", ");
arDestBus = oDStop.busList.split(", ");
sComma = "";
var retArray = [];
var dBus = [];
for(x=0; x < arStartBus.length; x++) {
sb = arStartBus[x].split("|");
for(var y=0; y < arDestBus.length; y++) {
db = arDestBus[y].split("|");
if(sb[0] == db[0]) {
busInfo = getBusInfo(sb[0]);
busfreq = "";
if(busInfo != undefined && busInfo.frequency !="")
busfreq = "&nbsp;(&nbsp;" + busInfo.frequency + "&nbsp;mins)";
url = 'journey.html?b=' + sb[0] + '&s=' + sb[1] + '&d=' + db[1];
url = '#';
sDirectBus = sDirectBus + sComma + buildUrl(sb[0], sb[1], db[1]);
nDirectBus++;
sComma = ", &nbsp;";
dBus[dBus.length] = [sb[0], sb[1], db[1]];
}
}
}
retArray = [nDirectBus, sDirectBus, dBus];
return retArray;
}
// Find connections - change bus at one point between start and destination
function conxions(startStop, destStop) {
if(startStop == undefined || destStop == undefined)
return null;
var AREA = 0;
var STOPNAMEID = 1;
var SEARCHSTR = 2;
var LAT = 3;
var LON = 4;
var BUSLIST = 5;
var MAXROUTES = 5;
var commonBus = new Array();
// var sCB = new Array();
// var dCB = new Array();
var arBestDist = [];
var areas = getAreas();
var startBuses = '';
var destBuses = '';
var htmCommonStops = "";
// first get the stop info
if(oStartStop == undefined || oDestStop == undefined)
return null;
startBuses = oStartStop.busList;
destBuses = oDestStop.busList;
var startAreaLat = 0; var startAreaLon = 0; var destAreaLat = 0; var destAreaLon = 0;
for(var i=0; i<areas.length; i++) {
if(oStartStop.area == areas[i][0]) {
startAreaLat = areas[i][1];
startAreaLon = areas[i][2];
}
if(oDestStop.area == areas[i][0]) {
destAreaLat = areas[i][1];
destAreaLon = areas[i][2];
}
}
nwLat = startAreaLat; nwLon = startAreaLon; seLat = destAreaLat; seLon = destAreaLon;
if( startAreaLat < destAreaLat ) {
nwLat = destAreaLat;
seLat = startAreaLat;
}
if( startAreaLon > destAreaLon) {
nwLon = destAreaLon;
seLon = startAreaLon;
}
arStartBuses = startBuses.split(", ");
arDestBuses = destBuses.split(", ");
var commonStops = [];
bStartFound = false;
bDestFound = false;
br = "<br>";
var n = 1;
curStop = "";
curSb = ""; curDb = "";
for(x=0; x < stopBusLines.length; x++) {
// dBug('conxion: ', 'checking common stops - ' + x, 5);
if(stopBusLines[x] !== "") {
ar = stopBusLines[x]; // ["138048", "10throad", "[Chembur W] 10Th Road", "8 L|34, 19 L|29, 92 L|48, 355 L|14, 362|2, 364|17"]
// Check whether the area of this stop is within the square start and dest
if(ar[LAT] > nwLat || ar[LON] > seLon || ar[LAT] < seLat || ar[LON] < nwLon)
continue;
sCb = ""; dCb = "";// Source and dest common buses
buses = ar[BUSLIST].split(", "); // ["8 L|34", "19 L|29", "92 L|48" ....]
// check if the stop has a bus in start and a bus in destination
bStartFound = false; bDestFound = false;
sCb = ''; sComma = ""; dCb = ''; dComma = "";
for(var c=0; c<buses.length;c++) {
bus = buses[c].split('|');
for(var y=0; y<arStartBuses.length; y++) {
sb = arStartBuses[y].split("|"); // ["A 70 Exp AC Exp", "13"] - bus, stopno.
if(bus[0] == sb[0] && !checkFoundB4(sb[0])) {// start bus found, check if dest bus there
bStartFound = true;
busInfo = getBusInfo(sb[0]);
busfreq = "";
if(busInfo.frequency != undefined)
busfreq = "&nbsp;(&nbsp;" + busInfo.frequency + "&nbsp;mins)";
sCb = sCb + sComma + '<a rel="external" href="journey.html?b=' + sb[0] +
'&s=' + sb[1] + '&d=' + bus[1] + '"> ' + sb[0] + busfreq + "</a>";
sComma = ", ";
}
}
for(var z=0; z<arDestBuses.length; z++) {
db = arDestBuses[z].split('|');
if(bus[0] == db[0]) {
bDestFound = true;
busInfo = getBusInfo(sb[0]);
busfreq = "";
if(busInfo.frequency != undefined)
busfreq = " ( " + busInfo.frequency + " mins)";
dCb = dCb + dComma + '<a rel="external" href="journey.html?b=' + db[0] +'&s=' + bus[1] + '&d=' + db[1] + '"> ' + db[0] + busfreq + "</a>";
// dCb = dCb + dComma + db;
dComma = ", ";
}
}
}
if(bStartFound && bDestFound) {
dBug('conxions: ', 'Found stop', 5);
var csLat = 0; var csLon = 0; var diStart = -1, diDest = -1;
for(i=0; i<areas.length; i++) {
if(ar[AREA] == areas[i][0]) {
csLat = areas[i][1];
csLon = areas[i][2];
diStart = distanceLatLon(csLat, csLon, startAreaLat, startAreaLon);
diDest = distanceLatLon(csLat, csLon, destAreaLat, destAreaLon);
}
}
combDist = -1;
if(diStart > 0 && diDest > 0) {
combDist = diStart + diDest;
arBestDist[combDist] =
[ar[STOPNAMEID], ar[SEARCHSTR], sCb, dCb, combDist];
dBug('conxions: ', 'Comb. dist - ' + combDist, 5);
}
// Check if this bus is in the direct or near buses, if so skip
commonStops[commonStops.length] =
[ar[STOPNAMEID], ar[SEARCHSTR], sCb, dCb, combDist];
n++;
}
}
}
dBug('conxions: ', 'found - ' + arBestDist.length, 5);
htmCommonStops = "";
var nStops = 0;
for(y=0; y<arBestDist.length; y++) {
if(arBestDist[y] != undefined) {
htmCommonStops = htmCommonStops + "<tr><td>" + arBestDist[y][1] + " (" + distFormat(arBestDist[y][4]) + ")</td><td>" + arBestDist[y][2] + "</td><td>" + arBestDist[y][3] + "</td><td></tr>";
nStops++;
dBug('conxions', arBestDist[y][1] + " (" + distFormat(arBestDist[y][4]), 5);
if(nStops > MAXROUTES)
break;
}
}
if (!nStops) {
for(x=0; x<commonStops.length; x++) {
htmCommonStops = htmCommonStops + "<tr><td>" + commonStops[x][1] + ")</td><td>"
+ commonStops[x][2] + "</td><td>" + commonStops[x][3] + "</td><td></tr>";
}
}
htmHdr = "<tr><th>Connecting Stop</th><th>Buses from start</th><th>Buses to Destination</th></tr>";
htmCommonStops = '<table class="tbl_color">' + htmHdr + htmCommonStops + "</table>";
return [nStops, htmCommonStops];
}
// Check if bus already found
function checkFoundB4(busno) {
if(busno == undefined)
return false;
var bFound = false;
for(b=0; b<arBusesFound.length; b++) {
if(busno.replace(/ /g, '') == arBusesFound[b].replace(/ /g, ''))
bFound = true;
}
return bFound;
}
function stopsNear(startStop) {
var STOPNAMEID = 0;
var STOPLAT = 1;
var STOPLON = 2;
var startStopIdx = 0;
var destStopIdx = 0;
var bStopFound = false;
var rHTML = '';
var arNearStopBuses = [];
for(x=0; x<sAr.length && x < SHOWMAXSTOPS; x++) {
stopInfo = sAr[x][1];
/* if(sAr[x][0] === 0) // Its this stop, so we don't need it
continue; */
sBus = '';
sComma = '';
arStopBus = stopInfo.busList.split(", ");
arBusesAtStop = [];
var nNewBus = 0;
var nBusesAtStop = 0;
for(var y=0; y < arStopBus.length; y++) {
stopbus = arStopBus[y].split("|");
var bBusFound = false;
for(var a=0; a<arNearStopBuses.length; a++) {
if(stopbus[0] == arNearStopBuses[a]) {
bBusFound = true;
break;
}
}
if(!bBusFound) {
arNearStopBuses[arNearStopBuses.length] = stopbus[0];
nNewBus++;
}
// arBusesAtStop[arBuesesAtStop.length] = stopbus[0];
sBus = sBus + sComma + '<a href="journey.html?b=' + stopbus[0] + '&s=0&d=0"> ' + stopbus[0] + "</a>" ;
sComma = ", &nbsp;";
}
if(nNewBus) {
rHTML = rHTML + '<tr><td>' + stopInfo.searchstr + ' (' + distFormat(sAr[x][0]) + ')</td><td>';
rHTML = rHTML + sBus + '</td></tr>';
}
}
return rHTML;
}
// Sort the distance, stops array by the shortest distance
function sortDiStop(a, b) {
return ((a[0] < b[0]) ? -1 : ((a[0] > b[0]) ? 1 : 0));
}
function getStopInfo(stopnameid) {
var oBus = null;
for(x=0; x < stopBusLines.length; x++) {
if(stopBusLines[x] !== "") {
ar = stopBusLines[x];
stopname = ar[1];
if(stopname == stopnameid) {
oBus = {"area":ar[0], "stopnameid":ar[1], "searchstr":ar[2],
"lat":ar[3], "lon":ar[4], "busList":ar[5]};
break;
}
}
}
return oBus;
}
function getStopsNear(stopNameId) {
var STOPNAMEID = 0;
var STOPLAT = 1;
var STOPLON = 2;
var startStopIdx = 0;
var destStopIdx = 0;
var bStopFound = false;
oStop = getStopInfo(stopNameId);
if(oStop === null)
return null;
var sAr = [];
for(x=0; x < stopBusLines.length && oStop != null; x++) {
var ar = stopBusLines[x];
if(ar[3] != undefined && ar[4] != undefined) {
if(oStop.lat != undefined && Math.abs(oStop.lat - ar[3]) < NEARLATLON &&
Math.abs(oStop.lon - ar[4]) < NEARLATLON) {
di = distanceLatLon(ar[3], ar[4], oStop.lat, oStop.lon);
if( di < WALKDIST)
sAr[sAr.length] = [di, {"area":ar[0], "stopnameid":ar[1],
"searchstr":ar[2], "lat":ar[3], "lon":ar[4], "busList":ar[5]}];
}
}
}
sAr.sort(sortDiStop);
// Check if source and destination stops are there
// If not prolly because lat lon not there add them
var SHOWMAXSTOPS = 5;
var stopFound = false;
for(x=0; x<sAr.length; x++) {
if(sAr[x][1] == stopNameId) {
stopFound = true;
break;
}
}
if(!stopFound)
sAr[sAr.length] = [0, oStop];
return { "startStops":sAr, "stopInfo":oStop };
}
// Add to the list of recent BusesFound
function addRecentBusesFound(oBusesFound) {
var rs = localStorage['recentBusesFound'];
var recentBusesFoundPrv;
if(rs != null)
recentBusesFoundPrv = JSON.parse(rs);
recentBusesFound = null;
var recentBusesFound = new Array;
recentBusesFound[0] = oBusesFound;
if(recentBusesFoundPrv !== null && recentBusesFoundPrv != undefined) {
for(var i = 0; i < recentBusesFoundPrv.length; i++) {
if(recentBusesFoundPrv[i] === undefined || recentBusesFoundPrv[i] === null)
continue;
// check if already in array, else add
alreadyThere = false;
for(var j = 0; j < recentBusesFound.length; j++) {
if(recentBusesFound[j].busHtml === recentBusesFoundPrv[i].busHtml) {
alreadyThere = true;
break;
}
}
if(!alreadyThere)
recentBusesFound[recentBusesFound.length] = recentBusesFoundPrv[i];
}
}
localStorage['recentBusesFound']=JSON.stringify(recentBusesFound);
}
function showRecentBusesFound() {
if(localStorage['recentBusesFound'] === undefined || localStorage['recentBusesFound'] === null)
return;
var recentBusesFound = JSON.parse(localStorage['recentBusesFound']);
recentBusesFoundStr = '<table id="recentBusesFound" class="tbl_color">';
if(recentBusesFound === null)
return;
if(recentBusesFound.length) {
// recentBusesFoundStr = '<table id="recentBusesFound">';
for(var i = 1; i < recentBusesFound.length && i < MAXRECENTBUSESFOUND; i++) {
if(recentBusesFound[i] !== null && recentBusesFound[i] !== undefined
&& typeof(recentBusesFound[i]) === 'object') {
elm = recentBusesFound[i].busesFrom + '<br>' +
recentBusesFound[i].busesTo + '<br>' +
recentBusesFound[i].busHtml + '<br>';
recentBusesFoundStr = recentBusesFoundStr + elm;
}
}
recentBusesFoundStr = recentBusesFoundStr + '</table>';
document.getElementById("recentBusesFound").innerHTML = recentBusesFoundStr;
}
}

126
busroute.js Normal file
View File

@ -0,0 +1,126 @@
var bDbug = true;
var dBugLvl = 3;
var STOPNO = 0;
var SEARCHSTR = 1;
var NXTDIST = 2;
var NXTTIME = 3;
var LAT = 4;
var LON = 5;
var NEARLAT = 0.01;
var busno = '';
var called_times = 0;
var stopLines = "";
var geoPos;
var arBusList = [];
var busNoList = [];
var stopBusLines = '';
var gStartStopnameId = 0;
var gDestStopnameId = 0;
var gStartStopSearchStr;
var gDestStopSearchStr;
var gStartStop;
var gDestStop;
var busMaster = [];
var homePage;
var gFndBus = "";
var startStopLat = 0;
var startStopLon = 0;
var destStopLat = 0;
var destStopLon = 0;
var stopBus = [];
var stopNames = [];
var db;
$(document).ready(function() {
arBusList = getbuslist();
stopBus = getStopBusList();
busMaster = getbusmaster();
stopNames = getStopNames();
for(var i=0; i<arBusList.length; i++)
busNoList[i] = arBusList[i][0];
PopulateAllBusList();
PopulateOtherBusLists();
getLocation(); // runs setGeoPos(pos), showLocation(pos)
});
function PopulateOtherBusLists() {
var oBus = document.getElementById('oBus');
var lBus = document.getElementById('lBus');
var aBus = document.getElementById('aBus');
var asBus = document.getElementById('asBus');
var cBus = document.getElementById('cBus');
if(oBus === null || lBus === null || aBus === null || asBus === null)
return;
for(var x=0; x<arBusList.length; x++) {
var option = document.createElement("option");
var busInfo = getBusInfo(arBusList[x][1]);
var busfreq = "";
if(busInfo != undefined && busInfo.frequency !="")
busfreq = '(' + busInfo.frequency + " mins)";
option.text = arBusList[x][1] + " - " + arBusList[x][2] + " to " +
arBusList[x][3]; // + ' ' + busfreq;
option.value = arBusList[x][1];
if(arBusList[x][1] == arBusList[x][0])
oBus.add(option, null);
else if(arBusList[x][1].indexOf('AC Exp') >= 0)
aBus.add(option, null);
else if(arBusList[x][1].indexOf('L') >= 0)
lBus.add(option, null);
else if(arBusList[x][1].indexOf('AS') >= 0)
asBus.add(option, null);
else if(arBusList[x][1].indexOf('C') >= 0)
cBus.add(option, null);
}
}
$(function () {
$("#busNo").autocomplete({
source: function(req, response) {
var re = $.ui.autocomplete.escapeRegex(req.term);
re = re.toLowerCase();
var len = re.length;
var i = 0;
matchArr = [];
for(var j=0; j<arBusList.length; j++) {
if(re == arBusList[j][0].toLowerCase().substring(0, len)
|| re == arBusList[j][1].toLowerCase().substring(0, len)) {
matchArr[i] = arBusList[j][1];
i = i + 1;
}
}
response(matchArr);
}
});
});
function showLocation(pos) { // Stops near you
// showRoutesAtStop({'area':'Tardeo', 'id':'bhatiahospital'}, 'Bus Routes Near You');
var oStop = findNearestStop(pos);
showRoutesAtStop(oStop, 'Bus Routes Near You ');
}
// set the local variable so it can be used in this js file
function setGeoPos(pos) {
geoPos = pos;
}

1
busroutes/bcjs1.js Normal file

File diff suppressed because one or more lines are too long

1
busroutes/bcjs2.js Normal file

File diff suppressed because one or more lines are too long

1
busroutes/bcjs3.js Normal file

File diff suppressed because one or more lines are too long

1
busroutes/bcjs4.js Normal file

File diff suppressed because one or more lines are too long

1
busroutes/bcjs5.js Normal file

File diff suppressed because one or more lines are too long

1
busroutes/bcjs6.js Normal file

File diff suppressed because one or more lines are too long

1
busroutes/bcjs7.js Normal file

File diff suppressed because one or more lines are too long

1
busroutes/bcjs8.js Normal file

File diff suppressed because one or more lines are too long

1
busroutes/bcjs9.js Normal file

File diff suppressed because one or more lines are too long

1
busroutes/bcjsa.js Normal file

File diff suppressed because one or more lines are too long

1
busroutes/bcjsc.js Normal file

File diff suppressed because one or more lines are too long

1
busroutes/bjs10l.js Normal file
View File

@ -0,0 +1 @@
function getb10l() { bjs10l = [[1,"[Fort] Hutatma Chowk / Mumbai University",1207,3,18.94381,72.83924],[2,"[Dhobi Talao] V B Phadke Chk / Metro / Dhobi Talao",,,18.94463,72.83034],[3,"[Bhuleshwar] Kalbadevi",,,,],[4,"[Dhobi Talao] Swadeshi Market",,,,],[5,"[Bhuleshwar] Bhuleshwar",,,,],[6,"[Bhendi Bazar] Vijay Vallabh Chowk / Pydhuni",,,,],[7,"[Bhendi Bazar] Johar Chowk",,,18.95953,72.83176],[8,"[Bhendi Bazar] Dr M Iqbal Chowk",,,,],[9,"[Nagpada] A H Ansari Chowk",451,2,18.96646,72.83259],[10,"[Nagpada] St Marys High School",344,2,18.96985,72.83494],[11,"[Mazgaon] Mazgaon Court",339,2,18.96906,72.8381],[12,"[Mazgaon] Maharana Pratap Chowk Mazgaon",259,2,18.96864,72.84129],[13,"[Dockyard Road] Dockyard Road Railway Station",,,18.96836,72.84374],[14,"[Mazgaon] BEST Power House / Kussara",,,,],[15,"[Dockyard Road] Daru Khana",,,18.97152,72.84518],[16,"[Reay Road W] Reay Road Bridge",,,,],[17,"[Kala Chowky] Ghodpdeo",571,2,18.97967,72.84347],[18,"[Kala Chowky] Albert Road / Tanaji Malusare Chowk",318,2,18.98466,72.8422],[19,"[Kala Chowky] Shrawan Yeshwante Chowk",88,2,18.98745,72.84152],[20,"[Kala Chowky] Kala Chowky Police Station",,,18.98815,72.84112],[21,"[Sewree] Tank Bunder",,,18.98883,72.84574],[22,"[Sewree] Jackeria Bunder",,,18.99482,72.84884],[23,"[Sewree] Sewree Court",,,18.99652,72.85306],[24,"[Sewree] Sewree Station W",,,18.99851,72.85335],[25,"[Sewree] Shivaji Nagar Sewree",,,19.00131,72.85371],[26,"[Sewree] Dnyaneshwar Nagar",,,19.00503,72.85359],[27,"[Wadala W] Kidwai Nagar",,,,],[28,"[Wadala W] Madhav Nagar",,,,],[29,"[Wadala W] Wadala Station W",,,19.057,72.5127],[30,"[Wadala W] Wadala Gate No 4",,,,],[31,"[Wadala W] Amulakh High School / Arora Cinema",,,,],[32,"[Kings Circle] Maheshwari Udyan",764,3,19.02678,72.85468],[33,"[Kings Circle] Gandhi Market Matunga",407,2,19.03259,72.85856],[34,"[Sion E] Lokmanya Tilak Hospital / Sion Hosp",2727,6,19.03592,72.86017],[35,"[Sion E] Rani Laxmibai Chowk / Sion / Sion Circle",,,19.04573,72.86513],[36,"[Kurla W] Kurla Level Crossing",,,,],[37,"[Kurla W] Lions Park",,,,],[38,"[Kurla W] Kurla Post Office",,,,],[39,"[Kurla W] Anjanabai Magar",,,,],[40,"[Kurla W] Kurla Depot",1245,3,19.06783,72.87884],[41,"[Kurla W] Old Agra Road",381,2,19.079,72.87966],[42,"[Kurla W] Sheetal Cinema",708,3,19.08183,72.88171],[43,"[Vidyavihar W] Kamani",,,19.08513,72.88747],[44,"[Vidyavihar W] Mukund Company / P W D Office",,,19.08484,72.89034],[45,"[Vidyavihar W] Guru Nanak Nagar",,,19.0854,72.89332],[46,"[Ghatkopar W] Narayan Nagar Ghatkopar",,,19.5906,72.5343],[47,"[Ghatkopar W] Chirag Nagar",649,2,19.08659,72.89725],[48,"[Ghatkopar W] Ghatkopar Pipe Line",385,2,19.08778,72.9033],[49,"[Ghatkopar W] Sarvodaya Hospital",,,19.08876,72.90681],[50,"[Ghatkopar W] Gopal Bhuvan",,,19.0907,72.90984],[51,"[Ghatkopar W] Nityanand Nagar",,,19.53,72.5446],[52,"[Ghatkopar W] Laxmi Nagar",,,19.522,72.5458],[53,"[Ghatkopar E] Ghatkopar Depot / Caseurina",,,,]]; return bjs10l;}

563
cf.js Normal file
View File

@ -0,0 +1,563 @@
/*!
* Common funcs needed for bestbus
*
* Copyright 2011, Chetan Temkar
*
* Date: Thu Mar 31 15:28:23 2011 -0400
*/
var CTIME = 100; // Cookie expires after 100 days
var MAXNEARSTOPDIST = 1000; // Nearest stops should be within 1 km.
var NEARLATLON = .001 // Within 1.1 kms.
function loadStyles() {
bl = BrowserLevel();
if(bl == 'A') {
document.write('<meta name="viewport" content="user-scalable=no, width=device-width" />');
}
loadjscssfile("css/basic.css", 'css');
loadjscssfile("css/main.css", 'css');
}
// See if smartphone or lower
function BrowserLevel() {
browser = navigator.userAgent.toLowerCase();
if(browser.search('safari') || browser.search('android') )
return 'A';
if(browser.search('firefox'))
return 'FF'; // Firefox problems with offline storage
if(browser.search('blackberry'))
return 'BB'; // Firefox problems with offline storage
else
return 'C';
}
// distance between 2 lat, lon pairs
function distanceLatLon(lat1, lon1, lat2, lon2) {
var R = 6371; // km
var dLat = (lat2-lat1) * Math.PI / 180;
var dLon = (lon2-lon1) * Math.PI / 180;
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2* Math.PI / 180) *
Math.sin(dLon/2) * Math.sin(dLon/2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
var d = R * c;
return Math.ceil(d * 1000); // return distance in meters
}
// setup location handler to get location by gps or cell towers
function getLocation() {
var lat, lon, gps, options, geo, watch;
gps = navigator.geolocation;
options = {timeout:60000, maximumAge:330000};
if(gps) {
browserSupportFlag = true;
navigator.geolocation.getCurrentPosition(function(position) {
lat = position.coords.latitude;
lon = position.coords.longitude;
}, function() {
handleNoGeolocation(browserSupportFlag);
});
// Try Google Gears Geolocation
} else if (google.gears) {
browserSupportFlag = true;
geo = google.gears.factory.create('beta.geolocation');
geo.getCurrentPosition(function(position) {
setGeoPos(pos);
showLocation(position);
}, function() {
handleNoGeoLocation(browserSupportFlag);
});
// Browser doesn't support Geolocation
} else {
browserSupportFlag = false;
handleNoGeolocation(browserSupportFlag);
}
if(gps != undefined) {
trackerId = gps.watchPosition(function(pos){
setGeoPos(pos);
showLocation(pos);
}, errorHandler, options);
}
else if (geo != undefined) {
watch = geo.watchPosition(function(pos){
setGeoPos(pos);
showLocation(pos);
}, errorHandler, options);
}
}
function handleNoGeolocation(errorFlag) {
if (errorFlag == true) {
// alert("Geolocation service failed.");
initialLocation = null;
} else {
// alert("Your browser doesn't support geolocation");
initialLocation = null;
}
// map.setCenter(initialLocation);
}
function showLoc(pos) {
setGeoPos(pos);
showLocation(pos);
}
function errorHandler(err) {
if(err.code == 1) {
dBug("geo:", "Error: Access is denied!", 5);
}else if( err.code == 2) {
dBug("geo", "Error: Position is unavailable!", 5);
}
}
// Format a date into hours, minutes
function timeStr(dt) {
var currentTime = dt;
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
var suffix = "AM";
if (hours >= 12) {
suffix = "PM";
hours = hours - 12;
}
if (hours === 0) {
hours = 12;
}
if (minutes < 10)
minutes = "0" + minutes;
return hours + ":" + minutes + " " + suffix;
}
function distFormat(d, maxd) { // d in meters, maxd -max distance allowed in km., else show as NA
if(maxd === undefined)
maxd = 10;
if(d / 1000 > maxd || typeof(d) == undefined || isNaN(d))
return "N/A";
if( d >= 1000)
return Math.round((d/ 1000)*100)/100 + '&nbsp;km';
else
return Math.round(d*1000)/1000 + '&nbsp;m';
}
function getFile(fileName){
oxmlhttp = null;
try{
oxmlhttp = new XMLHttpRequest();
oxmlhttp.overrideMimeType("text/xml");
}
catch(e){
try{
oxmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){
return null;
}
}
if(!oxmlhttp) return null;
try{
oxmlhttp.open("GET",fileName,false);
oxmlhttp.send(null);
}
catch(e){
return null;
}
return oxmlhttp.responseText;
}
function stopTracking(){
if (trackerId){
navigator.geolocation.clearWatch(trackerId);
}
}
function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays===null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}
function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
x=x.replace(/^\s+|\s+$/g,"");
if (x==c_name)
{
return unescape(y);
}
}
return '';
}
function dBug(sModule, sDebugStr, lvl) {
if(dBug && lvl < dBugLvl)
alert(sModule + ': ' + sDebugStr);
}
var STOPNAMEID = 1;
var SEARCHSTR = 0;
// return the first search string for a stopnameid
function findStopSs(stopnameid)
{
stopnameid = stopnameid.toLowerCase();
stops = getStopNames();
nStopsFound = 0;
for(var x=0; x < stops.length; x++) {
if(stopnameid == stops[x][STOPNAMEID])
return stops[x][SEARCHSTR];
}
return null;
}
// Find a stopnameid in the stopnames array and returns information about it
// returns no. of stops found,
function findStopId(stopid) {
stopid = stopid.toLowerCase();
stopNames = getStopNames();
nStopsFound = 0;
stopsFound = [];
stopsSrchStr = [];
for(var x=0; x < stopNames.length; x++) {
searchstr = stopNames[x][3].toLowerCase();
if(searchstr.search(stopid) != -1) {
nStopsFound++;
stopsFound = stopNames[x][3];
stopsSrchStr = stopNames[x][0] + ': ' + stopNames[x][1] + ' ' + stopNames[x][2];
break;
}
}
return {'nostopsFound':nStopsFound, 'stopsfound':stopsFound, 'stopsrchstr':stopsSrchStr};
}
// Find a stop searchstr in the stopnames array and returns information about it
// returns no. of stops found,
function findStop(stopstr) {
stopstr = stopstr.replace(/[^0-9a-zA-Z]+/g,'').toLowerCase(); // remove special characters, spaces
stops = getStopNames();
nStopsFound = 0;
stopsFound = [];
stopsSrchStr = [];
for(var x=0; x < stops.length; x++) {
searchstr = stops[x][0].replace(/[^0-9a-zA-Z]+/g,'').toLowerCase();
if(searchstr.search(stopstr) != -1) {
nStopsFound++;
stopsFound[stopsFound.length] = stops[x][1];
stopsSrchStr[stopsSrchStr.length] = stops[x][0];
if(searchstr.length == stopstr.length)
break; // exact match, so we have found our stop
}
}
return [nStopsFound, stopsFound, stopsSrchStr];
}
// Find a searchstr based on the stop name id
function getSearchStr(stopid) {
stops = getStopNames();
for(var x=0; x < stops.length; x++) {
if(stopid == stops[x][1]) {
// startStopLat = stopll[STOPLAT];
// startStopLon = stopll[STOPLON];
// startStopIdx = x;
return stops[x][0];
}
}
return '';
}
function getWinDim() {
var winW = 630, winH = 460;
if (document.body && document.body.offsetWidth) {
winW = document.body.offsetWidth;
winH = document.body.offsetHeight;
}
if (document.compatMode=='CSS1Compat' &&
document.documentElement &&
document.documentElement.offsetWidth ) {
winW = document.documentElement.offsetWidth;
winH = document.documentElement.offsetHeight;
}
if (window.innerWidth && window.innerHeight) {
winW = window.innerWidth;
winH = window.innerHeight;
}
// winW = screen.width < winW ? screen.width : winW;
// winH = screen.height < winH ? screen.height : winH;
// dBug('$window.width: ' + $(window).width() + ', $document.width(): ' + $(document).width());
return {
"wd": parseInt(winW, 10),
"ht": parseInt(winH, 10)
};
}
// get frequency, first bus time, last bus time from busmaster
function getBusInfo(busno) {
busno = busno.replace(/[^0-9a-zA-Z]+/g,'').toLowerCase();
busno = busno.replace('expacexp', 'e');
for(var x=0; x<busMaster.length; x++) {
if(busmaster[x][0] == busno) {
return { "firstFrom":busmaster[x][1], "lastFrom":busmaster[x][2],
"frequency":busmaster[x][3]};
}
}
}
// Call this link when bus is selected to set cookies and then fire the link.
// Done so that parameters are passed through cookies not link
// because offline storage does not work with changing links
function goLinkBusRoute(busNo, startStopNo, destStopNo, direction) {
url = 'journey.html?b=' + busNo + '&s=' + startStopNo +
'&d=' + destStopNo + '&dir=' + direction;
setCookie('cBusNo', busNo, 1);
setCookie('cStartStopNo', startStopNo, CTIME);
setCookie('cDestStopNo', destStopNo, CTIME);
setCookie('cDirection', direction, CTIME);
window.location = url;
return false;
}
// Build the url for showstops
function buildUrl(busNo, startStopNo, destStopNo) {
busInfo = getBusInfo(busNo);
busfreq = "";
var direction = 'd';
if(startStopNo < destStopNo)
direction = 'u';
if(busInfo != undefined && busInfo.frequency !="")
busfreq = "&nbsp;(&nbsp;" + busInfo.frequency + "&nbsp;mins)";
url = '<a href="#"' + ' onClick="return goLinkBusRoute('
+ "'" + busNo + "'" + ',' + startStopNo + ',' + destStopNo +
", '" + direction + "'" + ')">'
+ busNo.replace(/ /g, '&nbsp;') + busfreq + "</a>" ;
return url;
}
// Show all bestbus cookies for debugging
function showBBCookies() {
alert(printCookie('cMyLat') + printCookie('cMyLon') + printCookie('cStartStop')
+ printCookie('cStartStopId') + printCookie('cDestStop')
+ printCookie('cDestStopId') + printCookie('cStartStopNameId')
+ printCookie('cDestStopNameId') + printCookie('cBusNo')
+ printCookie('cStartStopNameid') + printCookie('cDestStopnameId'));
return;
}
function printCookie(cookieName) {
return cookieName + " : " + getCookie(cookieName) + ", ";
}
// This disables enter key for BB where you can select from auto suggest only with enter
function disableEnterKey(e)
{
var key;
if(window.event)
key = window.event.keyCode; //IE
else
key = e.which; //firefox
return (key != 13);
}
function showRoutesAtStop(oStop, title) { // Bus routes at stop
var busList = null;
document.getElementById("busroutesatstart").innerHTML = title + '(' + oStop.area + ')';
for(var i = 0; i < arStopBus.length; i++) {
if(arStopBus[i][1] == oStop.id) {
busList = arStopBus[i][5];
break;
}
}
var firstStop, lastStop;
if(busList != null) {
arNearBuses = busList.split(",");
routesAtStopStr = '<table id="routesAtStop" class="tbl_color">';
for(var j = 0; j < arNearBuses.length; j++) {
busNo = arNearBuses[j].split("|")[0].trim();
for(var a = 0; a < arBusList.length; a++) {
if(arBusList[a][1] == busNo) {
firstStop = arBusList[a][2];
lastStop = arBusList[a][3];
}
}
busInfo = getBusInfo(busNo);
busfreq = "";
if(busInfo != undefined && busInfo.frequency !="")
busfreq = "&nbsp;(&nbsp;" + busInfo.frequency + "&nbsp;mins)";
busInfo = getBusInfo(busNo);
busfreq = "";
if(busInfo != undefined && busInfo.frequency !="")
busfreq = busInfo.frequency + "&nbsp;mins";
sBusNo= busNo.replace('Exp AC Exp', 'AC Exp');
sBusNo = sBusNo.replace(/ /g, '&nbsp;');
url = '<a href="#"' + ' onClick="return goLinkBusRoute(' + "'" + busNo + "'"
+ ', 0, 0)' + '">' + '<span style="font-weight:bold;">' + sBusNo + '</span>' +
'</td><td>' + firstStop + ' - ' + lastStop +
'</td><td>' + busfreq + "</a>" ;
routesAtStopStr = routesAtStopStr + '<tr><td>' + url + "</a></td></tr>";
// routesAtStopStr = routesAtStopStr + '<tr><td>' + recentStops[i] + '</td></tr>';
}
routesAtStopStr = routesAtStopStr + '</table>';
document.getElementById("routesAtStop").innerHTML = routesAtStopStr;
}
}
// Find stops near a postion (lat, lon)
function findNearStops(pos) {
var nearStop, retNearStop, x, y, dLat, dLon, di;
nearStop = [];
aoNearStops= [];
y = 0;
for (x = 0; x < arStopNames.length; x += 1) {
dLat = parseFloat(arStopNames[x][4]);
dLon = parseFloat(arStopNames[x][5]);
if (Math.abs(pos.coords.latitude - dLat) < NEARLAT
&& Math.abs(pos.coords.longitude - dLon) < NEARLAT) {
di = distanceLatLon(pos.coords.latitude, pos.coords.longitude,
dLat, dLon);
if (di < MAXNEARSTOPDIST) {
var sname = stopNames[x][1];
var lmark = stopNames[x][2];
stopnameext = lmark !== null ? sname + ' /' + lmark : sname;
aoNearStops[aoNearStops.length] = {"di": di, "id": arStopNames[x][3],
"area": arStopNames[x][0], "stopname": arStopNames[x][1],
"landmark": arStopNames[x][2], 'stopnameext':stopnameext};
}
}
}
// aoNearStops.sort(distSort);
aoNearStops.sort(function(a, b) {return a.di - b.di});
if(aoNearStops.length === 0)
return null;
aoNearStops.length = 3; // return only 3 stops
return aoNearStops;
}
function showRoute(busNo)
{
goLinkBusRoute(busNo, 0, 0);
}
// Show a complete bus route
function showRouteComplete() {
bTxt = $('#busNo').val();
// Find the route in array
if(bTxt.length > 0) {
bTxt = bTxt.replace(/ /g, "");
bTxt = bTxt.toUpperCase();
var busFound = false;
for(var x=0; x<arBusList.length; x++) {
if(bTxt == arBusList[x][1].replace(/ /g, "").toUpperCase()) {
bTxt = arBusList[x][1];
busFound = true;
break;
}
}
if(!busFound) {
alert('Bus not found, please re-enter');
return false;
}
busNo = bTxt;
setCookie('cBusNo', bTxt, 365);
}
else {
bCombo = document.getElementById('busNoCombo');
busNo = bCombo.options[bCombo.selectedIndex].value;
}
goLinkBusRoute(busNo, 0, 0);
return;
}
// Populate the All buses List combo
function PopulateAllBusList() {
bCombo = document.getElementById('busNoCombo');
for(var x=0; x<arBusList.length; x++) {
var busInfo = getBusInfo(arBusList[x][1]);
var busfreq = "";
if(busInfo != undefined && busInfo.frequency !="")
busfreq = '(' + busInfo.frequency + " mins)";
var option = document.createElement("option");
option.text = arBusList[x][1] + " - " + arBusList[x][2] + " : "
+ arBusList[x][3]; // + ' ' + busfreq;
option.value = arBusList[x][1];
bCombo.add(option, null);
}
// $("#busNoCombo").selectmenu('refresh', true);
}
function supports_local_storage() {
try {
return 'localStorage' in window && window['localStorage'] !== null;
} catch(e){
return false;
}
}
function showAndroidToast(toast) {
/*
txt = "<p>Browser CodeName: " + navigator.appCodeName + "</p>";
txt+= "<p>Browser Name: " + navigator.appName + "</p>";
txt+= "<p>Browser Version: " + navigator.appVersion + "</p>";
txt+= "<p>Cookies Enabled: " + navigator.cookieEnabled + "</p>";
txt+= "<p>Platform: " + navigator.platform + "</p>";
txt+= "<p>User-agent header: " + navigator.userAgent + "</p>";
alert(txt);
*/
if(navigator.userAgent.indexOf('Android') === -1)
alert(toast);
else
Android.showToast(toast);
}

BIN
css/bg-nav.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

201
css/common.css Normal file
View File

@ -0,0 +1,201 @@
@charset "UTF-8";
/* CSS Document */
/*
* RESET
*
*/
body {
font-family: Helvetica,Arial,sans-serif;
}
/*
html, body, div, span, object, blockquote, pre,
abbr, acronym, address, big, cite, code, dfn, em, font, img, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center, dl, dt, dd, fieldset, form, label, legend,
caption, tr, th, td {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font-weight: normal;
vertical-align: baseline;
background: transparent;
font-family: Helvetica,Arial,sans-serif;
}
*/
p {
border: 0;
font-size: 100%;
font-weight: normal;
vertical-align: baseline;
background: transparent;
}
a {
margin: 0;
padding: 0;
font-weight: normal;
}
/* added styles not in Nokia template */
.floatleft {
float: left;
opacity:0.8;
}
.hdrcontainer {
background-color: #0038E1;
color: #FFFFFF;
border-bottom: 1px solid #D8D8D8;
border-top: 1px solid #D8D8D8;
font-size: 22px;
line-height:30px;
}
.hdrtxt {
padding:10px;
display:inline;
}
.floatright {
float: right;
opacity:0.8;
}
.hilite {
background-color: #95CBE9;
color: black;
font-size: 18px;
font-weight: bold;
}
.app_logo {
padding-left: 30px;
padding-right: 0px;
}
.header_table {
background-color: blue;
height: 26px;
width: 100%;
padding: 0px;
margin-bottom: 6px;
}
.header_table tr {
height: 24px;
width:98%;
}
.header_left_img {
width:24px;
padding:2px;
vertical-align: middle;
}
.header_txt {
color: white;
font-size: 16px;
margin: 0 0 0 0;
text-align: center;
vertical-align: center;
}
.header_right_img {
width:24px;
}
.header_search {
text-align: right;
}
.header_background {
/* background-image:url('../img/header_background.png'); */
}
.app_logo {
width: 43px;
}
.tbl_color {
color: black;
font-size:14px;
line-height:20px;
width:100%;
}
.tbl_color th {
background-color:#DAAF85;
color:black;
font-size:16px;
font-weight:bold;
text-align:left;
}
.tbl_color tr:nth-of-type(odd) {
background-color: #F0DDD5;
color:black;
width:100%
}
.tbl_color tr:nth-of-type(even) {
background-color: #EEEECE;
width:100%
}
.bar_color {
background-color: #D5E1DD;
color:black;
font-size:16px;
font-weight:bold;
text-align:center;
}
body h6 {
background-color: #F6F6F6;
border-bottom: 1px solid #D8D8D8;
border-top: 1px solid #D8D8D8;
font-size: 16px;
padding-left: 2%;
padding-right: 2%;
padding-top: .3em;
padding-bottom: .3em;
margin-top: 0;
margin-bottom: 0.6em;
text-align: center;
}
.ttl {
/*
background-color: #F6F6F6;
border-bottom: 1px solid #D8D8D8;
border-top: 1px solid #D8D8D8;
*/
padding-left: 2%;
padding-right: 2%;
padding-top: .3em;
padding-bottom: .3em;
margin-top: 14px;
margin-bottom: 0.6em;
margin-left: 2%;
font-size: 16px;
line-height: 40px;
/* float: left;
text-align: left;
*/
}
.spacer {
font-size: 2px;
}
.alignBottom{vertical-align: bottom;}
.leftItem {
clear: both;
float: left;
}
.rightItem {
float: right;
}

546
css/desktop.css Normal file
View File

@ -0,0 +1,546 @@
@charset "UTF-8";
/* CSS Document */
/*
* RESET
*
*/
html, body, div, span, object, blockquote, pre,
abbr, acronym, address, big, cite, code, dfn, em, font, img, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center, dl, dt, dd, fieldset, form, label, legend,
caption, tr, th, td {
margin: 0;
padding: 0;
border: 0;
/* font-size: 100%; */
font-weight: normal;
vertical-align: baseline;
background: transparent;
}
p {
border: 0;
font-size: 100%;
font-weight: normal;
vertical-align: baseline;
background: transparent;
}
a {
margin: 0;
padding: 0;
font-weight: normal;
}
h1, h2, h3, h4, h5, h6 {
margin: 0;
padding: 0;
border: 0;
vertical-align: baseline;
background: transparent;
}
body table {
margin: 0;
padding: 0;
font-size: 100%;
font-weight: normal;
vertical-align: baseline;
background: transparent;
border-collapse: collapse;
border-spacing: 0;
}
/*
* DEFAULT STYLES
*
*/
body {
color: #333333;
font-weight: normal;
font-family: sans-serif;
}
/*removes horizontal overflow on certain devices*/
body div#wrap {
width: 100%;
overflow: hidden;
position: absolute;
left: 0;
padding: 0;
}
/*
* HEADER
*
*/
body div#header {
height: 2.5em;
background-color: #D8D8D8;
border-bottom: 4px solid #44AA33;
margin-bottom: .5em;
}
/*
* FOOTER
*
*/
body div#footer {
background-color: #F6F6F6;
border-top: 1px solid #D8D8D8;
padding: .7em 0em;
clear: both;
height: 5em;
display: block;
}
body div#footer ul {
margin-left: 2em;
padding-left: 0;
margin-bottom: 0;
margin-top: 0;
}
body div#footer ul li {
margin-left: 0;
padding-left: 0;
}
body div#footer p {
margin-left: 2%;
margin-top: .3em;
padding: 0;
}
/*
* BASIC ELEMENTS
*
*/
/*body required as early browsers don't understand p by itself */
body p {
margin-top: 0;
margin-bottom: 0.6em;
padding: 0 2% 0 2%;
font-size: 100%;
}
strong {
font-weight: bold;
}
em {
font-style: normal;
font-weight: bold;
}
/*
* LINK STATES
*
*/
a:link {
color:#003399;
}
a:visited {
color:#006600;
}
a:hover {
color:#FF9900;
}
a:active {
color:#990000;
}
/*
* HEADERS
*
*/
body h1 {
padding-left: 2%;
padding-right: 2%;
margin-top: 0;
margin-bottom: 0.4em;
line-height: normal;
clear: both;
}
body h2 {
padding-left: 2%;
padding-right: 2%;
color: white;
background-color: #44AA33;
border-top: 1px solid #67DD30;
border-bottom: 2px solid #378C29;
margin-top: 0;
margin-bottom: 0.4em;
line-height: normal;
clear: both;
}
body h3 {
padding-left: 2%;
padding-right: 2%;
background-color: #0038E1;
color: #FFFFFF;
margin-top: 0;
margin-bottom: 0.4em;
border-top: 1px solid #0081CA;
border-bottom: 2px solid #000C30;
}
body h4 {
padding-left: 2%;
padding-right: 2%;
color: #CC0066;
margin-top: 0;
margin-bottom: 0.4em;
font-weight: bold;
}
body h5 {
padding-left: 2%;
padding-right: 2%;
color: #333333;
margin-top: 0;
margin-bottom: 0.4em;
}
body h6 {
background-color: #F6F6F6;
border-bottom: 1px solid #D8D8D8;
border-top: 1px solid #D8D8D8;
font-size: 18px;
padding-left: 2%;
padding-right: 2%;
padding-top: .3em;
padding-bottom: .3em;
margin-top: 0;
margin-bottom: 0.6em;
text-align: center;
}
/*
* IMAGE WITH OPTIONAL CAPTION
*
*/
body img.captioned {
margin: 0 0 0 2%;
}
body p.caption-image {
font-size: small;
margin-top: 0;
margin-bottom: 0.6em;
padding-left: 2%;
}
/*
* BLOCKQUOTE
*
*/
blockquote {
margin: 0 4% 0.4em 4%;
padding: .6em 0 .3em 0;
border-top: 1px solid #D8D8D8;
border-bottom: 1px solid #D8D8D8;
}
blockquote p {
margin: .0;
padding: 0 0 0.6em 0;
border-bottom: 1px solid #D8D8D8;
}
/*
* LISTS
*
*/
/* compensates for smaller Opera Mini margins */
ol, ul, dl {
margin-left: 2%;
}
dd {
margin-left: 2%;
}
/*forces native margin*/
body ul, body ol, body dl {
margin-top: 0;
margin-bottom: 0.6em;
font-size: 100%;
}
/*
* BREADCRUMBS
*
*/
body ul.breadcrumbs {
padding-top: 0;
padding-bottom: .5em;
padding-left: 0;
padding-right: .5em;
font-size: small;
list-style-type: none;
margin-bottom: 0.6em;
margin-top: 0;
margin-left: 2%;
}
body ul.breadcrumbs li {
display: inline;
line-height: 1em;
}
/*
* FORMS
*
*/
body fieldset {
margin: 0;
padding: 0;
border: none;
}
body form {
margin: 0;
color: #333333;
}
body form label {
font-size: medium;
margin-bottom: .5em;
margin-top: .5em;
}
body input[type='text'] {
padding: 0.2em;
margin-bottom: .5em;
display: block;
}
body textarea {
padding: 0.2em;
margin-bottom: .7em;
display: block;
}
body form input[type='radio'], body form input[type='checkbox'] {
margin:0.1em 0em;
padding: 0;
}
body select {
margin-bottom: 0;
}
body input[type='button'] {
padding: 1em 1.3em;
color: #D8D8D8;
margin: 1em 0em;
}
/*
* TABLES
*
*/
body table {
border: 1px solid #D8D8D8;
margin: 0;
width: 100%;
color: #333333;
font-size: 80%;
}
body td {
padding-left: .3em;
padding-right: .3em;
padding-top: .2em;
padding-bottom: .2em;
line-height: 1.5em;
border: 1px solid #D8D8D8;
}
/*compensates for lack of consistent header support*/
body td.table-header {
color: #0033CC;
font-weight: bold;
background-color: #F6F6F6;
}
body tr {
height: 1.5em;
}
body table td.odd {
background-color: #F6F6F6;
}
/*caption-side unlikely to be supported*/
body caption {
caption-side: bottom;
padding-top: 0.3em;
padding-bottom: 0.3em;
margin-left: .5em;
font-size: small;
text-align: left;
font-style: normal;
}
/*
* CONTAINER BOXES
*
*/
body div.box p.box-text {
border: 1px solid #D8D8D8;
width: 90%;
margin: 0 auto 0.6em auto;
padding: 0.4em 0.4em;
background-color: #F6F6F6;
}
body div.header-box p {
border: 1px solid #D8D8D8;
width: 90%;
margin: 0 auto 0.6em auto;
padding: 0.4em 0.4em;
background-color: #F6F6F6;
}
/* 2px border is required to ensure header is flush with the box */
body div.header-box h3 {
border: 2px solid #0038E1;
width: 90%;
margin: 0em auto;
padding: 0.3em 0.3em;
background-color: #0038E1;
color: white;
}
/*
* BACK TO TOP/HOME
*
*/
p.top {
font-size: small;
background-color: #F6F6F6;
border-bottom: 1px solid #D8D8D8;
border-top: 1px solid #D8D8D8;
padding-top: .3em;
padding-bottom: .3em;
margin-top: 0;
margin-bottom: 0.6em;
clear: both;
}
p.home {
font-size: small;
background-color: #F6F6F6;
border-bottom: 1px solid #D8D8D8;
border-top: 1px solid #D8D8D8;
padding-top: .3em;
padding-bottom: .3em;
margin-top: 0;
margin-bottom: 0.6em;
clear: both;
}
p.top a, p.home a {
color: #333333;
text-decoration: none;
width: 100%;
display: block;
}
/* added styles not in Nokia template */
.floatleft {
float: left;
opacity:0.8;
}
.hdrcontainer {
background-color: #0038E1;
color: #FFFFFF;
border-bottom: 1px solid #D8D8D8;
border-top: 1px solid #D8D8D8;
font-size: 22px;
line-height:30px;
}
.hdrtxt {
padding:10px;
display:inline;
}
.floatright {
float: right;
opacity:0.8;
}
.hilite {
background-color: #95CBE9;
color: black;
font-size: 16px;
font-weight: bold;
}
.app_logo {
padding-left: 30px;
padding-right: 0px;
}
.header_table {
background-color: blue;
height: 26px;
width: 100%;
padding: 0px;
margin-bottom: 6px;
}
.header_table tr {
height: 24px;
width:98%;
}
.header_left_img {
width:24px;
padding:2px;
vertical-align: middle;
}
.header_txt {
color: white;
font-size: 16px;
margin: 0 0 0 0;
text-align: center;
vertical-align: center;
}
.header_right_img {
width:24px;
}
.header_search {
text-align: right;
}
.header_background {
/* background-image:url('../img/header_background.png'); */
}
.app_logo {
width: 43px;
}
/*
.tbl_color {
color: black;
font-size:16px;
width:100%;
}
.tbl_color th {
background-color:#DAAF85;
color:black;
font-size:16px;
font-weight:bold;
text-align:left;
}
.tbl_color tr:nth-of-type(odd) {
background-color: #F0DDD5;
color:black;
font-size:14px;
}
.tbl_color tr:nth-of-type(even) {
background-color: #EEEECE;
font-size:14px;
}
*/
.bar_color {
background-color: #D5E1DD;
color:black;
font-size:16px;
font-weight:bold;
text-align:center;
}

23
css/findbus.css Normal file
View File

@ -0,0 +1,23 @@
#wrapper {
background-color: #0038E1;
color: #FFFFFF;
border-bottom: 1px solid #D8D8D8;
border-top: 1px solid #D8D8D8;
font-size: 22px;
}
#home {
float:left;
margin:0px;
}
#clearFld {
float:right;
margin:0px;
}
#help {
float:right;
margin:10px;
}
#hdr {
align:center;
}

545
css/mobile.css Normal file
View File

@ -0,0 +1,545 @@
@charset "UTF-8";
/* CSS Document */
/*
* RESET
*
*/
html, body, div, span, object, blockquote, pre,
abbr, acronym, address, big, cite, code, dfn, em, font, img, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center, dl, dt, dd, fieldset, form, label, legend,
caption, tr, th, td {
margin: 0;
padding: 0;
border: 0;
/* font-size: 100%; */
font-weight: normal;
vertical-align: baseline;
background: transparent;
}
p {
border: 0;
font-size: 100%;
font-weight: normal;
vertical-align: baseline;
background: transparent;
}
a {
margin: 0;
padding: 0;
font-weight: normal;
}
h1, h2, h3, h4, h5, h6 {
margin: 0;
padding: 0;
border: 0;
vertical-align: baseline;
background: transparent;
}
body table {
margin: 0;
padding: 0;
font-size: 100%;
font-weight: normal;
vertical-align: baseline;
background: transparent;
border-collapse: collapse;
border-spacing: 0;
}
/*
* DEFAULT STYLES
*
*/
body {
color: #333333;
font-weight: normal;
font-family: sans-serif;
}
/*removes horizontal overflow on certain devices*/
body div#wrap {
width: 100%;
overflow: hidden;
position: absolute;
left: 0;
padding: 0;
}
/*
* HEADER
*
*/
body div#header {
height: 2.5em;
background-color: #D8D8D8;
border-bottom: 4px solid #44AA33;
margin-bottom: .5em;
}
/*
* FOOTER
*
*/
body div#footer {
background-color: #F6F6F6;
border-top: 1px solid #D8D8D8;
padding: .7em 0em;
clear: both;
height: 5em;
display: block;
}
body div#footer ul {
margin-left: 2em;
padding-left: 0;
margin-bottom: 0;
margin-top: 0;
}
body div#footer ul li {
margin-left: 0;
padding-left: 0;
}
body div#footer p {
margin-left: 2%;
margin-top: .3em;
padding: 0;
}
/*
* BASIC ELEMENTS
*
*/
/*body required as early browsers don't understand p by itself */
body p {
margin-top: 0;
margin-bottom: 0.6em;
padding: 0 2% 0 2%;
font-size: 100%;
}
strong {
font-weight: bold;
}
em {
font-style: normal;
font-weight: bold;
}
/*
* LINK STATES
*
*/
a:link {
color:#003399;
}
a:visited {
color:#006600;
}
a:hover {
color:#FF9900;
}
a:active {
color:#990000;
}
/*
* HEADERS
*
*/
body h1 {
padding-left: 2%;
padding-right: 2%;
margin-top: 0;
margin-bottom: 0.4em;
line-height: normal;
clear: both;
}
body h2 {
padding-left: 2%;
padding-right: 2%;
color: white;
background-color: #44AA33;
border-top: 1px solid #67DD30;
border-bottom: 2px solid #378C29;
margin-top: 0;
margin-bottom: 0.4em;
line-height: normal;
clear: both;
}
body h3 {
padding-left: 2%;
padding-right: 2%;
background-color: #0038E1;
color: #FFFFFF;
margin-top: 0;
margin-bottom: 0.4em;
border-top: 1px solid #0081CA;
border-bottom: 2px solid #000C30;
}
body h4 {
padding-left: 2%;
padding-right: 2%;
color: #CC0066;
margin-top: 0;
margin-bottom: 0.4em;
font-weight: bold;
}
body h5 {
padding-left: 2%;
padding-right: 2%;
color: #333333;
margin-top: 0;
margin-bottom: 0.4em;
}
body h6 {
background-color: #F6F6F6;
border-bottom: 1px solid #D8D8D8;
border-top: 1px solid #D8D8D8;
font-size: 18px;
padding-left: 2%;
padding-right: 2%;
padding-top: .3em;
padding-bottom: .3em;
margin-top: 0;
margin-bottom: 0.6em;
text-align: center;
}
/*
* IMAGE WITH OPTIONAL CAPTION
*
*/
body img.captioned {
margin: 0 0 0 2%;
}
body p.caption-image {
font-size: small;
margin-top: 0;
margin-bottom: 0.6em;
padding-left: 2%;
}
/*
* BLOCKQUOTE
*
*/
blockquote {
margin: 0 4% 0.4em 4%;
padding: .6em 0 .3em 0;
border-top: 1px solid #D8D8D8;
border-bottom: 1px solid #D8D8D8;
}
blockquote p {
margin: .0;
padding: 0 0 0.6em 0;
border-bottom: 1px solid #D8D8D8;
}
/*
* LISTS
*
*/
/* compensates for smaller Opera Mini margins */
ol, ul, dl {
margin-left: 2%;
}
dd {
margin-left: 2%;
}
/*forces native margin*/
body ul, body ol, body dl {
margin-top: 0;
margin-bottom: 0.6em;
font-size: 100%;
}
/*
* BREADCRUMBS
*
*/
body ul.breadcrumbs {
padding-top: 0;
padding-bottom: .5em;
padding-left: 0;
padding-right: .5em;
font-size: small;
list-style-type: none;
margin-bottom: 0.6em;
margin-top: 0;
margin-left: 2%;
}
body ul.breadcrumbs li {
display: inline;
line-height: 1em;
}
/*
* FORMS
*
*/
body fieldset {
margin: 0;
padding: 0;
border: none;
}
body form {
margin: 0;
color: #333333;
}
body form label {
font-size: medium;
margin-bottom: .5em;
margin-top: .5em;
}
body input[type='text'] {
padding: 0.2em;
margin-bottom: .5em;
display: block;
}
body textarea {
padding: 0.2em;
margin-bottom: .7em;
display: block;
}
body form input[type='radio'], body form input[type='checkbox'] {
margin:0.1em 0em;
padding: 0;
}
body select {
margin-bottom: 0;
}
body input[type='button'] {
padding: 1em 1.3em;
color: #D8D8D8;
margin: 1em 0em;
}
/*
* TABLES
*
*/
body table {
border: 1px solid #D8D8D8;
margin: 0;
width: 100%;
color: #333333;
font-size: 80%;
}
body td {
padding-left: .3em;
padding-right: .3em;
padding-top: .2em;
padding-bottom: .2em;
line-height: 1.5em;
border: 1px solid #D8D8D8;
}
/*compensates for lack of consistent header support*/
body td.table-header {
color: #0033CC;
font-weight: bold;
background-color: #F6F6F6;
}
body tr {
height: 1.5em;
}
body table td.odd {
background-color: #F6F6F6;
}
/*caption-side unlikely to be supported*/
body caption {
caption-side: bottom;
padding-top: 0.3em;
padding-bottom: 0.3em;
margin-left: .5em;
font-size: small;
text-align: left;
font-style: normal;
}
/*
* CONTAINER BOXES
*
*/
body div.box p.box-text {
border: 1px solid #D8D8D8;
width: 90%;
margin: 0 auto 0.6em auto;
padding: 0.4em 0.4em;
background-color: #F6F6F6;
}
body div.header-box p {
border: 1px solid #D8D8D8;
width: 90%;
margin: 0 auto 0.6em auto;
padding: 0.4em 0.4em;
background-color: #F6F6F6;
}
/* 2px border is required to ensure header is flush with the box */
body div.header-box h3 {
border: 2px solid #0038E1;
width: 90%;
margin: 0em auto;
padding: 0.3em 0.3em;
background-color: #0038E1;
color: white;
}
/*
* BACK TO TOP/HOME
*
*/
p.top {
font-size: small;
background-color: #F6F6F6;
border-bottom: 1px solid #D8D8D8;
border-top: 1px solid #D8D8D8;
padding-top: .3em;
padding-bottom: .3em;
margin-top: 0;
margin-bottom: 0.6em;
clear: both;
}
p.home {
font-size: small;
background-color: #F6F6F6;
border-bottom: 1px solid #D8D8D8;
border-top: 1px solid #D8D8D8;
padding-top: .3em;
padding-bottom: .3em;
margin-top: 0;
margin-bottom: 0.6em;
clear: both;
}
p.top a, p.home a {
color: #333333;
text-decoration: none;
width: 100%;
display: block;
}
/* added styles not in Nokia template */
.floatleft {
float: left;
opacity:0.8;
}
.hdrcontainer {
background-color: #0038E1;
color: #FFFFFF;
border-bottom: 1px solid #D8D8D8;
border-top: 1px solid #D8D8D8;
font-size: 22px;
line-height:30px;
}
.hdrtxt {
padding:10px;
display:inline;
}
.floatright {
float: right;
opacity:0.8;
}
.hilite {
background-color: #95CBE9;
color: black;
font-size: 16px;
font-weight: bold;
}
.app_logo {
padding-left: 30px;
padding-right: 0px;
}
.header_table {
background-color: blue;
height: 26px;
width: 100%;
padding: 0px;
margin-bottom: 6px;
}
.header_table tr {
height: 24px;
width:98%;
}
.header_left_img {
width:24px;
padding:2px;
vertical-align: middle;
}
.header_txt {
color: white;
font-size: 16px;
margin: 0 0 0 0;
text-align: center;
vertical-align: center;
}
.header_right_img {
width:24px;
}
.header_search {
text-align: right;
}
.header_background {
/* background-image:url('../img/header_background.png'); */
}
.app_logo {
width: 43px;
}
.tbl_color {
color: black;
font-size:16px;
width:100%;
}
.tbl_color th {
background-color:#DAAF85;
color:black;
font-size:16px;
font-weight:bold;
text-align:left;
}
.tbl_color tr:nth-of-type(odd) {
background-color: #F0DDD5;
color:black;
font-size:14px;
}
.tbl_color tr:nth-of-type(even) {
background-color: #EEEECE;
font-size:14px;
}
.bar_color {
background-color: #D5E1DD;
color:black;
font-size:16px;
font-weight:bold;
text-align:center;
}

70
css/showstops.css Normal file
View File

@ -0,0 +1,70 @@
#stops {
color: black;
font-size:18px;
width:100%;
}
#stops th {
background-color:#DAAF85;
color:black;
font-size: 18px;
font-weight:bold;
text-align:left;
}
#stops tr:nth-of-type(odd) {
background-color: #F0DDD5;
color:black;
}
#stops tr:nth-of-type(even) {
background-color: #EEEECE;
}
#myLoc {
background-color: #DE9D7F;
color: black;
display: block;
font-size: 18px;
font-weight:bold;
text-align:left;
}
#before {
/* background-color:#ffff00; */
background-color:#C0C0C0;
color:black;
display:block;'
font-size: 18px;
text-align:center;
}
#past {
background-color:#ffff00;
color:red;
display:block;
font-size: 18px;
}
#at {
background-color:#ffff00;
color:red;
display:block;
font-size: 18px;
}
#neardest {
background-color:#ffff00;
}
#journey {
background-color:#EFD9DC;
display:block;
font-family:'Helvetica';
}

BIN
css/tab-right.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

59
css/tab.css Normal file
View File

@ -0,0 +1,59 @@
#navigation {
background: #AFD5E0 url("bg-nav.gif") repeat-x;
border: 1px solid #979797;
border-width: 1px 0;
font-size: 1.1em;
margin-top: 1em;
padding-top: .6em;
}
#navigation ul, #navigation ul li {
list-style: none;
margin: 0;
padding: 0;
}
#navigation ul {
padding: 5px 0;
text-align: center;
}
#navigation ul li {
display: inline;
margin-right: .75em;
}
#navigation ul li.last {
margin-right: 0;
}
#navigation ul li a {
background: url("tab-right.gif") no-repeat 100% 0;
color: #06C;
padding: 5px 0;
text-decoration: none;
}
#navigation ul li a span {
background: url("tab-left.gif") no-repeat;
padding: 5px 1em;
}
#navigation ul li a:hover span {
color: #69C;
text-decoration: underline;
}
/*\*//*/
#navigation ul li a {
display: inline-block;
white-space: nowrap;
width: 1px;
}
#navigation ul {
padding-bottom: 0;
margin-bottom: -1px;
}
/**/
//

BIN
default.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

BIN
favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

BIN
images/bestbus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
images/bestlogo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

BIN
images/black.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 800 B

BIN
images/blue.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 800 B

BIN
images/bus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B

BIN
images/home24.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 B

BIN
images/loading.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
images/px24bestbus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
images/px24help.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
images/px24map.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
images/px24startend.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 819 B

BIN
images/px30cross.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 926 B

BIN
images/px30help.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
images/px48cross.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
images/px48help.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
images/walk14x27.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 695 B

125
index.html Normal file
View File

@ -0,0 +1,125 @@
<!DOCTYPE html>
<!-- <html manifest="manifest.php"> -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Mumbai Best Bus - Find a Bus (B.E.S.T)</title>
<meta name="viewport" content="user-scalable=no, width=device-width">
<link rel="stylesheet" type="text/css" href="./css/common.css">
<!-- <link rel="stylesheet" type="text/css" href="./css/tab.css"> -->
<link rel="stylesheet" type="text/css" href="./lib/jquery/jquery.ui.custom.css">
<link rel="stylesheet" type="text/css" href="./lib/jquery/jquery.mobile.min.css">
<script type="text/javascript" src="./lib/jquery/jquery.min.js"></script>
<script type="text/javascript" src="init.js"></script>
<script type="text/javascript" src="./lib/jquery/jquery.ui.custom.min.js"></script>
<script type="text/javascript" src="./lib/jquery/jquery.mobile.min.js"></script>
<script type="text/javascript" src="libfns.js"></script>
<script type="text/javascript" src="cf.js"></script>
<script type="text/javascript" src="./init/buslist.js"></script>
<script type="text/javascript" src="./init/stopnames.min.js"></script>
<script type="text/javascript" src="./init/busmaster.js"></script>
<script type="text/javascript" src="./init/stopbus.min.js"></script>
<script type="text/javascript" src="busroute.js"></script>
<script type="text/javascript" src="index.js"></script>
</head>
<body>
<div data-role="page" data-theme="a">
<div data-role="header" data-theme="a">
<div data-role="navbar">
<!-- <div id="navigation"> -->
<ul>
<li><a href="index.html" rel="external" class="ui-btn-active">Find</a></li>
<li><a href="busesfound.html" rel="external">Routes</a></li>
<!-- <li><a href="busroute.html" rel="external">Routes</a></li> -->
<li><a href="journey.html" rel="external">Journey</a></li>
</ul>
</div><!-- /navbar -->
</div> <!-- /header -->
<div data-role="content" data-theme="b">
<form name="myForm" action="" onsubmit="validateFindBusForm(); return false;" >
<div id="findInput" class="text_entry" data-theme="d">
<div><input id="startStop" name="startStop" class="ac_input" autocomplete="off"
placeholder="Start: eg. Hanuman Road" type="text" data-theme="d"></div>
<div><input id="destStop" name="destStop" class="ac_input" autocomplete="off"
placeholder="Destination: eg. Churchgate Station" type="text" data-theme="d"></div>
</div>
<a href="javascript:void(0)" onclick="clearInput();"
data-role="button" data-inline="true">Clear</a>
<a href="javascript:void(0)" name="fndBusBtn" id="fndBusBtn"
style="float:right;"
onclick="validateFindBusForm();" type="text" data-role="button"
data-theme="b" data-inline="true">Find Bus</a>
</form>
<div style='width:98%;line-height:8px;' data-role="collapsible" data-theme="a" >
<h5><span id='stopsnearyou' >Nearby Stops </span></h5>
<div id="myLoc" class="tbl_color">No location fix as yet</div>
</div> <!-- /collapsible -->
<div style='width:98%;line-height:16px;' data-role="collapsible" data-theme="a">
<h5><span id='busroutesatstart'>Buses at </span></h5>
<div id="routesAtStop" class="tbl_color"></div>
<form name="routeForm" action="" onsubmit="showRouteComplete(); return false;">
<div class="ui-grid-a">
<div class="ui-block-a">
<input type="text" style="width:45%;"
id="busNo" name="busNo" placeholder="Bus No."
data-theme="d" data-inline="true"/>
</div>
<div class="ui-block-b">
<a href="javascript:void(0)" name="showRouteBtn" id="showRouteBtn"
style="float:right;"
onclick="showR();" type="text" data-role="button"
data-theme="b" data-inline="true">Show Route</a>
</div>
</div><!-- /grid-a -->
<div><select name="busNoCombo" data-role='none' id="busNoCombo" style="width:98%;" onChange='showRoute(this.options[this.selectedIndex].value);'>
<option value="" selected="selected">All Buses</option></select></div>
<div><select name="oBus" data-role='none' id="oBus" onChange='showRoute(this.options[this.selectedIndex].value);'>
<option value="" selected="selected">Ordinary Buses</option></select></div>
<div><select name="lBus" data-role='none' id="lBus" onChange='showRoute(this.options[this.selectedIndex].value);'>
<option value="" selected="selected">Limited Buses (L)</option></select></div>
<div><select name="asBus" data-role='none' id="asBus" onChange='showRoute(this.options[this.selectedIndex].value);'>
<option value="" selected="selected">A/C Buses (AS)</option></select></div>
<div><select name="aBus" data-role='none' id="aBus" onChange='showRoute(this.options[this.selectedIndex].value);'>
<option value="" selected="selected">A/C Express Buses (A)</option></select></div>
<div><select name="cBus" data-role='none' id="cBus" onChange='showRoute(this.options[this.selectedIndex].value);'>
<option value="" selected="selected">Corridor Buses (C)</option></select></div>
<div>
<input data-role='none' type="radio" id='ALL' name="group1" value="ALL" CHECKED onClick='activateList("ALL");' > All
<input data-role='none' type="radio" id='O' name="group1" value="O" onClick='activateList("O");'> Ordin.
<input data-role='none' type="radio" name="group1" value="L" onClick='activateList("L");' > Ltd.
<input data-role='none' type="radio" name="group1" value="AS" onClick='activateList("AS");'> AC (AS)
<input data-role='none' type="radio" name="group1" value="A" onClick='activateList("A");'>AC Exp.
<input data-role='none' type="radio" name="group1" value="C" onClick='activateList("C");'>Cor.
</div>
</form>
</div> <!-- /collapsible -->
<div style='width:98%;line-height:8px;' data-role="collapsible" data-theme="a">
<h5><span id="font-size:14px;">Recent Stops</h5>
<div id="recentStops" class="tbl_color"></div>
</div> <!-- /collapsible -->
<div class="ui-grid-a">
<div class="ui-block-a">
</div>
<div class="ui-block-b">
<a rel='external' href="javascript:showStatus()" name="busStatus" id="busStatus"
style="float:right;"
type="text" data-role="button"
data-theme="b" data-inline="true">Status</a>
</div>
</div>
</div> <!-- /content -->
</div> <!-- /page -->
</body>
</html>

414
index.js Normal file
View File

@ -0,0 +1,414 @@
/*
/*
var getStopNames, getCookie, setCookie, getWinDim, getLocation,
updateDestInfo, BrowserLevel, findNearestStop, updateStartInfo, goLinkBusesFound, findStop,
getCombo, setGeoPos, distanceLatLon, window;
*/
var firstLoad = true;
var arStopNames, arBusMaster, arBusList, arStopBus;
var gStartStop, gDestStop;
var gaoNearStops = null; //Array of near stop objects
var goNearestStop = null;
var MAXRECENTSTOPS = 7;
var selectedInput = 1;
var goCurStop = {'id':''};
$(document).ready(function () {
arStopNames = getStopNames();
arBusMaster = getbusmaster();
arBusList = getbuslist();
arStopBus = getStopBusList();
scrollTo(0, 0);
getLocation(); // runs setGeoPos(pos), showLocation(pos)
PopulateAllBusList();
PopulateOtherBusLists();
activateList('ALL');
initStops();
showRecentStops();
// $("#startStop").focus();
document.getElementById('busNoCombo').checked = true;
$("#startStop").autocomplete({
source: function(req, response) {
var re = $.ui.autocomplete.escapeRegex(req.term);
re = re.toLowerCase();
stopid = re.replace(/[^a-zA-Z0-9]+/g,'');
var len = stopid.length;
var i = 0;
matchArr = [];
for(var j=0; j<stopNames.length; j++) {
if(stopid == stopNames[j][0].toLowerCase().substring(0, len)) {
matchArr[i] = createOStop(stopNames[j]);
i = i + 1;
}
}
if(!matchArr.length) { // No matching areas found, look for stops
for(var j=0; j<stopNames.length; j++) {
if(stopNames[j][3].indexOf(stopid) >= 0) {
matchArr[i] = createOStop(stopNames[j]);
i = i + 1;
}
}
}
response(matchArr);
},
minLength: 2,
select: function(event, ui) {
$('#startStop').val(ui.item.value);
setStart(ui.item);
$('#destStop').focus();
} /* ,
focus: function(event, ui) {
$('#startStop').autocomplete("close").val(ui.item.value)
}
*/
// $('#abbrev').val(ui.item.abbrev);
});
$('#startStop').focus(function() {
selectedInput = 1;
});
$('#destStop').autocomplete({
source: function(req, response) {
var re = $.ui.autocomplete.escapeRegex(req.term);
re = re.toLowerCase();
stopid = re.replace(/[^a-zA-Z0-9]+/g,'');
var len = stopid.length;
var i = 0;
matchArr = [];
for(var j=0; j<stopNames.length; j++) {
if(stopid == stopNames[j][0].toLowerCase().substring(0, len)) {
matchArr[i] = createOStop(stopNames[j]);
// {'id':stopNames[j][3], 'label':stopNames[j][0] + ': ' + stopNames[j][1] + ' ' + stopNames[j][2],
// 'area':stopNames[j][0], 'value':stopNames[j][1], 'stopname':stopNames[j][2]};
i = i + 1;
}
}
if(!matchArr.length) { // No matching areas found, look for stops
for(var j=0; j<stopNames.length; j++) {
if(stopNames[j][3].indexOf(stopid) >= 0) {
matchArr[i] = createOStop(stopNames[j]);
// {'id':stopNames[j][3], 'label':stopNames[j][0] + ': ' + stopNames[j][1] + ' ' + stopNames[j][2],
// 'area':stopNames[j][0], 'value':stopNames[j][1], 'stopname':stopNames[j][2]};
i = i + 1;
}
}
}
response(matchArr);
// response($.grep(stopNames, function(item){return matcher.test(item[0]); }) );
},
minLength: 2,
select: function(event, ui) {
$('#destStopId').val(ui.item.id);
setCookie('cDestStop', ui.item.value, 1);
setCookie('cDestStopNameId', ui.item.id, 1);
// addRecentStop(ui.item.value);
setDest(ui.item);
$('#fndBusBtn').focus();
} /*,
focus: function(event, ui) {
$('#destStop').autocomplete("close").val(ui.item.value)
}
*/
});
$('#destStop').focus(function() {
selectedInput = 2;
});
});
// set the local variable so it can be used in this js file
function setGeoPos(pos) {
geoPos = pos;
}
function showLocation(pos) { // Stops near you
if(typeof(document.getElementById("myLoc")) === 'undefined')
return; // dom not loaded as yet
var aoNearStops = [];
var oNearestStop, contentString, x, oNearStop, elm;
aoNearStops = findNearStops(pos);
contentString = '<table id="myLoc" class="tbl_color">';
if (aoNearStops !== null) {
for (x = 0; x < aoNearStops.length; x += 1) {
oNearStop = aoNearStops[x];
if(x === 0) { // Nearest stop and area
goNearestStop = oNearStop;
document.getElementById('stopsnearyou').innerHTML = 'Nearby Stops (' + oNearStop.area + ')';
setStart(oNearStop);
}
elm = '<tr><td><a href="javascript:popStop({\'di\':' + x + ',\'id\':\'' +
oNearStop.id + '\', \'area\': \'' + oNearStop.area +
'\', \'stopname\': \'' + oNearStop.stopname + '\', \'landmark\': \'' +
oNearStop.landmark + '\', \'stopnameext\': \'' + oNearStop.stopnameext + '\'}, 1)">' +
oNearStop.stopname + "</td><td>" + oNearStop.di + "&nbsp;m" + "</a></td></tr>";
contentString = contentString + elm;
if (x >= 2) {// Show 2 nearest stops
break; }
}
} else {
contentString = contentString + '<tr><td>' + 'No stops near you found' + '</td></tr>'; }
if(firstLoad) {
if(goNearestStop !== null) {
$("#startStop").val(goNearestStop.stopname);
showRoutesAtStop(goNearestStop, 'Buses at ' + goNearestStop.stopname + ' ');
$('#destStop').focus();
firstLoad = false;
}
}
contentString = contentString + '</tbody></table>';
document.getElementById("myLoc").innerHTML = contentString;
setCookie('cMyLat', pos.coords.latitude, 1);
setCookie('cMyLon', pos.coords.longitude, 1);
}
function setStart(oStop) {
gStartStop = oStop;
localStorage['startStop']=JSON.stringify(gStartStop);
setCookie('cStartStop', oStop.stopname, 1);
setCookie('cStartStopNameId', oStop.id, 1);
addRecentStop(oStop);
showRoutesAtStop(oStop, 'Buses at ' + oStop.stopname + ' ');
}
// Add to the list of recent stops
function addRecentStop(oStop) {
if(oStop.id === goCurStop.id) // stop hasn't changed
return;
oCurStop = oStop;
var rs = localStorage['recentStops'];
var recentStopsPrv;
if(rs != null)
recentStopsPrv = JSON.parse(rs);
recentStops = null;
var recentStops = new Array;
recentStops[0] = oStop;
var alreadyThere = false;
if(recentStopsPrv !== null && recentStopsPrv != undefined) {
for(var i = 0; i < recentStopsPrv.length; i++) {
if(recentStopsPrv[i] === undefined || recentStopsPrv[i] === null)
continue;
// check if already in array, else add
alreadyThere = false;
for(var j = 0; j < recentStops.length; j++) {
if(recentStops[j].stopname === recentStopsPrv[i].stopname) {
alreadyThere = true;
break;
}
}
if(!alreadyThere)
recentStops[recentStops.length] = recentStopsPrv[i];
}
}
if(!alreadyThere) {
localStorage['recentStops']=JSON.stringify(recentStops);
showRecentStops();
}
}
function showRecentStops() {
// alert('in showrecentstops');
if(localStorage['recentStops'] === undefined || localStorage['recentStops'] === null)
return;
var recentStops = JSON.parse(localStorage['recentStops']);
recentStopsStr = '<table id="recentStops" class="tbl_color">';
if(recentStops === null)
return;
if(recentStops.length) {
// recentStopsStr = '<table id="recentStops">';
for(var i = 0; i < recentStops.length && i < MAXRECENTSTOPS; i++) {
if(recentStops[i] !== null && recentStops[i] !== undefined && typeof(recentStops[i]) === 'object') {
lmark = typeof(recentStops[i].landmark) == 'undefined' || recentStops[i].landmark == 'undefined'
? '' : recentStops[i].landmark;
elm = '<tr><td><a href="javascript:popStop({\'id\':\'' +
recentStops[i].id + '\', \'area\': \'' + recentStops[i].area +
'\', \'stopname\': \'' + recentStops[i].stopname + '\', \'landmark\': \'' +
recentStops[i].landmark + '\', \'stopnameext\': \'' + recentStops[i].stopnameext + '\'}, selectedInput)">' +
recentStops[i].stopname + '</td><td>' + recentStops[i].area + '</td><td>' + lmark
+ "</a></td></tr>";
recentStopsStr = recentStopsStr + elm;
}
}
recentStopsStr = recentStopsStr + '</table>';
document.getElementById("recentStops").innerHTML = recentStopsStr;
}
}
// Buses lists, hide and show per radio button selection
function activateList(cList) {
document.getElementById('busNoCombo').style.display = 'none';
document.getElementById('oBus').style.display = 'none';
document.getElementById('lBus').style.display = 'none';
document.getElementById('aBus').style.display = 'none';
document.getElementById('asBus').style.display = 'none';
document.getElementById('cBus').style.display = 'none';
if(cList === "ALL")
document.getElementById('busNoCombo').style.display='block';
else if(cList === "O")
document.getElementById('oBus').style.display='block';
else if(cList === "L")
document.getElementById('lBus').style.display='block';
else if(cList === "A")
document.getElementById('aBus').style.display='block';
else if(cList === "AS")
document.getElementById('asBus').style.display='block';
else if(cList === "C")
document.getElementById('cBus').style.display='block';
}
function createOStop(os) {
return {'id':os[3], 'label':os[0] + ': ' + os[1] + ' ' + os[2],
'area':os[0], 'value':os[1], 'stopname':os[1], 'landmark':os[2]};
}
function popStop(oStop, stop) {
if(stop === 1) {
$("#startStop").val(oStop.stopname);
setCookie('cStartStop', oStop.stopname, 1);
setStart(oStop);
$("#destStop").focus();
} else if(stop === 2) {
$("#destStop").val(oStop.stopname);
setCookie('cDestStop', oStop.stopname, 1);
setDest(oStop);
$("#findBus").focus();
}
}
function setDest(oStop) {
gDestStop = oStop;
localStorage['destStop']=JSON.stringify(gDestStop);
setCookie('cDestStop', oStop.stopname, 1);
setCookie('cDestStopNameId', oStop.id, 1);
addRecentStop(oStop);
}
// Initialize the input fields, start and destination from cookies/loca storage
function initStops() {
if(typeof(localStorage['destStop']) !== 'undefined')
if(localStorage['startStop'] !== null && localStorage['startStop'] !== 'undefined') {
gStartStop = JSON.parse(localStorage['startStop']);
$("#startStop").val(gStartStop.stopname);
}
if(typeof(localStorage['destStop']) !== 'undefined')
if(localStorage['destStop'] !== null && localStorage['destStop'] !== 'undefined') {
gDestStop = JSON.parse(localStorage['destStop']);
$("#destStop").val(gDestStop.stopname);
}
}
// fn run on submit find bus form
function validateFindBusForm() {
// document.getElementById("loading").className = "loading-visible";
var loc, sNameId, dNameId, rSFound,
nomatch, rDFound, bSMatch, bDMatch, w;
loc = '';
sNameId = ''; dNameId = '';
if (gStartStop.id === '' && gDestStop.id === '') {
alert('Enter a start stop or a start and destination stop');
return false;
}
if (gStartStop.id === '' && gDestStop.id !== '') {
alert('To check buses near a stop enter only start stop');
return false;
}
if (gStartStop.id !== '' && gDestStop.id === '') { // empty destination - display info for start stop
if (gStartStop !== undefined && gStartStop.id !== "") {// came from autocomplete, we already have stopnameid
sNameId = gStartStop.id;
dNameId = '';
loc = "busesfound.html?s=" + gStartStop.id;
}
} // We have both a start and destination entered by user
if (gStartStop !== null && gDestStop.id !== null) {
sNameId = gStartStop.id;
dNameId = gDestStop.id;
loc = "busesfound.html?s=" + gStartStop.id + "&d=" + gDestStop.id;
}
if (loc !== '') {
goLinkBusesFound(gStartStop.id, gDestStop.id);
return false;
}
// window.location = loc;
return;
}
// Clear start or destination fields
function clearInput()
{
if (selectedInput === 1) {
document.getElementById("startStop").value = "";
setCookie('cStartStop', "", 1);
setCookie('cStartStopNameId', 0, 1);
setCookie('cStartStopInfo', 0, 1);
$("#startStop").focus();
gStartStop = null;
} else {
document.getElementById("destStop").value = "";
setCookie('cDestStop', "", 1);
setCookie('cDestStopNameId', 0, 1);
setCookie('cDestStopInfo', 0, 1);
$("#destStop").focus();
gDestStop = null;
}
}
function goLinkBusesFound(startStopNameId, destStopNameId) {
var d;
setCookie("cStartStopNameId", startStopNameId, 1);
setCookie("cDestStopNameId", destStopNameId, 1);
if (startStopNameId !== "") {
d = destStopNameId !== "" ? "&d=" + destStopNameId : "";
window.location = "busesfound.html";
// window.location = "busesfound.html?s=" + startStopNameId + d;
}
return false;
}
function showStatus()
{
window.location='status.html?s=' + gStartStop.id;
}
function showR() {
b = $('#busNo').val();
if(b === '')
alert('Please type a Bus no. before hitting Select Route');
else
showRouteComplete();
}

1
index.min.js vendored Normal file

File diff suppressed because one or more lines are too long

574
index_old.js Normal file
View File

@ -0,0 +1,574 @@
// findbus.js
/*
var getStopNames, getStopLatLon, getCookie, setCookie, getWinDim, getLocation,
updateDestInfo, BrowserLevel, findNearestStop, updateStartInfo, goLinkBusesFound, findStop,
getCombo, setGeoPos, distanceLatLon, window;
*/
var startVld;
startVld = false;
var selectedInput = 1;
var dBugLvl = 3;
var phoneIA = true; // Iphone or Android
var stopNames;
var busMaster;
var gStartStop = {'id':'', 'value':''};
var gDestStop = {'id':'', 'value':''};
var geoPos;
var NEARLAT = 0.01;
var firstLoad = true;
var oNearestStop = null;
var arBusList;
var stopBus;
var selectedStop;
var near_stop;
var MAXRECENTSTOPS = 7;
$(document).ready(function () {
var sStop, dStop, sId, dId, w;
stopNames = getStopNames();
stopLatLon = getStopLatLon();
busMaster = getbusmaster();
arBusList = getbuslist();
stopBus = getStopBusList();
scrollTo(0, 0);
console.log('In index.js before initStops()');
initStops();
// w = getWinDim();
// $('#startStop').width(w.wd * 0.90);
$('#startStop').width("95%");
$('#startStop').height('18px');
$('#startStop').css('font-size', '16px');
$('#destStop').width("95%");
$('#destStop').height('18px');
$('#destStop').css('font-size', '16px');
getLocation(); // runs setGeoPos(pos), showLocation(pos)
PopulateAllBusList();
PopulateOtherBusLists();
activateList('ALL');
showRecentStops();
// $("#startStop").focus();
document.getElementById('busNoCombo').checked = true;
$(function () {
$("#startStop").autocomplete({
source: function(req, response) {
var re = $.ui.autocomplete.escapeRegex(req.term);
re = re.toLowerCase();
stopid = re.replace(/[^a-zA-Z0-9]+/g,'');
var len = stopid.length;
var i = 0;
matchArr = [];
for(var j=0; j<stopNames.length; j++) {
if(stopid == stopNames[j][0].toLowerCase().substring(0, len)) {
matchArr[i] = createOStop(stopNames[j]);
i = i + 1;
}
}
if(!matchArr.length) { // No matching areas found, look for stops
for(var j=0; j<stopNames.length; j++) {
if(stopNames[j][3].indexOf(stopid) >= 0) {
matchArr[i] = createOStop(stopNames[j]);
i = i + 1;
}
}
}
response(matchArr);
},
minLength: 2,
select: function(event, ui) {
$('#startStop').val(ui.item.value);
setStart(ui.item);
$('#destStop').focus();
} /* ,
focus: function(event, ui) {
$('#startStop').autocomplete("close").val(ui.item.value)
}
*/
// $('#abbrev').val(ui.item.abbrev);
});
$('#startStop').focus(function() {
selectedInput = 1;
});
$('#destStop').autocomplete({
source: function(req, response) {
var re = $.ui.autocomplete.escapeRegex(req.term);
re = re.toLowerCase();
stopid = re.replace(/[^a-zA-Z0-9]+/g,'');
var len = stopid.length;
var i = 0;
matchArr = [];
for(var j=0; j<stopNames.length; j++) {
if(stopid == stopNames[j][0].toLowerCase().substring(0, len)) {
matchArr[i] = createOStop(stopNames[j]);
// {'id':stopNames[j][3], 'label':stopNames[j][0] + ': ' + stopNames[j][1] + ' ' + stopNames[j][2],
// 'area':stopNames[j][0], 'value':stopNames[j][1], 'stopname':stopNames[j][2]};
i = i + 1;
}
}
if(!matchArr.length) { // No matching areas found, look for stops
for(var j=0; j<stopNames.length; j++) {
if(stopNames[j][3].indexOf(stopid) >= 0) {
matchArr[i] = createOStop(stopNames[j]);
// {'id':stopNames[j][3], 'label':stopNames[j][0] + ': ' + stopNames[j][1] + ' ' + stopNames[j][2],
// 'area':stopNames[j][0], 'value':stopNames[j][1], 'stopname':stopNames[j][2]};
i = i + 1;
}
}
}
response(matchArr);
// response($.grep(stopNames, function(item){return matcher.test(item[0]); }) );
},
minLength: 2,
select: function(event, ui) {
$('#destStopId').val(ui.item.id);
setCookie('cDestStop', ui.item.value, 1);
setCookie('cDestStopNameId', ui.item.id, 1);
// addRecentStop(ui.item.value);
setDest(ui.item);
$('#fndBusBtn').focus();
} /*,
focus: function(event, ui) {
$('#destStop').autocomplete("close").val(ui.item.value)
}
*/
});
$('#destStop').focus(function() {
selectedInput = 2;
});
$("#busNo").autocomplete({
source: function(req, response) {
var re = $.ui.autocomplete.escapeRegex(req.term);
re = re.toLowerCase();
var len = re.length;
var i = 0;
matchArr = [];
for(var j=0; j<arBusList.length; j++) {
if(re == arBusList[j][0].toLowerCase().substring(0, len)
|| re == arBusList[j][1].toLowerCase().substring(0, len)) {
matchArr[i] = arBusList[j][1];
i = i + 1;
}
}
response(matchArr);
} /*,
focus: function(event, ui) {
$('#busNo').autocomplete("close").val(ui.item.value)
}
*/
});
});
function handle_error(err) {
if (err.code === 1) {
return 1;// user said no!
}
}
function get_position() {
alert('Getting position');
}
function myLocStop() {
$('#startStop').val(document.getElementById('nearStop').value);
// sessionStorage.startStop = document.getElementById('nearStop').value;
setCookie('cStartStop', document.getElementById('nearStop').value, 1);
$('#startStopId').val(document.getElementById('nearStopId').value);
setCookie('cStartStopId', document.getElementById('nearStopId').value, 1);
// sessionStorage.startStopId = document.getElementById('nearStopId').value;
updateStartInfo('n');
}
});
function showLocation(pos) { // Stops near you
if(typeof(document.getElementById("myLoc")) === 'undefined')
return; // dom not loaded as yet
var resparr, contentString, x, near_stop, elm;
resparr = findNearestStop(pos);
contentString = '<table id="myLoc" class="tbl_color">';
if (resparr !== null) {
for (x = 0; x < resparr.length; x += 1) {
near_stop = resparr[x];
if(x === 0) { // Nearest stop and area
oNearestStop = near_stop;
document.getElementById('stopsnearyou').innerHTML = 'Nearby Stops (' + near_stop.area + ')';
setStart(near_stop);
}
elm = '<tr><td><a href="javascript:popStart({\'di\':' + x + ',\'id\':\'' +
near_stop.id + '\', \'area\': \'' + near_stop.area +
'\', \'stopname\': \'' + near_stop.stopname + '\', \'landmark\': \'' +
near_stop.landmark + '\', \'stopnameext\': \'' + near_stop.stopnameext + '\'})">' +
near_stop.stopname + "</td><td>" + near_stop.di + "&nbsp;m" + "</a></td></tr>";
contentString = contentString + elm;
if (x >= 2) {// Show 2 nearest stops
break; }
}
} else {
contentString = contentString + '<tr><td>' + 'No stops near you found' + '</td></tr>'; }
if(firstLoad) {
if(oNearestStop !== null) {
$("#startStop").val(oNearestStop.stopname);
// document.myForm.startStop.value = oNearestStop.stopname;
showRoutesAtStop(oNearestStop);
$('#destStop').focus();
firstLoad = false;
}
}
contentString = contentString + '</tbody></table>';
document.getElementById("myLoc").innerHTML = contentString;
setCookie('cMyLat', pos.coords.latitude, 1);
setCookie('cMyLon', pos.coords.longitude, 1);
}
// set the local variable so it can be used in this js file
function setGeoPos(pos) {
geoPos = pos;
}
function findNearestStop(pos) {
var nearStop, retNearStop, x, y, dLat, dLon, di;
nearStop = [];
retNearStop = [];
y = 0;
for (x = 0; x < stopLatLon.length; x += 1) {
dLat = parseFloat(stopLatLon[x][1]);
dLon = parseFloat(stopLatLon[x][2]);
if (Math.abs(pos.coords.latitude - dLat) < NEARLAT
|| Math.abs(pos.coords.longitude - dLon) < NEARLAT) {
di = distanceLatLon(pos.coords.latitude, pos.coords.longitude,
dLat, dLon);
if (di < 750) {
nearStop[di] = stopLatLon[x][0];
y += 1;
}
}
}
for (x = 0; x < nearStop.length; x += 1) {
if (nearStop[x] !== undefined) {
for (y = 0; y < stopNames.length; y += 1) {
if (stopNames[y][3] === nearStop[x]) {
var sname = stopNames[y][1];
var lmark = stopNames[y][2];
stopnameext = lmark !== null ? sname + ' /' + lmark : sname;
retNearStop[retNearStop.length] = {"di": x, "id": stopNames[y][3],
"area": stopNames[y][0], "stopname": stopNames[y][1],
"landmark": stopNames[y][2], 'stopnameext':stopnameext};
break;
}
}
// retNearStop[retNearStop.length] = {"di":x, "stopnameid":nearStop[x]};
}
}
return retNearStop;
}
// fn run on submit find bus form
function validateFindBusForm() {
// document.getElementById("loading").className = "loading-visible";
var loc, sNameId, dNameId, rSFound,
nomatch, rDFound, bSMatch, bDMatch, w;
loc = '';
sNameId = ''; dNameId = '';
if (gStartStop.id === '' && gDestStop.id === '') {
alert('Enter a start stop or a start and destination stop');
return false;
}
if (gStartStop.id === '' && gDestStop.id !== '') {
alert('To check buses near a stop enter only start stop');
return false;
}
if (gStartStop.id !== '' && gDestStop.id === '') { // empty destination - display info for start stop
if (gStartStop !== undefined && gStartStop.id !== "") {// came from autocomplete, we already have stopnameid
sNameId = gStartStop.id;
dNameId = '';
loc = "busesfound.html?s=" + gStartStop.id;
}
} // We have both a start and destination entered by user
if (gStartStop !== null && gDestStop.id !== null) {
sNameId = gStartStop.id;
dNameId = gDestStop.id;
loc = "busesfound.html?s=" + gStartStop.id + "&d=" + gDestStop.id;
}
if (loc !== '') {
goLinkBusesFound(gStartStop.id, gDestStop.id);
return false;
}
// window.location = loc;
return;
}
function goLinkBusesFound(startStopNameId, destStopNameId) {
var d;
setCookie("cStartStopNameId", startStopNameId, 1);
setCookie("cDestStopNameId", destStopNameId, 1);
if (startStopNameId !== "") {
d = destStopNameId !== "" ? "&d=" + destStopNameId : "";
window.location = "busesfound.html";
// window.location = "busesfound.html?s=" + startStopNameId + d;
}
return false;
}
// Show the bus nos. at a stop
// input stop object
function showRoutesAtStop(oStop) { // Bus routes at start - buses at start
var busList = null;
document.getElementById("busroutesatstart").innerHTML = 'Buses at ' + oStop.stopname + ' (' + oStop.area + ')';
for(var i = 0; i < stopBus.length; i++) {
if(stopBus[i][1] == oStop.id) {
busList = stopBus[i][5];
break;
}
}
var firstStop, lastStop;
if(busList != null) {
arNearBuses = busList.split(",");
routesAtStopStr = '<table id="routesAtStop" class="tbl_color">';
for(var j = 0; j < arNearBuses.length; j++) {
busNo = arNearBuses[j].split("|")[0].trim();
for(var a = 0; a < arBusList.length; a++) {
if(arBusList[a][1] == busNo) {
firstStop = arBusList[a][2];
lastStop = arBusList[a][3];
}
}
busInfo = getBusInfo(busNo);
busfreq = "";
if(busInfo != undefined && busInfo.frequency !="")
busfreq = "&nbsp;(&nbsp;" + busInfo.frequency + "&nbsp;mins)";
busInfo = getBusInfo(busNo);
busfreq = "";
if(busInfo != undefined && busInfo.frequency !="")
busfreq = busInfo.frequency + "&nbsp;mins";
sBusNo = busNo.replace(/ /g, '&nbsp;').replace('Exp AC Exp', 'AC Exp');
url = '<a href="#"' + ' onClick="return goLinkBusRoute(' + "'" + busNo + "'"
+ ', 0, 0)' + '">' + '<span style="font-weight:bold; width:15%;">'
+ sBusNo + '</span>' +
'</td><td>' + firstStop + ' - ' + lastStop +
'</td><td>' + busfreq + "</a>" ;
routesAtStopStr = routesAtStopStr + '<tr><td>' + url + "</a></td></tr>";
// routesAtStopStr = routesAtStopStr + '<tr><td>' + recentStops[i] + '</td></tr>';
}
routesAtStopStr = routesAtStopStr + '</table>';
document.getElementById("routesAtStop").innerHTML = routesAtStopStr;
}
}
// Clear start or destination fields
function clearInput()
{
if (selectedInput === 1) {
document.getElementById("startStop").value = "";
setCookie('cStartStop', "", 1);
setCookie('cStartStopNameId', 0, 1);
setCookie('cStartStopInfo', 0, 1);
$("#startStop").focus();
gStartStop = null;
} else {
document.getElementById("destStop").value = "";
setCookie('cDestStop', "", 1);
setCookie('cDestStopNameId', 0, 1);
setCookie('cDestStopInfo', 0, 1);
$("#destStop").focus();
gDestStop = null;
}
}
// Stuff value from link into start field
function popStart(oStop) {
$("#startStop").val(oStop.stopname);
setStart(oStop);
$("#destStop").focus();
}
// Stuff value from link into the input field
function popStop(oStop) {
if(selectedInput === 1) {
$("#startStop").val(oStop.stopname);
setCookie('cStartStop', oStop.stopname, 1);
setStart(oStop);
$("#destStop").focus();
} else if(selectedInput === 2) {
$("#destStop").val(oStop.stopname);
setCookie('cDestStop', oStop.stopname, 1);
setDest(oStop);
$("#findBus").focus();
}
}
function setStart(oStop) {
gStartStop = oStop;
localStorage['startStop']=JSON.stringify(gStartStop);
setCookie('cStartStop', oStop.stopname, 1);
setCookie('cStartStopNameId', oStop.id, 1);
addRecentStop(oStop);
showRoutesAtStop(oStop);
}
function setDest(oStop) {
gDestStop = oStop;
localStorage['destStop']=JSON.stringify(gDestStop);
setCookie('cDestStop', oStop.stopname, 1);
setCookie('cDestStopNameId', oStop.id, 1);
addRecentStop(oStop);
}
// Initialize the input fields, start and destination from cookies/loca storage
function initStops() {
if(typeof(localStorage['destStop']) !== 'undefined')
if(localStorage['startStop'] !== null && localStorage['startStop'] !== 'undefined') {
gStartStop = JSON.parse(localStorage['startStop']);
$("#startStop").val(gStartStop.stopname);
}
if(typeof(localStorage['destStop']) !== 'undefined')
if(localStorage['destStop'] !== null && localStorage['destStop'] !== 'undefined') {
gDestStop = JSON.parse(localStorage['destStop']);
$("#destStop").val(gDestStop.stopname);
}
}
// Add to the list of recent stops
function addRecentStop(oStop) {
var rs = localStorage['recentStops'];
var recentStopsPrv;
if(rs != null)
recentStopsPrv = JSON.parse(rs);
recentStops = null;
var recentStops = new Array;
recentStops[0] = oStop;
if(recentStopsPrv !== null && recentStopsPrv != undefined) {
for(var i = 0; i < recentStopsPrv.length; i++) {
if(recentStopsPrv[i] === undefined || recentStopsPrv[i] === null)
continue;
// check if already in array, else add
alreadyThere = false;
for(var j = 0; j < recentStops.length; j++) {
if(recentStops[j].stopname === recentStopsPrv[i].stopname) {
alreadyThere = true;
break;
}
}
if(!alreadyThere)
recentStops[recentStops.length] = recentStopsPrv[i];
}
}
localStorage['recentStops']=JSON.stringify(recentStops);
showRecentStops();
}
function showRecentStops() {
if(localStorage['recentStops'] === undefined || localStorage['recentStops'] === null)
return;
var recentStops = JSON.parse(localStorage['recentStops']);
recentStopsStr = '<table id="recentStops" class="tbl_color">';
if(recentStops === null)
return;
if(recentStops.length) {
// recentStopsStr = '<table id="recentStops">';
for(var i = 0; i < recentStops.length && i < MAXRECENTSTOPS; i++) {
if(recentStops[i] !== null && recentStops[i] !== undefined && typeof(recentStops[i]) === 'object') {
lmark = typeof(recentStops[i].landmark) == 'undefined' || recentStops[i].landmark == 'undefined'
? '' : recentStops[i].landmark;
elm = '<tr><td><a href="javascript:popStop({\'id\':\'' +
recentStops[i].id + '\', \'area\': \'' + recentStops[i].area +
'\', \'stopname\': \'' + recentStops[i].stopname + '\', \'landmark\': \'' +
recentStops[i].landmark + '\', \'stopnameext\': \'' + recentStops[i].stopnameext + '\'})">' +
recentStops[i].stopname + '</td><td>' + recentStops[i].area + '</td><td>' + lmark
+ "</a></td></tr>";
recentStopsStr = recentStopsStr + elm;
}
}
recentStopsStr = recentStopsStr + '</table>';
document.getElementById("recentStops").innerHTML = recentStopsStr;
}
}
function showR() {
b = $('#busNo').val();
if(b === '')
alert('Please type a Bus no. before hitting Select Route');
else
showRouteComplete();
}
function createOStop(os) {
return {'id':os[3], 'label':os[0] + ': ' + os[1] + ' ' + os[2],
'area':os[0], 'value':os[1], 'stopname':os[1], 'landmark':os[2]};
}
function activateList(cList) {
document.getElementById('busNoCombo').style.display = 'none';
document.getElementById('oBus').style.display = 'none';
document.getElementById('lBus').style.display = 'none';
document.getElementById('aBus').style.display = 'none';
document.getElementById('asBus').style.display = 'none';
document.getElementById('cBus').style.display = 'none';
if(cList === "ALL")
document.getElementById('busNoCombo').style.display='block';
else if(cList === "O")
document.getElementById('oBus').style.display='block';
else if(cList === "L")
document.getElementById('lBus').style.display='block';
else if(cList === "A")
document.getElementById('aBus').style.display='block';
else if(cList === "AS")
document.getElementById('asBus').style.display='block';
else if(cList === "C")
document.getElementById('cBus').style.display='block';
}

263
index_old.php Normal file
View File

@ -0,0 +1,263 @@
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<title>BestBus Route Finder (Mumbai)</title>
<meta name="viewport" content="user-scalable=yes, width=device-width">
<!-- <link rel="stylesheet" type="text/css" href="css/common.css"> -->
<link rel="stylesheet" type="text/css" href="lib/jquery/jquerymobilemin.css">
<script type="text/javascript" src="lib/jquery/jquerymin.js"></script>
<script type="text/javascript" src="lib/jquery/jquerymobilemin.js"></script>
</head>
<body>
<div data-role="page" data-theme="a">
<div data-role="header" data-theme="a">
<h1>BestBus Route Finder (Mumbai)</h1>
<a href="help/bestbushelp.html" rel="external" data-icon="search">Help</a>
</div>
<!--
<td style="width: 581px;" class="header_txt">&nbsp; &nbsp; &nbsp;
&nbsp; &nbsp;&nbsp;BestBus Route Finder (Mumbai)</td>
<td style="width: 24px;" class="header_right_img"><a
href="help/BestbusHelp.html"> <img
style="border: 0px solid ; width: 24px; height: 24px;" id="Help"
title="Help" onclick="window.location='help/bestbushelp.html';"
src="./images/px24help.png"></a></td>
</div>
<!--
<div class="menu">
<h6><a href="findbus.html">Find your Bus</a></h6>
<h6><a href="busroute.html">Show a route</a></h6>
</div>
-->
<div data-role="content">
<ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="a">
<li><a href="findbus.html" data-transition="slidedown" rel="external">Find your Bus</a></li>
<li><a href="busroute.html" data-transition="slidedown" rel="external">Show a route</a></li>
</ul>
</div>
<div data-role="footer" data-position="fixed" data-theme="c">
<?php
// AdMob Publisher Code
// Language: PHP (fsockopen)
// Version: 20081105
// Copyright AdMob, Inc., All rights reserved
// Documentation at http://developer.admob.com/wiki/Main_Page
$admob_params = array(
'PUBLISHER_ID' => 'a14df5265566847', // Required to request ads. To find your Publisher ID, log in to your AdMob account and click on the "Sites & Apps" tab.
'ANALYTICS_ID' => 'a14df5a1a495612', // Required to collect Analytics data. To find your Analytics ID, log in to your Analytics account and click on the "Edit" link next to the name of your site.
'AD_REQUEST' => true, // To request an ad, set to TRUE.
'ANALYTICS_REQUEST' => true, // To enable the collection of analytics data, set to TRUE.
'TEST_MODE' => false, // While testing, set to TRUE. When you are ready to make live requests, set to FALSE.
// Additional optional parameters are available at: http://developer.admob.com/wiki/AdCodeDocumentation
'OPTIONAL' => array()
);
// Optional parameters for AdMob Analytics (http://analytics.admob.com)
//$admob_params['OPTIONAL']['title'] = "Enter Page Title Here"; // Analytics allows you to track site usage based on custom page titles. Enter custom title in this parameter.
//$admob_params['OPTIONAL']['event'] = "Enter Event Name Here"; // To learn more about events, log in to your Analytics account and visit this page: http://analytics.admob.com/reports/events/add
/* This code supports the ability for your website to set a cookie on behalf of AdMob
* To set an AdMob cookie, simply call admob_setcookie() on any page that you call admob_request()
* The call to admob_setcookie() must occur before any output has been written to the page (http://www.php.net/setcookie)
* If your mobile site uses multiple subdomains (e.g. "a.example.com" and "b.example.com"), then pass the root domain of your mobile site (e.g. "example.com") as a parameter to admob_setcookie().
* This will allow the AdMob cookie to be visible across subdomains
*/
//admob_setcookie();
/* AdMob strongly recommends using cookies as it allows us to better uniquely identify users on your website.
* This benefits your mobile site by providing:
* - Improved ad targeting = higher click through rates = more revenue!
* - More accurate analytics data (http://analytics.admob.com)
*/
// Send request to AdMob. To make additional ad requests per page, copy and paste this function call elsewhere on your page.
echo admob_request($admob_params);
/////////////////////////////////
// Do not edit below this line //
/////////////////////////////////
// This section defines AdMob functions and should be used AS IS.
// We recommend placing the following code in a separate file that is included where needed.
function admob_request($admob_params) {
static $pixel_sent = false;
$ad_mode = false;
if (!empty($admob_params['AD_REQUEST']) && !empty($admob_params['PUBLISHER_ID'])) $ad_mode = true;
$analytics_mode = false;
if (!empty($admob_params['ANALYTICS_REQUEST']) && !empty($admob_params['ANALYTICS_ID']) && !$pixel_sent) $analytics_mode = true;
$protocol = 'http';
if (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') $protocol = 'https';
$rt = $ad_mode ? ($analytics_mode ? 2 : 0) : ($analytics_mode ? 1 : -1);
if ($rt == -1) return '';
list($usec, $sec) = explode(' ', microtime());
$params = array('rt=' . $rt,
'z=' . ($sec + $usec),
'u=' . urlencode($_SERVER['HTTP_USER_AGENT']),
'i=' . urlencode($_SERVER['REMOTE_ADDR']),
'p=' . urlencode("$protocol://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']),
'v=' . urlencode('20081105-PHPFSOCK-33fdd8e59a40dd9a'));
$sid = empty($admob_params['SID']) ? session_id() : $admob_params['SID'];
if (!empty($sid)) $params[] = 't=' . md5($sid);
if ($ad_mode) $params[] = 's=' . $admob_params['PUBLISHER_ID'];
if ($analytics_mode) $params[] = 'a=' . $admob_params['ANALYTICS_ID'];
if (!empty($_COOKIE['admobuu'])) $params[] = 'o=' . $_COOKIE['admobuu'];
if (!empty($admob_params['TEST_MODE'])) $params[] = 'm=test';
if (!empty($admob_params['OPTIONAL'])) {
foreach ($admob_params['OPTIONAL'] as $k => $v) {
$params[] = urlencode($k) . '=' . urlencode($v);
}
}
$ignore = array('HTTP_PRAGMA' => true, 'HTTP_CACHE_CONTROL' => true, 'HTTP_CONNECTION' => true, 'HTTP_USER_AGENT' => true, 'HTTP_COOKIE' => true);
foreach ($_SERVER as $k => $v) {
if (substr($k, 0, 4) == 'HTTP' && empty($ignore[$k]) && isset($v)) {
$params[] = urlencode('h[' . $k . ']') . '=' . urlencode($v);
}
}
$post = implode('&', $params);
$request_timeout = 1; // 1 second timeout
$contents = '';
$errno = 0;
$errstr = '';
list($usec_start, $sec_start) = explode(' ', microtime());
$request = @fsockopen('r.admob.com', 80, $errno, $errstr, $request_timeout);
if($request) {
stream_set_timeout($request, $request_timeout);
$post_body = "POST /ad_source.php HTTP/1.0\r\nHost: r.admob.com\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: " . strlen($post) . "\r\n\r\n" . $post;
$post_body_len = strlen($post_body);
$bytes_written = 0;
$body = false;
$info = stream_get_meta_data($request);
$timeout = $info['timed_out'];
while($bytes_written < $post_body_len && !$timeout) {
$current_bytes_written = fwrite($request, $post_body);
if($current_bytes_written === false) return ''; // write failed
$bytes_written += $current_bytes_written;
if($bytes_written === $post_body_len) break;
$post_body = substr($post_body, $bytes_written);
$info = stream_get_meta_data($request);
$timeout = $info['timed_out'];
}
while(!feof($request) && !$timeout) {
$line = fgets($request);
if(!$body && $line == "\r\n") $body = true;
if($body && !empty($line)) $contents .= $line;
$info = stream_get_meta_data($request);
$timeout = $info['timed_out'];
}
fclose($request);
}
else {
$contents = '';
}
if (!$pixel_sent) {
$pixel_sent = true;
list($usec_end, $sec_end) = explode(' ', microtime());
$contents .= "<img src=\"$protocol://p.admob.com/e0?"
. 'rt=' . $rt
. '&amp;z=' . ($sec + $usec)
. '&amp;a=' . ($analytics_mode ? $admob_params['ANALYTICS_ID'] : '')
. '&amp;s=' . ($ad_mode ? $admob_params['PUBLISHER_ID'] : '')
. '&amp;o=' . (empty($_COOKIE['admobuu']) ? '' : $_COOKIE['admobuu'])
. '&amp;lt=' . ($sec_end + $usec_end - $sec_start - $usec_start)
. '&amp;to=' . $request_timeout
. '" alt="" width="1" height="1"/>';
}
return $contents;
}
function admob_setcookie($domain = '', $path = '/') {
if (empty($_COOKIE['admobuu'])) {
$value = md5(uniqid(rand(), true));
if (!empty($domain) && $domain[0] != '.') $domain = ".$domain";
if (setcookie('admobuu', $value, mktime(0, 0, 0, 1, 1, 2038), $path, $domain)) {
$_COOKIE['admobuu'] = $value; // make it visible to admob_request()
}
}
}
?>
<!--
<fb:like></fb:like>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: '179731092083198', status: true, cookie: true,
xfbml: true});
};
(function() {
var e = document.createElement('script');
e.type = 'text/javascript';
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
-->
<!--
<div id="desc">
You are at the main screen of the Mumbai Bus Route Finder. <br>
To find a bus from Point A (eg. Worli Naka) to Point B (Churgate
Station), select the Find a Bus option. <br>
To see a particular route (e.g. 2 L), select the Show a Route option.<br>
<br>
Disclaimer: The route suggestions, timings, frequencies are accurate to
the best of our knowledge. MESN, Tech. Services and its employees or
agents bear no responsibility for any information that may not be
updated or accurate. <br>
By continuing past this page you implicitly absolve us of any
responsibility or damages caused by the use of this software.<br>
Your location is determined by the different way. On a computer, it may
be based on the location of your Internet Service provider.<br>
On a GPS equipped phone, the location is based on either the GPS or the
cell phone tower location.<br>
Please make sure that you verify your location based on your
surroundings and do not completely
rely on this software.
</div>
-->
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", function() {
// alert('initialized');
}, true);
</script>
</body>
</html>

6
init.js Normal file
View File

@ -0,0 +1,6 @@
$(document).bind("mobileinit", function(){
$.mobile.loadingMessage = false;
});

119
init/areas.js Normal file
View File

@ -0,0 +1,119 @@
function getAreas() {
var a = [
["Aksa", 19.188430, 72.798030],
["Anand Nagar", 19.150210, 72.836230],
["Andheri E", 19.129670, 72.883570],
["Andheri W", 19.138230, 72.847330],
["Arthur Road", 18.994660, 72.831220],
["Asalpha Village", 19.103220, 72.892340],
["Babulnath", 18.960830, 72.808610],
["Backbay", 18.917820, 72.824600],
["Bandra E", 19.068570, 72.867870],
["Bandra Kurla Complex", 19.070600, 72.871250],
["Bandra W", 19.068140, 72.837950],
["Bhandup W", 19.159310, 72.937650],
["Bhendi Bazar", 18.961950, 72.834160],
["Borivali E", 19.441600, 72.870170],
["Borivali W", 19.244570, 72.856130],
["Byculla E", 18.985590, 72.835270],
["Byculla W", 18.980750, 72.831960],
["Chandivli", 19.112770, 72.888460],
["Charkop", 19.219950, 72.833970],
["Charni Road E", 18.954330, 72.823340],
["Chembur", 19.053970, 72.911950],
["Chembur E", 19.054270, 72.891820],
["Chembur W", 19.069040, 72.904440],
["Chh Shivaji Terminus", 18.942000, 72.834680],
["Chunabhatti", 19.050830, 72.874540],
["Churchgate", 18.938610, 72.826690],
["Colaba", 18.924170, 72.831880],
["Dadar E", 19.019730, 72.848920],
["Dadar W", 19.022240, 72.844010],
["Dahisar E", 19.244250, 72.869830],
["Delisle Road", 18.991570, 72.831760],
["Deonar", 19.045620, 72.925230],
["Dhobi Talao", 18.946080, 72.831700],
["Dindoshi", 19.177000, 72.865100],
["Dockyard Road", 18.971520, 72.846550],
["Elphiston Road", 19.011590, 72.832430],
["Fort", 18.944340, 72.839720],
["Ghatkopar E", 19.078000, 72.915950],
["Ghatkopar W", 19.088760, 72.906810],
["Ghodbunder", 19.209840, 72.974490],
["Girgaon", 18.950200, 72.825340],
["Goregaon E", 19.178270, 72.884220],
["Goregaon W", 19.177470, 72.848340],
["Grant Road E", 18.965310, 72.819860],
["Grant Road W", 18.961830, 72.814380],
["Haji Ali", 18.982220, 72.814610],
["J V P D", 19.123250, 72.831240],
["Jogeshwari E", 19.146230, 72.870700],
["Jogeshwari W", 19.146850, 72.846580],
["Juhu", 19.125390, 72.836870],
["Kala Chowky", 18.988370, 72.843470],
["Kalina", 19.080670, 72.869230],
["Kandivali E", 19.214410, 72.878910],
["Kandivali W", 19.221670, 72.853070],
["Kanjurmarg W", 19.130810, 72.926570],
["Khar E", 19.067840, 72.846410],
["Khar W", 19.075020, 72.837160],
["Kings Circle", 19.032590, 72.858560],
["Kurla E", 19.074930, 72.879130],
["Kurla W", 19.093590, 72.883100],
["Lalbaug", 18.992740, 72.836420],
["Lower Parel", 18.998480, 72.831210],
["Madh", 19.196750, 72.816110],
["Mahalaxmi", 18.983280, 72.824200],
["Mahalaxmi W", 18.983390, 72.824520],
["Mahatma Phule Market", 18.945710, 72.834040],
["Mahim", 19.046180, 72.845570],
["Mahim W", 19.042960, 72.847810],
["Malad E", 19.194950, 72.869710],
["Malad W", 19.200990, 72.848780],
["Malvani", 19.196310, 72.821540],
["Mankhurd", 19.051730, 72.937660],
["Mankhurd S", 19.046180, 72.933750],
["Mantralaya", 18.931170, 72.830350],
["Marine Drive", 18.955960, 72.823740],
["Marine Lines", 18.941610, 72.826880],
["Marol", 19.123880, 72.886930],
["Marve", 19.196080, 72.799800],
["Matunga", 19.030610, 72.857840],
["Matunga W", 19.029980, 72.847030],
["Mazgaon", 18.969060, 72.847360],
["Mulund E", 19.173360, 72.964670],
["Mulund W", 19.175650, 72.951860],
["Mumbai Central E", 18.977480, 72.824030],
["Nagpada", 18.970510, 72.834940],
["Nana Chowk", 18.961310, 72.813110],
["Napean Sea Road", 18.976250, 72.808440],
["Opera House", 18.960200, 72.819670],
["Oshiwara", 19.150960, 72.845150],
["Parel", 19.012260, 72.844250],
["Pedder Rd", 18.973330, 72.808890],
["Powai", 19.128440, 72.918490],
["Prabhadevi", 19.022940, 72.835490],
["Reay Road E", 18.975350, 72.844310],
["Sahar", 19.103880, 72.874530],
["Saki Naka", 19.105680, 72.885920],
["Santacruz E", 19.087190, 72.858380],
["Santacruz W", 19.091830, 72.838590],
["Satrasta", 18.983860, 72.831960],
["Sewree", 19.992180, 72.853710],
["Shivaji Park", 19.028760, 72.840880],
["Sion E", 19.052570, 72.879220],
["Tardeo", 18.973070, 72.819820],
["Thane w", 19.195890, 72.964170],
["Upper Worli", 19.006180, 72.829630],
["Versova", 19.139260, 72.814090],
["Vidyavihar W", 19.085400, 72.893320],
["Vileparle E", 19.107680, 72.859240],
["Vileparle W", 19.113210, 72.840230],
["Walkeshwar", 18.955260, 72.806870],
["Warden Rd", 18.972200, 72.804950],
["Worli", 19.016680, 72.824030]
];
return a;
}

1
init/buslist.js Normal file

File diff suppressed because one or more lines are too long

2
init/busmaster.js Normal file

File diff suppressed because one or more lines are too long

1
init/stopbus.js Normal file

File diff suppressed because one or more lines are too long

1
init/stopbus.min.js vendored Normal file

File diff suppressed because one or more lines are too long

8
init/stopnames.js Normal file

File diff suppressed because one or more lines are too long

1
init/stopnames.min.js vendored Normal file

File diff suppressed because one or more lines are too long

77
journey.html Normal file
View File

@ -0,0 +1,77 @@
<!DOCTYPE html>
<html>
<head>
<title>BestBus Mumbai - Show Stops</title>
<meta name="viewport" content="user-scalable=no, width=device-width" >
<!--
<link rel="stylesheet" type="text/css" href="css/mobile.css" media="only screen and (max-width: 480px)" >
<link rel="stylesheet" type="text/css" href="css/desktop.css" media="screen and (min-width: 481px)" >
-->
<link rel="stylesheet" type="text/css" href="./css/common.css">
<link rel="stylesheet" type="text/css" href="./lib/jquery/jquery.mobile.min.css">
<script type="text/javascript" src="./lib/jquery/jquery.min.js"></script>
<script type="text/javascript" src="init.js"></script>
<script type="text/javascript" src="./lib/jquery/jquery.mobile.min.js"></script>
<script type="text/javascript" src="libfns.js"></script>
<script type="text/javascript" src="cf.js"></script>
<script type="text/javascript">
busno = gup('b');
if(busno === "")
busno = getCookie('cBusNo');
if(busno === "") {
alert('No Journey selected yet. Select one from the Find Bus tab or the Routes tab');
window.location.href = "index.html";
}
busno = busno.replace(/ /g, "").toLowerCase();
jsfile = decodeURI("%3Cscript src='busroutes\/bcjs" + busno.substr(0,1)
+ ".js' type='text/javascript'%3E%3C/script%3E");
bfile = '<script> function getb() { return getb' + busno + '();}<\/script>';
document.write(jsfile);
document.write(bfile);
</script>
</head>
<!-- <body onLoad='initjourney()> -->
<body>
<div data-role="page" data-theme="a">
<div data-role="header" data-theme="a">
<div data-role="navbar">
<!-- <div id="navigation"> -->
<ul>
<li><a href="index.html" rel="external">Find</a></li>
<li><a href="busesfound.html" rel="external">Routes</a></li>
<!-- <li><a href="busroute.html" rel="external">Routes</a></li> -->
<li><a href="journey.html" rel="external" class="ui-btn-active">Journey</a></li>
</ul>
</div><!-- /navbar -->
</div> <!-- /header -->
<div data-role="content" data-theme="b">
<div style="align:center;" class='hilite' id="routeTitle"></div>
<div id="dispRoute"></div>
<div id="location"></div>
<div id="pastB4"></div>
<div class="hilite">
<div id="nearStop">No location fix as yet</div>
<div id="locAccuracy" style="font-size: 14px;"></div>
</div>
<div id="routeStops"></div>
<!-- <div id="remainingJourney" style="font-size: 16px;"></div>
<div id="journey"></div> -->
<div style='width:98%;line-height:8px;' data-role="collapsible" data-theme="a">
<h5><span id="font-size:14px;">Recent Journeys</h5>
<div id="recentJourneys" class="tbl_color"></div>
</div> <!-- /collapsible -->
</div> <!-- /content -->
</div> <!-- /page -->
</body>
<script type="text/javascript" src="journey.js"></script>
</html>

528
journey.js Normal file
View File

@ -0,0 +1,528 @@
// Shows a bus route with the stops
// Parameters: b - busno (eg. 301 or 2 L), s - start stopno (eg. 2 or 0 for start),
// d - dest stopno (e.g. 25 or 0 for last stop)
/* global $, document, gup */
var dBugLvl = 3;
var stopBusLines = '';
var called_times = 0;
var STOPNO = 0;
var SEARCHSTR = 1;
var NXTDIST = 2;
var NXTTIME = 3;
var LAT = 4;
var LON = 5;
var MAXROUTEDIST = 50;
var MAXSTOPDIST = 2;
var MAXRECENTJOURNEYS = 7;
var geoPos;
var gStartStop = {};
var gDestStop = {};
var gStartStopNo;
var gStartSearchStr;
var gDestStopNo;
var gDestSearchStr;
var total_dist = 0;
var total_time = 0;
var firstStop = 0;
var lastStop = 0;
var arBusStops = [];
var colStart = '';
var colEnd = '<br>';
var dispSize;
var wdth;
var busNo, firstStop, lastStop;
var addJourney = true;
var trackJourney = true;
// var bDir = 'u';
var sDir = 'u';
$(document).ready(function () {
var dispSize, wdth, s, d, startStop, destStop;
dispSize = getWinDim();
wdth = dispSize.wd * 0.98;
if (dispSize.wd > 240) { // Screen too small to display columns
colStart = '<td>';
colEnd = '</td>';
}
busNo = gup('b'); // get URL params
s = gup('s');
d = gup('d');
sDir = gup('dir');
if (s === "" && d === "") {
busNo = getCookie('cBusNo');
s = getCookie('cStartStopNo');
d = getCookie('cDestStopNo');
}
if(busNo === "") {
alert('No Journey selected yet. Select one from the Find Bus tab or the Routes tab');
window.location.href = "index.html";
return;
}
startStop = parseInt(s, 10);
destStop = parseInt(d, 10);
if(startStop > 0 && destStop > 0) {
if(startStop > destStop)
sDir = 'd';
else
sDir = 'u';
}
if(startStop === 0 && destStop === 0)
trackJourney = false; // User is just browsing a route
// dBug('', 'b=' + busNo + ' s = ' + s + ', d = ' + d, 5);
// showBBCookies();
startStop = startStop > 0 ? startStop : 1;
if (startStop === "" && destStop === "") {
document.write('Cannot find a valid start or destination');
return false;
}
gStartStop.stopno = startStop;
gStartStop.searchstr = '';
gDestStop.stopno = destStop;
gDestStop.searchstr = '';
firstStop = startStop > 0 ? startStop : 0;
lastStop = destStop > 0 ? destStop : 0;
dBug('ready: ', 'busno= ' + busNo + ', s ' + startStop + ', d=' + destStop, 5);
document.getElementById("routeTitle").innerHTML = "Bus no.: " + busNo;
// readRouteStopFile(busNo, startStop, destStop);
arBusStops = getb();
dBug('arBusStops: ', arBusStops.length, 5);
// <tr><th>Stop no.</th><th>[Area] Stop name </th><th>Next Stop<br>Dist. (Time)</th></tr>';
var ht = showRouteStops(arBusStops, 0, startStop, destStop);
gStartStopNo = startStop;
gDestStopNo = destStop;
if(addJourney) {
addRecentJourney({'busNo':busNo, 'firstStop':firstStop, 'firstStopName':gStartStop.searchstr,
'lastStop':lastStop, 'lastStopName':gDestStop.searchstr});
addJourney = false;
}
getLocation();
// document.getElementById("journey").innerHTML = "Total distance: " + distFormat(total_dist, MAXROUTEDIST) + " (" + total_time + "&nbsp;mins)";
document.getElementById("routeStops").innerHTML = ht;
return;
});
function initmodule() {
var x;
a = getb();
for (x=0;x<a.length;x++)
document.write( '<br>' + a[x][0] + ", " + a[x][1] + ", " + a[x][2]);
}
// Show route stops in table
function showRouteStops(stops, hlstop, sS, dS) {
var sStop, dStop;
sStop = parseInt(sS);
dStop = parseInt(dS);
var dir = 1;
if(sDir === 'd')
dir = -1;
/*
if(sStop > dStop && dStop) {
bDir = 'd';
dir = -1;
}
*/
if (sStop)
sStop -=1;
if(dStop)
dStop -=1;
if((dStop == 0 || dStop == -1) && dir != -1) {
dStop = stops.length - 1;
lastStop = dStop;
}
stopsHtml = "";
if(hlstop > 0)
hlStyle = 'style="background-color:cyan; color:red;"';
else
hlStyle = '';
var x = sStop;
total_dist = 0; total_time = 0;
if(sStop > dStop) {
firstStop = dStop + 1;
lastStop = sStop + 1;
} else {
firstStop = sStop + 1;
lastStop = dStop + 1;
}
while(true) { // for(var x=0; x < stops.length; x++) {
if(stops[x] != "") {
ar = stops[x];
if(x == hlstop && hlstop != 0)
stopsHtml = stopsHtml + '<tr ' + hlStyle + ' >';
else
stopsHtml = stopsHtml + '<tr>';
if(x+1 == gStartStop.stopno)
gStartStop.searchstr = ar[SEARCHSTR];
if(x == dStop)
gDestStop.searchstr = ar[SEARCHSTR];
mins = "";
// stopsHtml = stopsHtml + colStart + ar[STOPNO] + colEnd;
stopsHtml = stopsHtml + colStart + ar[SEARCHSTR] + colEnd;
met = typeof(ar[NXTDIST]) != "undefined" ? distFormat(parseInt(ar[NXTDIST]), MAXSTOPDIST) : "";
var missingLoc = true;
if(typeof(ar[NXTTIME]) != "undefined" && ar[NXTDIST] < 2000) {
missingLoc = false;
mins = " (" + ar[NXTTIME] + "&nbsp;mins)";
}
stopsHtml = stopsHtml + colStart + met + colEnd;
stopsHtml = stopsHtml + colStart + mins + " ";
stopsHtml = stopsHtml + "</td></tr>";
if(missingLoc) { // if no info, take average distance as 500 m and average time as 3 mins
total_dist += 500;
total_time += 3;
} else {
total_dist += typeof(ar[NXTDIST]) != "undefined" ? parseInt(ar[NXTDIST]) : 0;
total_time += typeof(ar[NXTTIME]) != "undefined" ? parseInt(ar[NXTTIME]) : 0;
}
}
x += dir;
if(x < 0 || x > stops.length)
break;
if(dir < 0 && x < dStop)
break;
if(dir > 0 && x > dStop)
break;
}
if(gDestStop.stopno == 0) {
gDestStop.stopno = x-2;
gDestStop.searchstr = ar[SEARCHSTR];
}
var hdrHtml = '<table class="tbl_color" style="width: ' + wdth + 'px;">'
hdrHtml = hdrHtml + '<tr><th>[Area] Stop name </th><th>Dist. to Next Stop</th><th>Time to Next Stop</th></tr>';
stopsHtml = hdrHtml + stopsHtml + "</table>";
return stopsHtml;
}
/*
// Read the route from server and write to file
function openBusRouteFile(busNo) {
var xmlhttp;
xmlhttp=new XMLHttpRequest();
xmlhttp.open("POST","init/busstoplist.php",false);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("busno=" + busNo + "&s=0&d=0");
return xmlhttp.responseText.split("\n");
}
*/
// Shows the current location and hilites the stop in the stop list
function showLocation(pos) {
dBug('showLocation: ', 'lat: ' + pos.coords.latitude + ', lon: ' + pos.coords.longitude, 5);
// send location to server to identify bus route
called_times++;
var curStopNo = 0;
// var bDir = 'd';
var idxnearstop = -1;
if(arBusStops.length == 0 || pos == undefined) {
document.getElementById("nearStop").innerHTML = 'N/A';;
return;
}
nearStop = "";
locHtml = "";
prvdi = -1;
for(var x=0; x < arBusStops.length; x++) {
if(arBusStops[x] != "") {
ar = arBusStops[x];
if(x == 1) {
firstStop = ar[STOPNO];
firstStopName = ar[SEARCHSTR];
document.getElementById("nearStop").innerHTML = 'First Stop: ' + firstStop;
}
}
// dBug('Stop: ' + x + ' of ' + stopLines.length + ' - ' + ar[SEARCHSTR]);
}
// document.getElementById("myLoc").innerHTML = 'First Stop: ' + firstStop;
lastStop = lastStop > 0 ? lastStop :ar[STOPNO];
// document.getElementById("myLoc").innerHTML = 'Last Stop: ' + lastStop;
// dBug('first: ' + firstStop + ', last: ' + lastStop);
if(pos == undefined)
return;
diTillNearStop = 0;
timeTillNearStop = 0;
// Get nearest stop
for(var x=0; x < arBusStops.length; x++) {
// document.getElementById("myLoc").innerHTML = '';
if(arBusStops[x] == "")
continue;
ar = arBusStops[x];
// document.getElementById("myLoc").innerHTML = 'Stop: ' + x + ' of '
// + arBusStops.length + ' - ' + ar[SEARCHSTR];
dLat = ar[LAT];
dLon = ar[LON];
if(dLat !== 0 && dLon !== 0) {
diNearStop = Math.abs(distanceLatLon(dLat, dLon, pos.coords.latitude, pos.coords.longitude));
if(diNearStop < prvdi || prvdi == -1) {
prvdi = diNearStop;
idxnearstop = x;
arNearStop = ar;
}
diTillNearStop += typeof(ar[NXTDIST]) != "undefined" ? parseInt(ar[NXTDIST]) : 0;
timeTillNearStop += typeof(ar[NXTTIME]) != "undefined" ? parseInt(ar[NXTTIME]) : 0;
}
}
diNearStop = prvdi;
var maxStop = firstStop;
var minStop = lastStop;
var locationFound = true;
var nowMs = new Date();
var fixTime = new Date(pos.timestamp);
var fixAge = nowMs - fixTime;
// dBug('fixms' + pos.timestamp + ', time:' + fixTime + ' Now:' + nowMs);
if ( typeof showLocation.called_times == 'undefined' ) {
// first time, define static vars lat and lon
called_times = 0;
dLat = 0;
dLon = 0;
// return;
}
if(firstStop < lastStop) {
// bDir = 'u';
minStop = firstStop;
maxStop = lastStop;
}
var pastDestination = false;
var beforeStart = false;
var beforeMsg = "<span id='before'>Journey hasn't started</span>";
var pastMsg = "<span id='past'>You have passed your destination, please get down when bus stops</span>";
var atMsg = "<span id='at' Reached. Please alight when bus stops<div></span>";
var myLoc = '';
var htmLocInfo = "<tr>" + colStart +
"(Location Accuracy - " + distFormat(pos.coords.accuracy, MAXROUTEDIST) + ", at " +
timeStr(fixTime) + ") " + colEnd + "</tr>";
if(prvdi != -1) {
// document.getElementById("myLoc").innerHTML = 'Found location ....';
try {
// document.getElementById("myLoc").innerHTML = 'Processing location ....';
if(sDir == 'u') {
if(arNearStop[STOPNO] < minStop || diNearStop > 2000) // proably far away 2 km from any stop
beforeStart = true;
if(arNearStop[STOPNO] > maxStop)
pastDestination = true;
} else {
if(arNearStop[STOPNO] < minStop)
pastDestination = true;
if(arNearStop[STOPNO] > maxStop)
beforeStart = true;
}
sDiNearStop = diNearStop != undefined ? distFormat(diNearStop, 5) : "N/A";
var elm = "Nearest stop: " + arNearStop[STOPNO] + ". " + arNearStop[SEARCHSTR] + " (" +
sDiNearStop + ") " ;
myLoc = myLoc + elm;
myLoc = '<table style="width: ' + wdth + 'px;">' + myLoc + htmLocInfo + '</table>';
myLoc = myLoc + colEnd + '</tr>';
var stops_remaining = Math.abs(lastStop - arNearStop[STOPNO]);
var bc = ''; // background color for remaining stops\
var almostthere = '';
if(stops_remaining <= 2) {
bc = "id='neardest'"
if(stops_remaining < 1 ) {
almostthere = '<span id="at">Please Alight</span>';
myLoc = atMsg + myLoc;
} else {
almostthere = '<span>(Almost There)</span>';
}
}
var d = Math.abs(total_dist - diTillNearStop);
remJourney = '';
rem_time = Math.abs(total_time - timeTillNearStop);
nearStop = myLoc;
if(pastDestination) {
myLoc = pastMsg + myLoc;
pastB4 = pastMsg;
}
else if(beforeStart) {
myLoc = beforeMsg + myLoc;
pastB4 = beforeMsg;
}
else
if(stops_remaining > 0) {
myLoc = myLoc + '<tr ' + bc + '>' + colStart + 'Remaining ' + almostthere +
colEnd + colStart + stops_remaining + ' Stops, '
+ distFormat(d, MAXROUTEDIST) + ", " + rem_time
+ ' min. ' + colEnd + '</tr>';
remJourney = 'Remaining ' + almostthere + stops_remaining + ' Stops, '
+ distFormat(d, MAXROUTEDIST) + ", " + rem_time
+ ' min. ';
}
} catch(e) {
$("location").innerHTML = myLoc;
return;
}
myLoc = '<div id="loc"><table style="width: ' + wdth + 'px;">' + myLoc + '</table></div>'
// document.getElementById("myLoc").innerHTML = myLoc;
}
ht = showRouteStops(arBusStops, idxnearstop, gStartStopNo, gDestStopNo);
document.getElementById("routeStops").innerHTML = ht;
locAccur = "(Location Accuracy - " + distFormat(pos.coords.accuracy, MAXROUTEDIST) +
", at " + timeStr(fixTime) + ") " + colEnd + "</tr>";
nearStop = elm;
// $('#pastB4').html(pastB4);
$('#nearStop').html(nearStop);
$('#locAccuracy').html(locAccur);
// $('#remainingJourney').html(remJourney);
/* +
distFormat(pos.coords.accuracy, MAXROUTEDIST) + ", at " +
timeStr(fixTime) + ") " + colEnd + "</tr>";
*/
// send location to server to identify bus route
if(trackJourney)
sendBusInfo(busNo, pos, arNearStop, sDir);
return;
// dBug('In showLocation');
// showPosDetails(pos);
} // eofn: showLocation(pos)
function setGeoPos(pos) {
geoPos = pos;
}
function include(arquivo){
//By Fabr<62>cio Magri e Micox
//http://elmicox.blogspot.com/2006/12/include-em-javascript.html
var novo = document.createElement('script');
novo.setAttribute('type', 'text/javascript');
novo.setAttribute('src', arquivo);
document.getElementsByTagName('head')[0].appendChild(novo);
//apos a linha acima o navegador inicia o carregamento do arquivo
//portanto aguarde um pouco at<61> o navegador baix<69>-lo. :)
}
function showStopsMap() {
loc = "http://mesn.org/bestbus/showstopsmap.php?busno=" + busNo + "&s=" + firstStop
+ "&d=" + lastStop;
window.location.href = loc;
return true;
}
// Send the location and bus info to server
function sendBusInfo(busno, pos, arNearBus, dir)
{
var xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
// document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
url = "http://mesn.org/bestbus/svr/sendbusinfo.php?b=" + busno + "&lat="
+ pos.coords.latitude + "&lon=" + pos.coords.longitude
+ '&a=' + pos.coords.accuracy + '&s=' + arNearBus[STOPNO]
+ '&sn=' + arNearBus[SEARCHSTR] + '&d=' + dir;
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
// Add to the list of recent journeys
function addRecentJourney(oJourney) {
var rs = localStorage['recentJourneys'];
var recentJourneysPrv;
if(rs != null)
recentJourneysPrv = JSON.parse(rs);
recentJourneys = null;
var recentJourneys = new Array;
recentJourneys[0] = oJourney;
if(recentJourneysPrv !== null && recentJourneysPrv != undefined) {
for(var i = 0; i < recentJourneysPrv.length; i++) {
if(recentJourneysPrv[i] === undefined || recentJourneysPrv[i] === null)
continue;
// check if already in array, else add
alreadyThere = false;
for(var j = 0; j < recentJourneys.length; j++) {
if(recentJourneys[j].busNo === recentJourneysPrv[i].busNo &&
recentJourneys[j].firstStop === recentJourneysPrv[i].firstStop &&
recentJourneys[j].lastStop === recentJourneysPrv[i].lastStop) {
alreadyThere = true;
break;
}
}
if(!alreadyThere)
recentJourneys[recentJourneys.length] = recentJourneysPrv[i];
}
}
localStorage['recentJourneys']=JSON.stringify(recentJourneys);
showRecentJourneys();
}
function showRecentJourneys() {
if(localStorage['recentJourneys'] === undefined || localStorage['recentJourneys'] === null)
return;
var recentJourneys = JSON.parse(localStorage['recentJourneys']);
recentJourneysStr = '<table id="recentJourneys" class="tbl_color">';
if(recentJourneys === null)
return;
if(recentJourneys.length) {
// recentJourneysStr = '<table id="recentJourneys">';
for(var i = 0; i < recentJourneys.length && i < MAXRECENTJOURNEYS; i++) {
if(recentJourneys[i] !== null && recentJourneys[i] !== undefined
&& typeof(recentJourneys[i]) === 'object') {
elm = '<tr><td><a rel="external" href="journey.html?b=' + recentJourneys[i].busNo +
'&s=' + recentJourneys[i].firstStop + '&d=' + recentJourneys[i].lastStop + '">' +
recentJourneys[i].busNo + '</td><td>' + recentJourneys[i].firstStopName + '</td><td>' +
recentJourneys[i].lastStopName + "</a></td></tr>";
recentJourneysStr = recentJourneysStr + elm;
}
}
recentJourneysStr = recentJourneysStr + '</table>';
document.getElementById("recentJourneys").innerHTML = recentJourneysStr;
}
}

11
jq.css Normal file
View File

@ -0,0 +1,11 @@
/*
* jQuery UI CSS Framework @VERSION
*
* Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Theming
*/
@import "jquery.ui.base.css";
@import "jquery.ui.theme.css";

27
jqmcustom.css Normal file
View File

@ -0,0 +1,27 @@
.ui-collapsible-heading a span.ui-btn {
position: absolute;
right: 6px;
top: 50%;
margin: -12px 0 0 0;
width: 20px;
height: 20px;
padding: 1px 0px 1px 2px;
text-indent: -9999px;
}
.ui-btn-inner {
display: none;
overflow: hidden;
padding: 0.6em 25px;
position: relative;
white-space: nowrap;
}
.ui-btn {
cursor: pointer;
display: none;
margin: 0.5em 5px;
padding: 0;
position: relative;
text-align: center;
}

1
lib/comfuncsmin.js Normal file

File diff suppressed because one or more lines are too long

93
lib/gearsinit.js Normal file
View File

@ -0,0 +1,93 @@
// Copyright 2007, Google Inc.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// 3. Neither the name of Google Inc. nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Sets up google.gears.*, which is *the only* supported way to access Gears.
//
// Circumvent this file at your own risk!
//
// In the future, Gears may automatically define google.gears.* without this
// file. Gears may use these objects to transparently fix bugs and compatibility
// issues. Applications that use the code below will continue to work seamlessly
// when that happens.
(function() {
// We are already defined. Hooray!
if (window.google && google.gears) {
return;
}
var factory = null;
// Firefox
if (typeof GearsFactory != 'undefined') {
factory = new GearsFactory();
} else {
// IE
try {
factory = new ActiveXObject('Gears.Factory');
// privateSetGlobalObject is only required and supported on IE Mobile on
// WinCE.
if (factory.getBuildInfo().indexOf('ie_mobile') != -1) {
factory.privateSetGlobalObject(this);
}
} catch (e) {
// Safari
if ((typeof navigator.mimeTypes != 'undefined')
&& navigator.mimeTypes["application/x-googlegears"]) {
factory = document.createElement("object");
factory.style.display = "none";
factory.width = 0;
factory.height = 0;
factory.type = "application/x-googlegears";
document.documentElement.appendChild(factory);
if(factory && (typeof factory.create == 'undefined')) {
// If NP_Initialize() returns an error, factory will still be created.
// We need to make sure this case doesn't cause Gears to appear to
// have been initialized.
factory = null;
}
}
}
}
// *Do not* define any objects if Gears is not installed. This mimics the
// behavior of Gears defining the objects in the future.
if (!factory) {
return;
}
// Now set up the objects, being careful not to overwrite anything.
//
// Note: In Internet Explorer for Windows Mobile, you can't add properties to
// the window object. However, global objects are automatically added as
// properties of the window object in all browsers.
if (!window.google) {
google = {};
}
if (!google.gears) {
google.gears = {factory: factory};
}
})();

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

18
lib/jquery/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long

9
lib/jquery/jquery.mobile.min.css vendored Normal file

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More