myadhd/site/sw.js
djg 453ae9c8a0 fix: address remaining QA bugs — timer reset, ARIA, SW cache, og:url
BUG 2 — Timer not reset after mark-done: extract timerReset() and call
  it after marking a step done so the timer is ready for the next step
BUG 4 — ARIA tabpanel linking: add id/aria-controls on tabs,
  aria-labelledby on panels
BUG 6 — SW missing icons: add icon-192.png and icon-512.png to cache
  list, bump cache version to v2
BUG 7 — og:url: add missing meta tag
2026-09-23 02:25:59 +00:00

32 lines
842 B
JavaScript

/* myadhd.dev — service worker for offline PWA */
var CACHE = 'myadhd-v2';
var ASSETS = [
'/',
'/index.html',
'/static/style.css',
'/static/app.js',
'/static/favicon.svg',
'/static/icon-192.png',
'/static/icon-512.png',
'/manifest.json'
];
self.addEventListener('install', function (e) {
e.waitUntil(caches.open(CACHE).then(function (c) { return c.addAll(ASSETS); }));
self.skipWaiting();
});
self.addEventListener('activate', function (e) {
e.waitUntil(
caches.keys().then(function (names) {
return Promise.all(names.filter(function (n) { return n !== CACHE; }).map(function (n) { return caches.delete(n); }));
})
);
self.clients.claim();
});
self.addEventListener('fetch', function (e) {
e.respondWith(
caches.match(e.request).then(function (r) { return r || fetch(e.request); })
);
});