myadhd/site/sw.js
djg 1506d98b42 feat: Sprint 1 — Make It Real
Track 1 — Fix the foundation (P0):
- Fix dopamine reroll bug (track selected time bucket properly)
- Add 404 page with gentle copy
- Persist timer state across page refresh (localStorage)
- Add ARIA labels, roles, keyboard nav across all tools
- Shame-free microcopy throughout

Track 2 — Connect the flow (P0):
- Break down → 'Start this step' sets One Thing
- One Thing shows step progress (step N of M)
- 'Start timer' from One Thing pre-links context
- Timer completion → 'Mark step done?' prompt
- Done → auto-surface next step with transition
- Full flow: task → break down → focus → complete → next

Track 3 — Sensory rewards (P1):
- Canvas confetti on step/task completion
- Celebration moment when all steps done
- Session counter with warm encouragement
- Streak tracking for dopamine menu

Track 4 — Quality of life (P1-P2):
- PWA: manifest.json, service worker, installable + offline
- Welcome state for first-time visitors
- Keyboard shortcuts (1-4 for tools)
- Pick For Me button on task breaker
- OG image for social sharing
- Proper meta tags for SEO
2026-09-23 02:01:57 +00:00

30 lines
790 B
JavaScript

/* myadhd.dev — service worker for offline PWA */
var CACHE = 'myadhd-v1';
var ASSETS = [
'/',
'/index.html',
'/static/style.css',
'/static/app.js',
'/static/favicon.svg',
'/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); })
);
});