Skip to content

Commit

Permalink
timetables data processing
Browse files Browse the repository at this point in the history
  • Loading branch information
Ja-Tar committed Aug 31, 2024
1 parent 25cad03 commit eb13c9a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
8 changes: 4 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
<div id="form">
<label for="server">Serwer:</label>
<select id="server">
<option value="pl1">PL1</option>
<option value="pl2">PL2</option>
<option value="de">DE</option>
<option value="cz">CZ</option>
<option value="eu">PL1</option>
<option value="cae">PL2</option>
<option value="" disabled>DE</option>
<option value="" disabled>CZ</option>
</select><br>
<label for="scenery">Sceneria:</label>
<input type="text" id="scenery" placeholder='Stacja'></input>
Expand Down
34 changes: 31 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ window.checkpointData = [];
window.platformsVersionID = "0.0.5"

document.getElementById("submit").addEventListener("click", function () {
buttonSetDisplay();
if (window.timetablesData) {
buttonSetDisplay();
processTimetablesData();
}
});

function buttonSetDisplay() {
Expand Down Expand Up @@ -53,6 +56,32 @@ function getProcessedData(display_id) {
return json;
}

function processTimetablesData() {
// Po kliknięciu przycisku, sprawdza czy dana stacja jest w rozkładzie jazdy pociągu,
// sprawdza który peron, oraz sprawdza który pociąg najwcześniej przyjedzie na stację

let server = document.getElementById("server").value;
let checkpoint = document.getElementById("point").value;

let timetableData = window.timetablesData;

for (let i = 0; i < timetableData.length; i++) {
if (timetableData[i].region === server) {
let timetable = timetableData[i].timetable;

if (timetable) {
let stopList = timetable.stopList;

for (let j = 0; j < stopList.length; j++) {
if (stopList[j].stopNameRAW === checkpoint) {
console.log(stopList[j].stopNameRAW);
}
}
}
}
}
}

function getDataFromAPI() {
let saved = false;
let sceneryInput = document.getElementById("scenery");
Expand All @@ -72,8 +101,7 @@ function getDataFromAPI() {
updateTextScenery();
});
});
//getTimetablesAPI();

getTimetablesAPI()

window.localStorage.setItem("version", window.platformsVersionID);

Expand Down

0 comments on commit eb13c9a

Please sign in to comment.