From d187373fd3b8f3aa16af8998f4e6481bb4505e60 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Fri, 16 Mar 2018 14:47:34 +0100 Subject: Use JSON-encoded POST body for /raw --- swayback/templates/sw.html | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'swayback/templates/sw.html') 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'); -- cgit v1.2.3