forked from M-Labs/web2019
48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
var CACHE_NAME = 'ml-02';
|
|
var urlsToCache = [
|
|
'/css/bootstrap-4.3.1.min.css',
|
|
'/css/styles.css',
|
|
'/js/jquery-3.3.1.slim.min.js',
|
|
'/js/bootstrap-4.3.1.min.js',
|
|
'/js/popper-1.14.7.min.js',
|
|
'/js/hammer-2.0.8.js',
|
|
'/js/three-r76.js',
|
|
'/js/SolveSpaceControls.js',
|
|
'/js/SolveSpaceControls.js',
|
|
'/js/models/kf25.js',
|
|
'/js/models/viewport.js',
|
|
'/js/models/multiport.js',
|
|
'/js/models/chamber.js',
|
|
'/js/models/k526s-body.js',
|
|
'/js/models/k526s-head.js',
|
|
'/js/models/k526s-fixture.js',
|
|
'/js/models/k526s-adapter.js',
|
|
'/js/models/k526s-adapter-assy.js',
|
|
];
|
|
|
|
self.addEventListener('install', function(event) {
|
|
console.log('[SW] Install');
|
|
event.waitUntil(
|
|
caches.open(CACHE_NAME)
|
|
.then(function(cache) {
|
|
console.log('[SW] add to cache');
|
|
return cache.addAll(urlsToCache);
|
|
})
|
|
);
|
|
});
|
|
|
|
self.addEventListener('fetch', function (event) {
|
|
console.log('[SW] Fetch');
|
|
event.respondWith(
|
|
caches.match(event.request).then(function (response) {
|
|
return response || fetch(event.request);
|
|
})
|
|
);
|
|
});
|
|
|
|
self.addEventListener('message', function (event) {
|
|
if (event.data.action === 'skipWaiting') {
|
|
self.skipWaiting();
|
|
caches.delete(CACHE_NAME);
|
|
}
|
|
}); |