diff --git a/games/uptime/manifest.webmanifest b/games/uptime/manifest.webmanifest deleted file mode 100644 index efd5636..0000000 --- a/games/uptime/manifest.webmanifest +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "UPTIME: Incident Response", - "short_name": "UPTIME", - "description": "Survive a datacenter night shift by choosing the right incident response.", - "id": "uptime-incident-response.html", - "start_url": "uptime-incident-response.html", - "scope": "./", - "display": "standalone", - "orientation": "landscape", - "background_color": "#04060c", - "theme_color": "#04060c", - "categories": ["games"], - "icons": [ - { - "src": "favicon/favicon.svg", - "sizes": "any", - "type": "image/svg+xml", - "purpose": "any" - }, - { - "src": "favicon/favicon-192.png", - "sizes": "192x192", - "type": "image/png", - "purpose": "any" - }, - { - "src": "favicon/favicon-512.png", - "sizes": "512x512", - "type": "image/png", - "purpose": "any" - } - ] -} diff --git a/games/uptime/uptime-incident-response.html b/games/uptime/uptime-incident-response.html index c470258..57cd883 100644 --- a/games/uptime/uptime-incident-response.html +++ b/games/uptime/uptime-incident-response.html @@ -4,12 +4,6 @@ UPTIME: Incident Response - - - - - - @@ -1246,12 +1240,6 @@ function endGame(won=false){ state = freshState(); render(); setDifficulty(selectedDifficulty); - -if ('serviceWorker' in navigator) { - window.addEventListener('load', () => { - navigator.serviceWorker.register('../../sw.js'); - }); -} diff --git a/index.html b/index.html index 24d8585..415633a 100644 --- a/index.html +++ b/index.html @@ -4,12 +4,6 @@ SysAdmin Arcade - - - - - - @@ -675,14 +669,8 @@ }) .catch(() => { gameCount.textContent = '?'; - gameGrid.innerHTML = '
Could not load games.json. Serve this directory over HTTP and check the manifest path.
'; + gameGrid.innerHTML = '
Could not load games.json. Serve this directory over HTTP and check the games list path.
'; }); - - if ('serviceWorker' in navigator) { - window.addEventListener('load', () => { - navigator.serviceWorker.register('sw.js'); - }); - } diff --git a/manifest.webmanifest b/manifest.webmanifest deleted file mode 100644 index 0afbf9a..0000000 --- a/manifest.webmanifest +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "SysAdmin Arcade", - "short_name": "Arcade", - "description": "A browser arcade for sysadmins, with installable games for quick maintenance-window breaks.", - "id": "./", - "start_url": "./", - "scope": "./", - "display": "standalone", - "orientation": "any", - "background_color": "#030712", - "theme_color": "#030712", - "categories": ["games", "entertainment"], - "icons": [ - { - "src": "favicon/arcade-favicon-192.png", - "sizes": "192x192", - "type": "image/png", - "purpose": "any" - }, - { - "src": "favicon/arcade-favicon-512.png", - "sizes": "512x512", - "type": "image/png", - "purpose": "any" - } - ] -} diff --git a/sw.js b/sw.js index c21ccdb..135b8f5 100644 --- a/sw.js +++ b/sw.js @@ -1,85 +1,13 @@ -const CACHE_NAME = 'sysadmin-arcade-v2'; - -const PRECACHE_URLS = [ - './', - './index.html', - './games.json', - './manifest.webmanifest', - './favicon/arcade-favicon.ico', - './favicon/arcade-favicon-16.png', - './favicon/arcade-favicon-32.png', - './favicon/arcade-favicon-180.png', - './favicon/arcade-favicon-192.png', - './favicon/arcade-favicon-512.png', - './games/uptime/uptime-incident-response.html', - './games/uptime/manifest.webmanifest', - './games/uptime/favicon/favicon.svg', - './games/uptime/favicon/favicon.ico', - './games/uptime/favicon/favicon-16.png', - './games/uptime/favicon/favicon-32.png', - './games/uptime/favicon/favicon-180.png', - './games/uptime/favicon/favicon-192.png', - './games/uptime/favicon/favicon-512.png' -]; - -const cacheUrl = (path) => new URL(path, self.registration.scope).href; - self.addEventListener('install', (event) => { - event.waitUntil( - caches.open(CACHE_NAME) - .then((cache) => cache.addAll(PRECACHE_URLS.map(cacheUrl))) - .then(() => self.skipWaiting()) - ); + event.waitUntil(self.skipWaiting()); }); self.addEventListener('activate', (event) => { event.waitUntil( caches.keys() - .then((keys) => Promise.all( - keys - .filter((key) => key !== CACHE_NAME) - .map((key) => caches.delete(key)) - )) - .then(() => self.clients.claim()) - ); -}); - -self.addEventListener('fetch', (event) => { - const { request } = event; - const url = new URL(request.url); - - if (request.method !== 'GET' || url.origin !== self.location.origin) return; - - if (request.mode === 'navigate') { - event.respondWith( - fetch(request) - .then((response) => { - const responseCopy = response.clone(); - caches.open(CACHE_NAME).then((cache) => cache.put(request, responseCopy)); - return response; - }) - .catch(async () => { - const fallback = url.pathname.includes('/games/uptime/') - ? './games/uptime/uptime-incident-response.html' - : './index.html'; - - return await caches.match(request) || await caches.match(cacheUrl(fallback)); - }) - ); - return; - } - - event.respondWith( - caches.match(request).then((cachedResponse) => { - if (cachedResponse) return cachedResponse; - - return fetch(request).then((response) => { - if (!response || response.status !== 200 || response.type !== 'basic') return response; - - const responseCopy = response.clone(); - caches.open(CACHE_NAME).then((cache) => cache.put(request, responseCopy)); - return response; - }); - }) + .then((keys) => Promise.all(keys.map((key) => caches.delete(key)))) + .then(() => self.registration.unregister()) + .then(() => self.clients.matchAll({ type: 'window' })) + .then((clients) => clients.forEach((client) => client.navigate(client.url))) ); });