Skip to content

Commit

Permalink
Metrolink departure board automatically updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kylerchin committed Feb 2, 2024
1 parent eeb22a1 commit 95b1390
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -1269,10 +1269,9 @@
}
});
map.on('click', 'intercityrailstopscircle', (events) => {
let displayname = events.features[0].properties.displayname
if (typeof events.features != 'undefined' && (displayname == 'L. A. Union Metrolink' || displayname == 'Los Angeles')) {
fetch('https://backend.catenarymaps.org/metrolinktrackproxy')
function get_metrolink_board() {
//side effect that returns nothing
fetch('https://backend.catenarymaps.org/metrolinktrackproxy')
.then((x) => x.json())
.then((arrivals) => {
selectedStop = {
Expand All @@ -1282,6 +1281,21 @@
sidebarCollapsed = false;
sidebarView = 9998;
});
}
map.on('click', 'intercityrailstopscircle', (events) => {
let displayname = events.features[0].properties.displayname
if (typeof events.features != 'undefined' && (displayname == 'L. A. Union Metrolink' || displayname == 'Los Angeles')) {
get_metrolink_board();
setTimeout(() => {
if (sidebarCollapsed === true) {
//self destruct if the sidebar has been collapsed
clearTimeout(this.timeoutID);
} else {
get_metrolink_board();
}
}, 10_000);
}
});
Expand Down

0 comments on commit 95b1390

Please sign in to comment.