worktree-citti-arkiver-tur #5
BIN
static/icon-192.png
Normal file
BIN
static/icon-192.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
static/icon-512.png
Normal file
BIN
static/icon-512.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
@@ -9,6 +9,9 @@
|
||||
"background_color": "#f5f2ed",
|
||||
"theme_color": "#c84b2f",
|
||||
"icons": [
|
||||
{ "src": "/icon.svg", "sizes": "any", "type": "image/svg+xml", "purpose": "any maskable" }
|
||||
{ "src": "/static/icon-192.png", "sizes": "192x192", "type": "image/png", "purpose": "any" },
|
||||
{ "src": "/static/icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "any" },
|
||||
{ "src": "/static/icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" },
|
||||
{ "src": "/icon.svg", "sizes": "any", "type": "image/svg+xml", "purpose": "any" }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -71,6 +71,38 @@
|
||||
else { el.style.opacity = '0'; }
|
||||
}
|
||||
|
||||
// ---- Install ("Add to home screen") prompt ----
|
||||
var deferredPrompt = null;
|
||||
function showInstall() {
|
||||
if (!document.body) { document.addEventListener('DOMContentLoaded', showInstall); return; }
|
||||
var b = document.getElementById('citti-install');
|
||||
if (!b) {
|
||||
b = document.createElement('button');
|
||||
b.id = 'citti-install';
|
||||
b.type = 'button';
|
||||
b.textContent = '⬇ Installér app';
|
||||
b.style.cssText = 'position:fixed;left:14px;bottom:14px;z-index:9999;padding:9px 15px;'
|
||||
+ 'border:none;border-radius:20px;background:#1a1814;color:#fff;cursor:pointer;'
|
||||
+ 'font:600 13px/1 system-ui,-apple-system,sans-serif;box-shadow:0 2px 10px rgba(0,0,0,.25)';
|
||||
b.addEventListener('click', function () {
|
||||
if (!deferredPrompt) return;
|
||||
deferredPrompt.prompt();
|
||||
deferredPrompt.userChoice.finally(function () { deferredPrompt = null; b.remove(); });
|
||||
});
|
||||
document.body.appendChild(b);
|
||||
}
|
||||
}
|
||||
window.addEventListener('beforeinstallprompt', function (e) {
|
||||
e.preventDefault(); // keep the event so we can trigger it from our button
|
||||
deferredPrompt = e;
|
||||
showInstall();
|
||||
});
|
||||
window.addEventListener('appinstalled', function () {
|
||||
deferredPrompt = null;
|
||||
var b = document.getElementById('citti-install');
|
||||
if (b) b.remove();
|
||||
});
|
||||
|
||||
window.addEventListener('online', function () { render(); flush(); });
|
||||
window.addEventListener('offline', render);
|
||||
if (document.readyState !== 'loading') { render(); flush(); }
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
// citti service worker — offline shell + asset caching.
|
||||
// Pages: network-first (fresh when online, cached copy in the store).
|
||||
// Assets: cache-first. POSTs are never touched here — the page queues them.
|
||||
const CACHE = 'citti-v1';
|
||||
const CORE = ['/', '/tilbud', '/koeb-nu', '/offline.js', '/manifest.webmanifest', '/icon.svg'];
|
||||
const CACHE = 'citti-v2';
|
||||
const CORE = ['/', '/tilbud', '/koeb-nu', '/offline.js', '/manifest.webmanifest',
|
||||
'/icon.svg', '/static/icon-192.png', '/static/icon-512.png'];
|
||||
|
||||
self.addEventListener('install', (e) => {
|
||||
e.waitUntil(
|
||||
|
||||
Reference in New Issue
Block a user