feat: add pwa support
This commit is contained in:
5
app.js
5
app.js
@@ -361,6 +361,11 @@ hasExplicitThemePreference = Boolean(window.localStorage.getItem(THEME_STORAGE_K
|
|||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
startClock();
|
startClock();
|
||||||
renderSearchResults('');
|
renderSearchResults('');
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
|
navigator.serviceWorker.register('service-worker.js').catch((error) => {
|
||||||
|
console.error('Service Worker Registrierung fehlgeschlagen:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (themeToggleButton) {
|
if (themeToggleButton) {
|
||||||
|
BIN
icons/icon-192.png
Normal file
BIN
icons/icon-192.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
icons/icon-512.png
Normal file
BIN
icons/icon-512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
@@ -4,7 +4,14 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Weltze.it — Alle Zeitzonen im Blick</title>
|
<title>Weltze.it — Alle Zeitzonen im Blick</title>
|
||||||
|
<meta name="theme-color" content="#0f172a">
|
||||||
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||||
<link rel="stylesheet" href="styles.css">
|
<link rel="stylesheet" href="styles.css">
|
||||||
|
<link rel="manifest" href="manifest.webmanifest">
|
||||||
|
<link rel="icon" type="image/png" sizes="192x192" href="icons/icon-192.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="512x512" href="icons/icon-512.png">
|
||||||
|
<link rel="apple-touch-icon" href="icons/icon-192.png">
|
||||||
<script defer src="https://umami.due.ren/script.js" data-website-id="4692d3ad-c36a-4fb9-a7f0-182a8fe72a0b"></script>
|
<script defer src="https://umami.due.ren/script.js" data-website-id="4692d3ad-c36a-4fb9-a7f0-182a8fe72a0b"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -51,7 +58,7 @@
|
|||||||
</main>
|
</main>
|
||||||
|
|
||||||
<footer class="site-footer">
|
<footer class="site-footer">
|
||||||
<p>Mit ♥ von <a href="https://andreas.due.ren">Andreas Dueren</a> gebaut · Open Source unter der <a href="LICENSE">MIT-Lizenz</a></p>
|
<p>Mit ♥ von <a href="https://andreas.due.ren">Andreas Dueren</a> gebaut · Quellcode auf <a href="https://git.due.ren/andreas/weltze.it">git.due.ren/andreas/weltze.it</a></p>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script src="zones.js"></script>
|
<script src="zones.js"></script>
|
||||||
|
25
manifest.webmanifest
Normal file
25
manifest.webmanifest
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"name": "Weltze.it — Alle Zeitzonen im Blick",
|
||||||
|
"short_name": "Weltze.it",
|
||||||
|
"description": "Alle Zeitzonen auf einen Blick vergleichen und Termine koordinieren.",
|
||||||
|
"lang": "de",
|
||||||
|
"start_url": "./",
|
||||||
|
"scope": "./",
|
||||||
|
"display": "standalone",
|
||||||
|
"background_color": "#ffffff",
|
||||||
|
"theme_color": "#0f172a",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "icons/icon-192.png",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "any"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "icons/icon-512.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "any maskable"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
56
service-worker.js
Normal file
56
service-worker.js
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
const CACHE_NAME = 'weltzeit-cache-v1';
|
||||||
|
const PRECACHE_RESOURCES = [
|
||||||
|
'./',
|
||||||
|
'./index.html',
|
||||||
|
'./styles.css',
|
||||||
|
'./app.js',
|
||||||
|
'./zones.js',
|
||||||
|
'./manifest.webmanifest',
|
||||||
|
'./icons/icon-192.png',
|
||||||
|
'./icons/icon-512.png'
|
||||||
|
];
|
||||||
|
|
||||||
|
self.addEventListener('install', (event) => {
|
||||||
|
event.waitUntil(
|
||||||
|
caches.open(CACHE_NAME).then((cache) => cache.addAll(PRECACHE_RESOURCES))
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
self.addEventListener('activate', (event) => {
|
||||||
|
event.waitUntil(
|
||||||
|
caches.keys().then((cacheNames) =>
|
||||||
|
Promise.all(
|
||||||
|
cacheNames.map((cacheName) => {
|
||||||
|
if (cacheName !== CACHE_NAME) {
|
||||||
|
return caches.delete(cacheName);
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
self.addEventListener('fetch', (event) => {
|
||||||
|
if (event.request.method !== 'GET') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.respondWith(
|
||||||
|
caches.match(event.request).then((cachedResponse) => {
|
||||||
|
if (cachedResponse) {
|
||||||
|
return cachedResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fetch(event.request)
|
||||||
|
.then((response) => {
|
||||||
|
const responseClone = response.clone();
|
||||||
|
caches.open(CACHE_NAME).then((cache) => {
|
||||||
|
cache.put(event.request, responseClone);
|
||||||
|
});
|
||||||
|
return response;
|
||||||
|
})
|
||||||
|
.catch(() => caches.match('./index.html'));
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
Reference in New Issue
Block a user