
// nb. SW needs a delta change on every site update.

const disabled = true;

const VERSION = 'choose';
const CACHE_NAME = 'cache';
const PRECACHE = [
  '/', '/styles.css', '/elements.js', '/ic_fullscreen_white_24px.svg', '/manifest.json',
  'https://cdn.rawgit.com/GoogleChrome/pwacompat/v1.0.3/pwacompat.min.js',
];

self.addEventListener('activate', ev => {
  // Claim all clients immediately.
  ev.waitUntil(self.clients.claim());
});

self.addEventListener('install', ev => {
  const precache = caches.open(CACHE_NAME).then(cache => {
    const requests = PRECACHE.map(url => {
      // TODO: do we need cors to cache rawgit correctly?
      return fetch(url, {mode: 'cors'}).then(response => {
        if (response.status === 200) {
          cache.put(new Request(url), response);
        } else {
          return Promise.reject('couldn\'t cache: ' + url);
        }
      });
    });
    return Promise.all(requests);
  });
  ev.waitUntil(precache.then(self.skipWaiting()));
});

self.addEventListener('fetch', ev => {
  if (ev.request.method === 'POST') {
    ev.request.text().then(text => {
      console.info('got text', text);
    });
  }

  if (disabled || ev.request.method !== 'GET') {
    return;
  }
  const url = new URL(ev.request.url);
  ev.respondWith(caches.open(CACHE_NAME)
      .then(cache => cache.match(url))
      .then(response => {
        if (!response) {
          if (!url.hostname.match(/google-analytics\.com$/)) {
            console.debug('can\'t serve from cache', ev.request.url);
          }
          return fetch(ev.request);
        }
        return response;
      }));
});

self.addEventListener('message', ev => {
  if (ev.data === 'version') {
    ev.ports[0].postMessage(VERSION);
  }
});

@@ -69,11 +69,12 @@
 d = 
-tru
+fals
 e;%0A%0A
@@ -96,16 +96,19 @@
  'choose
+-v1
 ';%0Aconst
@@ -1030,134 +1030,8 @@
 %3E %7B%0A
-  if (ev.request.method === 'POST') %7B%0A    ev.request.text().then(text =%3E %7B%0A      console.info('got text', text);%0A    %7D);%0A  %7D%0A%0A
   if
@@ -1248,239 +1248,44 @@
     
-if (!response) %7B%0A          if (!url.hostname.match(/google-analytics%5C.com$/)) %7B%0A            console.debug('can%5C't serve from cache', ev.request.url);%0A          %7D%0A          return fetch(ev.request);%0A        %7D%0A        return response
+return response %7C%7C fetch(ev.request)
 ;%0A  

fix sw