2018-08-14 14:30:53 +00:00
|
|
|
var CACHE = 'myMPD-cache-v3.6.0';
|
2018-07-16 17:33:20 +00:00
|
|
|
var urlsToCache = [
|
|
|
|
'/',
|
|
|
|
'/player.html',
|
|
|
|
'/css/bootstrap.min.css',
|
|
|
|
'/css/mpd.css',
|
|
|
|
'/js/bootstrap-native-v4.min.js',
|
|
|
|
'/js/mpd.js',
|
|
|
|
'/js/player.js',
|
|
|
|
'/assets/appicon-167.png',
|
|
|
|
'/assets/appicon-192.png',
|
|
|
|
'/assets/appicon-512.png',
|
|
|
|
'/assets/coverimage-httpstream.png',
|
|
|
|
'/assets/coverimage-notavailable.png',
|
|
|
|
'/assets/favicon.ico',
|
|
|
|
'/assets/MaterialIcons-Regular.eot',
|
|
|
|
'/assets/MaterialIcons-Regular.ttf',
|
|
|
|
'/assets/MaterialIcons-Regular.woff',
|
|
|
|
'/assets/MaterialIcons-Regular.woff2'
|
|
|
|
];
|
|
|
|
|
|
|
|
self.addEventListener('install', function(event) {
|
2018-07-29 22:05:47 +00:00
|
|
|
event.waitUntil(
|
2018-07-29 22:20:22 +00:00
|
|
|
caches.open(CACHE).then(function(cache) {
|
2018-07-29 22:05:47 +00:00
|
|
|
return cache.addAll(urlsToCache);
|
|
|
|
})
|
|
|
|
);
|
2018-07-16 17:33:20 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
self.addEventListener('fetch', function(event) {
|
2018-07-29 22:05:47 +00:00
|
|
|
event.respondWith(
|
|
|
|
caches.match(event.request).then(function(response) {
|
|
|
|
if (response)
|
|
|
|
return response
|
|
|
|
else
|
|
|
|
return fetch(event.request);
|
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|
2018-07-16 17:33:20 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
self.addEventListener('activate', function(event) {
|
|
|
|
event.waitUntil(
|
|
|
|
caches.keys().then(function(cacheNames) {
|
|
|
|
return Promise.all(
|
|
|
|
cacheNames.map(function(cacheName) {
|
2018-07-29 22:05:47 +00:00
|
|
|
if (cacheName != CACHE)
|
2018-07-16 17:33:20 +00:00
|
|
|
return caches.delete(cacheName);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|