Fahrplaninformationssysteme




Aktuelle Fahrten


Linie:      Fahrtage:     Richtung:     

Quelltext:

Im <body>-Tag muss ein onload-Ereignis hinzugefügt werden:

<body onload="runQuery()">

Restlicher Quelltext:

<script> 			
	var oInterval = new Object();
  var lineID;
  var lineName;
  var daygroupID;
  var direction;

function timeToTable(t) { var i,j,k, alti; var v1, v2, v3; var idx1, idx2; var a; var aktTR, newTD, newTDText; var stunde, minute, feld; var aktMinutes; var minInterval, addInterval; var jetzt = new Date(); aktMinutes = jetzt.getHours() * 60 + jetzt.getMinutes(); i = 1; while (i < t.length) { j = 1; v1 = -1; v2 = -1; while (j < t[i].length) { v1 = t[i][j]; if (v1 != -1) { idx1 = j; j = t[i].length; } else { j++; } } j = t[i].length-1; while (j > 0) { v2 = t[i][j]; if (v2 != -1) { idx2 = j; j = 0; } else { j--; } } if ( (v1 < -1) || (v2 < -1) ) { if ( !( (aktMinutes < t[i-1][idx1]) && (aktMinutes > t[i-1][idx2]) && (aktMinutes < t[i+1][idx1]) && (aktMinutes > t[i+1][idx2]) ) ) { minInterval = 10000; for (k = 1; k < t[0].length; k++) { v3 = t[i][k]; if (v3 < -1) { if (oInterval[Math.abs(v3)] < minInterval) { minInterval = oInterval[Math.abs(v3)]; } } } if (minInterval < 10000) { addInterval = 0; alti = i-1; while ((t[i-1][idx1] + minInterval) < t[i+1][idx1]) { a = new Array; a.push(0); addInterval += minInterval; for (k = 1; k < t[0].length; k++) { if ( (t[i+1][k] > -1) && ( (addInterval % oInterval[Math.abs(t[i][k])] ) == 0) ) { a.push(t[alti][k] + addInterval); } else { a.push(-1); } } t.splice(i, 0, a); i++; } t.splice(i, 1); } } } i++; } i = 1; while (i < t.length) { j = 1; v1 = -1; v2 = -1; while (j < t[i].length) { v1 = t[i][j]; if (v1 != -1) { idx = j; j = t[i].length; } else { j++; } } j = t[i].length-1; while (j > 0) { v2 = t[i][j]; j = (v2 != -1) ? 0 : j-1; } if ((aktMinutes < v1) || (aktMinutes > v2)) { t.splice(i,1); } else { i++; } }

for (i=0; i<t[1].length; i++) { aktTR = document.getElementById("mytable").tBodies[0].rows[i]; for (j=1; j<t.length; j++) { newTD = document.createElement("td"); if ( (i>0) && ((i % 2) == 0) ) { newTD.bgColor = "#F0F0F0"; } else { newTD.bgColor = "#E0E0E0"; } if (i == 0) { feld = j; newTD.bgColor = "#CCCCFF"; } else { if (t[j][i] > -1) { stunde = Math.floor(t[j][i] / 60); minute = t[j][i] - (stunde * 60); stunde = ((stunde > 23) ? stunde - 24 : stunde); feld = ((stunde < 10) ? "0" + stunde : stunde); feld = feld + ":" + ((minute < 10) ? "0" + minute : minute); } else if (t[j][i] == -1) { feld = ""; } else if (t[j][i] < -1) { if (t[j][i] > -1000) { feld = "alle " + oInterval[Math.abs(t[j][i])] + " Min."; k = i+1; newTD.bgColor = "#E8E8E8"; newTD.style.textAlign = "center"; a[j] = newTD; while ( (k <t[1].length) && (t[j][k] == t[j][i]) ) { t[j][k] = -1000 - i; k++; } } else { a[j].rowSpan++; } } } if (t[j][i] > -1000) { newTDtext = document.createTextNode(feld); newTD.appendChild(newTDtext); aktTR.appendChild(newTD); } } } }

function stationsToTable(t) { var i; var newTR, newTD, newTDText; publicSQL.htmlTableDelete("mytable") var tb = document.getElementById("mytable"); newTR = tb.insertRow(i); newTD = document.createElement("td"); newTDtext = document.createTextNode(""); newTD.appendChild(newTDtext); newTD.innerHTML = '<b>' + lineName + '</b>'; newTR.appendChild(newTD); for (i=1; i<t.length; i++) { newTR = tb.insertRow(i); newTD = document.createElement("td"); newTDtext = document.createTextNode(""); newTD.appendChild(newTDtext); newTD.innerHTML = '<b>' + t[i][0] + '</b>'; newTD.bgColor = "#CCCCFF"; newTR.appendChild(newTD); } publicSQL.query('select * from tt_' + lineID + '_' + direction + '_' + daygroupID, 'timeToTable'); }

function showTimeTable2(t) { for (var i=1; i<t.length; i++) { oInterval[t[i][0]] = t[i][1]; } publicSQL.query('select s.Station from ttc_' + lineID + ' t, stations s where t.StationID = s.ID and t.DayGroupID = ' + daygroupID + ' and t.Direction = ' + direction + ' order by t.Position', 'stationsToTable'); }

function showTimeTable() { publicSQL.query('select * from intervals', 'showTimeTable2'); }

function runQuery2(t) { var neuer; for (var i=1; i<t.length; i++) { neuer = new Option(t[i][1], t[i][0], false, false); document.fmSelect.sbLines.options[i-1] = neuer; } document.fmSelect.sbLines.selectedIndex = 0; lineID = document.fmSelect.sbLines.options[document.fmSelect.sbLines.selectedIndex].value; lineName = document.fmSelect.sbLines.options[document.fmSelect.sbLines.selectedIndex].text; publicSQL.query('select lc.DayGroupID, lc.Direction, dg.Text from line_connections lc, daygroups dg where lc.LineID = ' + lineID + ' and lc.DayGroupID = dg.ID order by dg.DayGroupID, lc.Direction', 'newDirAndDays'); }

function runQuery() { publicSQL.query('select * from lines order by ID', 'runQuery2'); }

function newDir(t) { var neuer; document.fmSelect.sbDirection.length = 0; for (var i=1; i<t.length; i++) { neuer = new Option(t[i][0], t[i][0], false, false); document.fmSelect.sbDirection.options[document.fmSelect.sbDirection.length] = neuer; } document.fmSelect.sbDirection.selectedIndex = 0; direction = document.fmSelect.sbDirection.options[document.fmSelect.sbDirection.selectedIndex].value; }

function newDirAndDays(t) { var wert; var alt = 0; var neuer; document.fmSelect.sbDays.length = 0; for (var i=1; i<t.length; i++) { wert = t[i][0]; if (wert != alt) { neuer = new Option(t[i][2], wert, false, false); document.fmSelect.sbDays.options[document.fmSelect.sbDays.length] = neuer; } alt = wert; } daygroupID = document.fmSelect.sbDays.options[document.fmSelect.sbDays.selectedIndex].value; publicSQL.query('select lc.Direction from line_connections lc where lc.LineID = ' + lineID + ' and lc.DayGroupID = ' + daygroupID + ' order by lc.Direction', 'newDir'); }

function changeLine() { lineID = document.fmSelect.sbLines.options[document.fmSelect.sbLines.selectedIndex].value; lineName = document.fmSelect.sbLines.options[document.fmSelect.sbLines.selectedIndex].text; publicSQL.query('select lc.DayGroupID, lc.Direction, dg.Text from line_connections lc, daygroups dg where lc.LineID = ' + lineID + ' and lc.DayGroupID = dg.ID order by dg.DayGroupID, lc.Direction', 'newDirAndDays'); }

function changeDays() { daygroupID = document.fmSelect.sbDays.options[document.fmSelect.sbDays.selectedIndex].value; publicSQL.query('select lc.Direction, from line_connections lc where lc.LineID = ' + lineID + ' and lc.DayGroupID = ' + daygroupID + ' order by lc.Direction', 'newDir'); }

function changeDirection() { direction = document.fmSelect.sbDirection.options[document.fmSelect.sbDirection.selectedIndex].value; } </script> <form action="" method="post" name="fmSelect" id="fmSelect"> <strong>Linie:</strong> <select name="sbLines" onChange="changeLine();"> </select> <strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Fahrtage:</strong> <select name="sbDays" id="sbDays" onChange="changeDays()"> </select> <strong>&nbsp;&nbsp;&nbsp;&nbsp;Richtung:</strong> <select name="sbDirection" id="sbDirection" onChange="changeDirection()"> </select> <strong>&nbsp;</strong><strong>&nbsp;</strong><strong>&nbsp;</strong><strong>&nbsp;</strong> <input name="btStart" type="button" id="btStart" onClick="showTimeTable();" value="Start"> <!-- hier kann ein Text zur Abfrage eingefügt werden --> <br><br> </form>

<table id="mytable" border="1"> <tr> <td></td> </tr> </table>

 

 

Impressum: Jörg Siebrands, 21614 Buxtehude (Kreis Stade), Lüneburger Schanze 1
www.ptraffic.net - www.sybrands.de - www.moers-online.de