1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { route, go, start } from './router.js';
import { ElementById } from './helpers.js';
import { showAlertModal, hideOverlay } from './overlays.js';
import { initSettings, settings } from './settings.js';
import { initDataStorage } from './dataStorage.js';
import { initHafasClient } from './hafasClient.js';
import { searchView } from './searchView.js';
import { journeysView } from './journeysView.js';
import { journeyView } from './journeyView.js';
import { tripView } from './tripView.js';
import { departuresView } from './departuresView.js';
import './assets/style.css';
(async () => {
await initDataStorage();
await initSettings();
await initHafasClient(settings.profile || "db");
hideOverlay();
ElementById('overlay').innerHTML = '';
route(/^\/$/, searchView);
route(/^\/([a-zA-Z0-9]+)\/([a-z]+)$/, journeysView);
route(/^\/j\/([a-z]+)\/(.+)$/, journeyView);
route(/^\/t\/([a-z]+)\/(.+)$/, tripView);
route(/^\/d\/([a-z]+)\/([^/]+)(\/[0-9]+)?$/, departuresView);
route(/^.*$/, async () => {
await showAlertModal('Route not found');
go('/');
});
if (!window.location.hash.length) go('/');
start();
}) ();
if (!isDevServer) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/service-worker.js').then(registration => {
console.log('SW registered: ', registration);
}).catch(registrationError => {
console.log('SW registration failed: ', registrationError);
});
});
}