2020-07-12 15:01:42 +02:00
|
|
|
var CACHE_NAME = 'snapdrop-cache-v1.045';
|
2018-10-24 17:43:50 +02:00
|
|
|
var urlsToCache = [
|
|
|
|
'/',
|
|
|
|
'/styles.css',
|
|
|
|
'/scripts/network.js',
|
|
|
|
'/scripts/ui.js',
|
2020-12-20 04:54:19 +01:00
|
|
|
'/scripts/clipboard.js',
|
2020-12-20 22:00:36 +01:00
|
|
|
'/scripts/theme.js',
|
2019-03-12 23:38:32 +01:00
|
|
|
'/sounds/blop.mp3',
|
|
|
|
'/images/favicon-96x96.png'
|
2018-10-24 17:43:50 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
self.addEventListener('install', function(event) {
|
|
|
|
// Perform install steps
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
return fetch(event.request);
|
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|
|
|
|
});
|
2020-05-19 22:52:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
self.addEventListener('activate', function(event) {
|
|
|
|
console.log('Updating Service Worker...')
|
|
|
|
event.waitUntil(
|
|
|
|
caches.keys().then(function(cacheNames) {
|
|
|
|
return Promise.all(
|
|
|
|
cacheNames.filter(function(cacheName) {
|
|
|
|
// Return true if you want to remove this cache,
|
|
|
|
// but remember that caches are shared across
|
|
|
|
// the whole origin
|
|
|
|
return true
|
|
|
|
}).map(function(cacheName) {
|
|
|
|
return caches.delete(cacheName);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|