blob: 9210c63390f93fa14af0767992e0582e9fd1e339 [file] [log] [blame]
avm9996399bb77c2020-01-27 03:15:08 +01001window.addEventListener("load", _ => {
2 fetch("ajax/api.php?action=stations").then(res => res.json()).then(res => {
3 if (res.status != "ok") throw Error("a");
4
5 var select = document.getElementById("station");
6
7 res.data.forEach(station => {
8 var option = document.createElement("option");
9 option.value = station.stop_id;
10 option.textContent = station.stop_name;
11 select.appendChild(option);
12 });
13
14 select.disabled = false;
15 }).catch(err => console.error(err));
16
17 if ('serviceWorker' in navigator) {
18 navigator.serviceWorker.register('sw.js').then(function(registration) {
19 console.log('ServiceWorker registration successful with scope: ', registration.scope);
20 }, function(err) {
21 console.log('ServiceWorker registration failed: ', err);
22 });
23 }
24});