ebe770fecd
Turn a regular-season-looking Tuesday into a full playoff experience: - Playoff banner with round + day + series + elimination counts, gold/silver Cup theme toggled by body.playoff-mode - Series context on each playoff card: round chip, series score, stake badges (GAME 7, CLINCHER, PIVOTAL), and one-line blurb - Game 7s pin to a new Spotlight section above Live - Playoff OT renders with SUDDEN DEATH badge and pulsing gold border - Client-side OT notifications via bell button in the banner - New /series/<id> drill-down with headline, next-game, and game-by-game history - New /bracket page: 7-column desktop grid, accordion on mobile - Day N banner count auto-anchors on first playoff scoreboard hit - SQLite cache for bracket + per-series schedules, stale-on-failure up to 24h Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
64 lines
1.9 KiB
JavaScript
64 lines
1.9 KiB
JavaScript
const CACHE = 'nhl-scoreboard-v3';
|
|
const PRECACHE = [
|
|
'/',
|
|
'/static/styles.css',
|
|
'/static/script.js',
|
|
'/static/icon-192x192.png',
|
|
'/static/icon-512x512.png',
|
|
'/manifest.json',
|
|
];
|
|
|
|
self.addEventListener('install', event => {
|
|
event.waitUntil(caches.open(CACHE).then(c => c.addAll(PRECACHE)));
|
|
self.skipWaiting();
|
|
});
|
|
|
|
self.addEventListener('activate', event => {
|
|
event.waitUntil(
|
|
caches.keys().then(keys =>
|
|
Promise.all(keys.filter(k => k !== CACHE).map(k => caches.delete(k)))
|
|
)
|
|
);
|
|
self.clients.claim();
|
|
});
|
|
|
|
self.addEventListener('fetch', event => {
|
|
const { pathname } = new URL(event.request.url);
|
|
|
|
// Network-first for the live scoreboard API — stale data is useless
|
|
if (pathname === '/scoreboard') {
|
|
event.respondWith(
|
|
fetch(event.request).catch(() => caches.match(event.request))
|
|
);
|
|
return;
|
|
}
|
|
|
|
// Network-first for bracket + series detail pages; fall back to cache offline
|
|
if (pathname === '/bracket' || pathname.startsWith('/series/')) {
|
|
event.respondWith(
|
|
fetch(event.request).then(response => {
|
|
if (response.ok) {
|
|
const clone = response.clone();
|
|
caches.open(CACHE).then(c => c.put(event.request, clone));
|
|
}
|
|
return response;
|
|
}).catch(() => caches.match(event.request))
|
|
);
|
|
return;
|
|
}
|
|
|
|
// Cache-first for everything else (static assets, shell)
|
|
event.respondWith(
|
|
caches.match(event.request).then(cached => {
|
|
if (cached) return cached;
|
|
return fetch(event.request).then(response => {
|
|
if (response.ok) {
|
|
const clone = response.clone();
|
|
caches.open(CACHE).then(c => c.put(event.request, clone));
|
|
}
|
|
return response;
|
|
});
|
|
})
|
|
);
|
|
});
|