var VERSION = "1.0.1";
var CACHE_NAME = 'fireworks-cache-v' + VERSION;
var urlsToCache = [
  'index.html',
  'elements/card.html',
  'elements/counter.html',
  'elements/elements.html',
  'elements/game.html',
  'elements/gamecontroller.html',
  'elements/player.html',
  'elements/routing.html',
  'images/board.jpg',
  'images/bombicon.jpg',
  'images/fireworks.png',
  'images/hanabi.jpg',
  'images/hinticon.jpg',
  'scripts/app.js',
  'styles/app-theme.html',
  'styles/main.css'
];

self.addEventListener('install', function(event) {
  event.waitUntil(
    caches.open(CACHE_NAME)
      .then(function(cache) {
        console.log('Opened cache');
        return cache.addAll(urlsToCache);
      })
  );
});

self.addEventListener('fetch', function(event) {
  event.respondWith(
    caches.match(event.request)
      .then(function(response) {
        // Cache hit - return response
        if (response) {
          return response;
        }

        // IMPORTANT: Clone the request. A request is a stream and
        // can only be consumed once. Since we are consuming this
        // once by cache and once by the browser for fetch, we need
        // to clone the response.
        var fetchRequest = event.request.clone();

        return fetch(fetchRequest).then(
          function(response) {
            // Check if we received a valid response
            if(!response || response.status !== 200 || response.type !== 'basic' || event.request.method == 'POST') {
              return response;
            }

            // IMPORTANT: Clone the response. A response is a stream
            // and because we want the browser to consume the response
            // as well as the cache consuming the response, we need
            // to clone it so we have two streams.
            var responseToCache = response.clone();

            caches.open(CACHE_NAME)
              .then(function(cache) {
                cache.put(event.request, responseToCache);
              });

            return response;
          }
        );
      })
    );
});

self.addEventListener('activate', function(event) {

  var cacheWhitelist = [CACHE_NAME];

  event.waitUntil(
    caches.keys().then(function(cacheNames) {
      return Promise.all(
        cacheNames.map(function(cacheName) {
          if (cacheWhitelist.indexOf(cacheName) === -1) {
            return caches.delete(cacheName);
          }
        })
      );
    })
  );
});


importScripts('https://www.gstatic.com/firebasejs/3.5.2/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/3.5.2/firebase-messaging.js');
firebase.initializeApp({
  'messagingSenderId': '168641906858'
});


const messaging = firebase.messaging();

messaging.setBackgroundMessageHandler(function(payload) {
  console.log('Received background message ', payload);
  // Customize notification here
  const notificationTitle = "Fireworks - it's your turn!";
  const notificationOptions = {
    body: 'Other players are waiting for you! Take your turn.',
    icon: '/firebase-logo.png',
    click_action: 'https://fellyeah.dlinkddns.com:80/#!/games/' + payload.data.Game
  };

  return self.registration.showNotification(notificationTitle,
      notificationOptions);
});
@@ -12,17 +12,17 @@
  = %221.0.
-1
+2
 %22;%0Avar C
@@ -763,27 +763,223 @@
 %7B%0A  
-event.respondWith(%0A
+var regex = /client%5C/version$/;%0A  if (event.request.url.match(regex)) %7B%0A    event.respondWith(new Response(VERSION, %7B%0A          headers: %7B'Content-Type': 'text/plain'%7D%0A    %7D));%0A  %7D%0A  else %7B%0A    event.respondWith(%0A  
     
@@ -1004,32 +1004,34 @@
 .request)%0A      
+  
 .then(function(r
@@ -1033,32 +1033,34 @@
 ion(response) %7B%0A
+  
         // Cache
@@ -1086,24 +1086,26 @@
 nse%0A        
+  
 if (response
@@ -1100,32 +1100,34 @@
 if (response) %7B%0A
+  
           return
@@ -1137,35 +1137,39 @@
 sponse;%0A        
+  
 %7D%0A%0A
+  
         // IMPOR
@@ -1227,16 +1227,18 @@
         
+  
 // can o
@@ -1287,16 +1287,18 @@
 ng this%0A
+  
         
@@ -1357,32 +1357,34 @@
 we need%0A        
+  
 // to clone the 
@@ -1393,16 +1393,18 @@
 sponse.%0A
+  
         
@@ -1450,24 +1450,26 @@
 );%0A%0A        
+  
 return fetch
@@ -1489,16 +1489,18 @@
 ).then(%0A
+  
         
@@ -1530,24 +1530,26 @@
             
+  
 // Check if 
@@ -1569,32 +1569,34 @@
  valid response%0A
+  
             if(!
@@ -1703,32 +1703,34 @@
 %7B%0A              
+  
 return response;
@@ -1722,32 +1722,34 @@
 eturn response;%0A
+  
             %7D%0A%0A 
@@ -1751,32 +1751,34 @@
  %7D%0A%0A            
+  
 // IMPORTANT: Cl
@@ -1818,16 +1818,18 @@
  stream%0A
+  
         
@@ -1899,24 +1899,26 @@
             
+  
 // as well a
@@ -1953,32 +1953,34 @@
 sponse, we need%0A
+  
             // t
@@ -2022,24 +2022,26 @@
             
+  
 var response
@@ -2061,32 +2061,34 @@
 ponse.clone();%0A%0A
+  
             cach
@@ -2113,32 +2113,34 @@
 )%0A              
+  
 .then(function(c
@@ -2139,32 +2139,34 @@
 nction(cache) %7B%0A
+  
                 
@@ -2222,21 +2222,25 @@
         
+  
 %7D);%0A%0A
+  
         
@@ -2262,34 +2262,38 @@
 onse;%0A          
-%7D%0A
+  %7D%0A  
         );%0A     
@@ -2297,18 +2297,26 @@
     
+  
 %7D)%0A
+  
     );%0A
+  %7D%0A
 %7D);%0A

Add ability for SW to print out version