Skip to content

Commit

Permalink
Add Long Distance Filter
Browse files Browse the repository at this point in the history
Added a long distance filter so only long distance trains are being shown.
  • Loading branch information
root committed Mar 29, 2021
1 parent 7101a05 commit 975e83c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
3 changes: 0 additions & 3 deletions idklol.exe.pdf.css.html.docx.ini

This file was deleted.

4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@

<form class="search">
<input id="search" type="text" class="inputbox" name="destination" placeholder="Suche"> <button action="submit" class="sbb-button">Verbindungen suchen ➜</button>
<input type="checkbox" name="filter" id="Swiss" value="Swiss">
<input type="checkbox" name="filter" id="Swiss" value="swiss">
<label for="Swiss">Swiss only</label>
<input type="checkbox" name="filter" id="long-distance" value="long">
<label for="Swiss">Only long-distance transport</label>
<label for="long-distance">Only long-distance transport</label>
</form>
<br />
<div class="connection">
Expand Down
21 changes: 20 additions & 1 deletion js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ $( ".time" ).hide();
if (urlParams.get("destination") !== null) {
//Set Search box Value to Destination
document.getElementById("search").value = urlParams.get("destination");

if(urlParams.get("filter")=="long") { document.getElementById("long-distance").checked = true; }
//New Request
var xhttp = new XMLHttpRequest();
//On Request Done
Expand All @@ -42,10 +44,27 @@ if (urlParams.get("destination") !== null) {
var numPlatforms = [];
//Loop through the Stationboard
for (x in stationboard) {

//Train is added by default
addTrain=true;

//Shit train filter
//Get "Long PArameter"
if (urlParams.get("filter")=="long"){
//Check if not a shit train
if (stationboard[x]["category"]!=="S" && stationboard[x]["category"]!=="R" && stationboard[x]["category"]!=="RE" && stationboard[x]["category"]!=="TER") {
console.log("Nice Train ("+stationboard[x]["category"]+")")
}else {
//Don't Add the Shit train
console.log("Shit train")
addTrain=false;
}
}

//Get the Current Platform
currentPlatform = parseInt(stationboard[x]["stop"]["platform"]);
//Ignore Trams and Stuff
if (String(currentPlatform)!="NaN"){
if (String(currentPlatform)!="NaN" && !addTrain == false){
//If Key for Platform doesn't exist in Platforms Array
if (!platforms.hasOwnProperty(currentPlatform)) {
//Create Sub-Array for the current Platform
Expand Down

0 comments on commit 975e83c

Please sign in to comment.