add offline functionality by making this a PWA

- added favicons
- added manifest
- split javascript into main.js and elevators.js
This commit is contained in:
kritzl 2024-06-08 23:12:00 +02:00
parent 192e59d9f8
commit e72ad0cf07
15 changed files with 257 additions and 34 deletions

View file

@ -6,11 +6,6 @@ let geolocationPermission = false;
let geolocation = null;
const openStations = new Set();
let sortByDistance = false;
const version = '0.5.2'
const minorVersion = version.split('.').splice(0, 2).join('.');
const numberFormat = new Intl.NumberFormat('de-DE', {
maximumFractionDigits: 1
});
const substituteData = [
{
@ -87,14 +82,6 @@ const substituteData = [
},
]
Object.defineProperty(String.prototype, 'capitalize', {
value: function () {
return this.charAt(0).toUpperCase() + this.toLowerCase().slice(1);
},
enumerable: false
});
async function loadElevators() {
document.querySelector('#errorMessage').classList.add('hidden');
const res = await fetch('https://www.hvv.de/elevators', {
@ -203,12 +190,6 @@ async function loadElevators() {
}));
}
const dateTimeStyle = new Intl.DateTimeFormat('de-DE', {
dateStyle: 'medium',
timeStyle: 'medium',
timeZone: 'Europe/Berlin',
})
async function loadOsmData() {
const nodeIdList = [];
for (const station of internalData.stations) {
@ -726,21 +707,6 @@ document.querySelectorAll('button.typeChip').forEach(e => {
})
})
function openDialog(selector) {
document.querySelector('body').classList.add('has-dialog')
document.querySelector('#dialog_layer').classList.add('active')
document.querySelector(selector).classList.remove('hidden')
}
function closeDialog(selector) {
document.querySelector('body').classList.remove('has-dialog')
document.querySelector('#dialog_layer').classList.remove('active')
document.querySelector(selector).classList.add('hidden')
}
// set version
document.querySelector('#version').innerHTML = `v${version}`;
// data api version check
const check_internal = JSON.parse(localStorage.getItem("internal_data"));
const check_osm = JSON.parse(localStorage.getItem("osm_data"));