Skip to content

Commit

Permalink
feat: offline service workers
Browse files Browse the repository at this point in the history
  • Loading branch information
rayhanadev committed Jun 12, 2021
1 parent cfd7c69 commit 75909da
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 54 deletions.
2 changes: 1 addition & 1 deletion offline/index.html

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions service-worker.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const cacheName = 'tether_cache_v1';
const cacheName = 'tether_cache-v2';
const precacheResources = [
'/',
'/offline.html',
'/fonts/Quantico400.woff2',
'/fonts/Quantico700.woff2',
'/fonts/Tulpen-One400.woff2',
'/favicon.ico',
'/',
'/fonts/Quantico400.woff2',
'/fonts/Quantico700.woff2',
'/fonts/Tulpen-One400.woff2',
'/icons/favicon-16x16.png',
'/tether_theme.mp3',
'/libs/font-awesome.min.css',
'/libs/fontawesome-webfont.woff'
];
Expand Down
4 changes: 4 additions & 0 deletions source/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ var DEBUG = window.location.hash === '#DEBUG',
if(window.location.pathname === '/source/') subtitleText = 'Source Development Mode. #OpenSource';
else subtitleText = 'Swing around a ball and cause pure destruction.';

setInterval(function() {
if(!navigator.onLine) subtitleText = 'Offline Mode.';
}, 60000);

cookieExpiryDate.setFullYear(cookieExpiryDate.getFullYear() + 50);
var cookieSuffix = '; expires=' + cookieExpiryDate.toUTCString();

Expand Down
12 changes: 0 additions & 12 deletions source/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,6 @@
});
})();
</script>
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', async () => {
try {
const reg = await navigator.serviceWorker.register('service-worker.js');
console.log('Service worker registered! 😎', reg);
} catch (err) {
console.log('😥 Service worker registration failed: ', err);
}
});
}
</script>
<body>
<noscript>Hey there, this game needs Javascript. Turn it on to experience the excitement!</noscript><canvas id="game"></canvas>
<script src="game.js"></script>
Expand Down
34 changes: 0 additions & 34 deletions source/source-service-worker.js

This file was deleted.

0 comments on commit 75909da

Please sign in to comment.