summaryrefslogtreecommitdiff
path: root/swayback/templates/sw.html
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2018-03-16 14:47:34 +0100
committerLars-Dominik Braun <lars@6xq.net>2018-03-16 14:47:34 +0100
commitd187373fd3b8f3aa16af8998f4e6481bb4505e60 (patch)
tree0726f240ec9af1bd584964e748bbf28098afe2ef /swayback/templates/sw.html
parentd0e031ceff074667516130c58113e1ef7f24fa7a (diff)
downloadswayback-d187373fd3b8f3aa16af8998f4e6481bb4505e60.tar.gz
swayback-d187373fd3b8f3aa16af8998f4e6481bb4505e60.tar.bz2
swayback-d187373fd3b8f3aa16af8998f4e6481bb4505e60.zip
Use JSON-encoded POST body for /raw
Diffstat (limited to 'swayback/templates/sw.html')
-rw-r--r--swayback/templates/sw.html13
1 files changed, 11 insertions, 2 deletions
diff --git a/swayback/templates/sw.html b/swayback/templates/sw.html
index 2abfac2..0735ae9 100644
--- a/swayback/templates/sw.html
+++ b/swayback/templates/sw.html
@@ -24,8 +24,17 @@
/* service workers must be hosted in the same origin (i.e. subdomain) */
navigator.serviceWorker.register('/static/sw.js', {scope: '/'})
.then(function(reg) {
- /* load actual content using the service worker */
- window.location.reload ();
+ /* load actual content using the service worker when done installing */
+ if (reg.installing) {
+ reg.installing.addEventListener ('statechange', function (e) {
+ if (e.target.state !== 'installing') {
+ console.log ('reloading');
+ window.location.reload ();
+ return false;
+ }
+ return true;
+ });
+ }
}).catch(function(error) {
console.log ('sw error', error);
document.getElementById ('unsupported').classList.remove ('hidden');