Files
JGA-2026/sw.js
T
Hermes AI Bot dc58d2f7c1 Feature 17 + 19: Strafen-Generator + Memory-Buch
Neu:
- strafen.html: 50 kuratierte Strafen (24 Common, 15 Uncommon, 8 Rare,
  3 Legendary) mit Tier-Würfel-Mechanik (60/25/10/5%), Pool-Editor
  (an/aus pro Strafe, eigene Strafen hinzufügbar, löschen),
  Tier-Filter, Würfel-History, Statistik, Ziel-Person-Wahl
  (Bräutigam/Zufällig/Gruppe), Skip-Button, Würfel-Spin-Animation.
- memory.html: Digitales Gästebuch. Setup-Wizard für Mitreisende
  (Name + Farbe + Emoji), Foto-Upload mit Auto-Resize auf 1200px
  (Canvas-API), Text-Einträge, Mood-Picker, Location-Tagging
  (12 JGA-Locations), Tag-System, 7 Emoji-Reactions, Threaded
  Comments, Filter (Alle/mit Fotos/pro Autor), JSON-Export/Import
  als Backup, Storage-Warnung bei <500 KB frei.

Update:
- sw.js: strafen.html + memory.html gecacht, Cache v2->v3.

Nicht verlinkt auf index.html oder anderswo — User-Review vor
Freigabe. Beide Seiten teilen das Theme-Toggle-System mit den
bestehenden 5 Seiten.
2026-06-27 09:15:42 +00:00

74 lines
2.1 KiB
JavaScript

// JGA Prag 2026 — Service Worker
// Cache-Strategie: cache-first für HTML/Assets, network-first für externe APIs (OSRM)
const CACHE_VERSION = 'jga-2026-v3';
const CORE_ASSETS = [
'./',
'./index.html',
'./tourenplan.html',
'./tourenplan-mit-tram.html',
'./wetter.html',
'./packliste.html',
'./countdown.html',
'./trinkspiel.html',
'./strafen.html',
'./memory.html',
'./manifest.json'
];
// Install: alle Core-Files cachen
self.addEventListener('install', (event) => {
event.waitUntil(
caches.open(CACHE_VERSION)
.then(cache => cache.addAll(CORE_ASSETS))
.then(() => self.skipWaiting())
);
});
// Activate: alte Caches aufräumen
self.addEventListener('activate', (event) => {
event.waitUntil(
caches.keys()
.then(keys => Promise.all(
keys.filter(k => k !== CACHE_VERSION).map(k => caches.delete(k))
))
.then(() => self.clients.claim())
);
});
// Fetch: cache-first für eigene Files, network-first für externe APIs
self.addEventListener('fetch', (event) => {
const url = new URL(event.request.url);
// Externe APIs (OSRM, OpenStreetMap, Wetter) → network-first
if (url.origin !== self.location.origin) {
event.respondWith(
fetch(event.request)
.then(response => {
// Erfolgreich: clone & cache für offline
if (response.ok && (url.hostname.includes('openstreetmap') ||
url.hostname.includes('cartocdn') ||
url.hostname.includes('unpkg'))) {
const clone = response.clone();
caches.open(CACHE_VERSION).then(c => c.put(event.request, clone));
}
return response;
})
.catch(() => caches.match(event.request))
);
return;
}
// Eigene Files → cache-first
event.respondWith(
caches.match(event.request)
.then(cached => cached || fetch(event.request)
.then(response => {
if (response.ok) {
const clone = response.clone();
caches.open(CACHE_VERSION).then(c => c.put(event.request, clone));
}
return response;
})
)
);
});