From f236b1f9a7b3a984fd539013ba32d93a90e17c2d Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 26 Feb 2017 15:15:21 +0300 Subject: worker: add missing css; only handle requests when offline --- worker.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/worker.js b/worker.js index e2413a4..7bc5337 100644 --- a/worker.js +++ b/worker.js @@ -11,6 +11,7 @@ self.addEventListener('activate', function(event) { 'js/read.js', 'js/offline.js', 'css/read.css', + 'css/index.css', 'offline.html', 'lib/zip.min.js', 'lib/epub.js', @@ -32,9 +33,9 @@ self.addEventListener('activate', function(event) { this.addEventListener('fetch', function(event) { var req = event.request.clone(); - event.respondWith( - caches.match(req).then(function(resp) { - if (!navigator.onLine) { + if (!navigator.onLine) { + event.respondWith( + caches.match(req).then(function(resp) { if (resp) return resp; @@ -45,9 +46,7 @@ this.addEventListener('fetch', function(event) { if (req.url.match("index.php")) { return caches.match("offline.html"); } - } - - return fetch(req); - }) - ); + }) + ); + } }); -- cgit v1.2.3