aboutsummaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2019-12-19 09:23:21 +0000
committerMatthew Somerville <matthew@mysociety.org>2020-02-14 10:38:49 +0000
commit0e80a90bebc12fe381892386f9ffd751edb38d7c (patch)
tree50f5ac13f745f6142c9b6cab726dacda2fb447fe /web
parent43290e5f733b4e88c6b4e5467b7e446a416a4682 (diff)
Initial service worker.
This basic service worker behaves identically to the existing appcache - some static scripts and CSS are cached, any HTML offline instead returns a static HTML page that knows how to show data on stored problems out of localStorage (stored there when /my/planned was visited online). Inspect form submissions will be captured and can be synced back when online. Once feature parity is established, we will then remove appcache, switch from using localStorage to the cache API, and hopefully move all offline support into the service worker.
Diffstat (limited to 'web')
-rw-r--r--web/cobrands/fixmystreet/offline.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/web/cobrands/fixmystreet/offline.js b/web/cobrands/fixmystreet/offline.js
index 4d7c471aa..648375afd 100644
--- a/web/cobrands/fixmystreet/offline.js
+++ b/web/cobrands/fixmystreet/offline.js
@@ -411,9 +411,10 @@ if ($('#offline_list').length) {
}
fixmystreet.offlineBanner.make(true);
} else {
- // Put the appcache manifest in a page in an iframe so that HTML pages
- // aren't cached (thanks to Jake Archibald for documenting this!)
- if (window.applicationCache && window.localStorage) {
+ // If we're using appcache, not a service worker, put the appcache manifest
+ // in a page in an iframe so that HTML pages aren't cached
+ // (thanks to Jake Archibald for documenting this!)
+ if (!('serviceWorker' in navigator) && window.applicationCache && window.localStorage) {
$(document.body).prepend('<iframe src="/offline/appcache" style="position:absolute;top:-999em;visibility:hidden"></iframe>');
}