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); }); }); }