mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-11 19:00:00 +01:00
* Add version number to bottom * Get latest version number from GitHub * Create versionManagement.js Fetching the latest and local version number is now done through versionManagement.js * Add popup to prompt for refresh when a new version is available A new version is available whenever the sw.js file is changed. * Add version number fixed in top right corner * Fix Codeclimate issues * Update versionManagement.js * Update versionManagement.js * Make update prompt appear at front of page Changed z-index * Delete unecessary code * Create task to automatically update sw.js Used grunt-text-replace * Uninstall semver * Add replace task to serve and production tasks * Update demo.js Make version statements more descriptive. * Update versionManagement.js Remove unused versionCompare function * Change URL for getting latest version Changed the URL for getting the latest NPM version to be based on the package.json file's attribute for "homepage". * Update index.html * Update demo.css * Added explanatory comments * Update versionManagement.js * Update versionManagement.js * Updates for readability Changed single-line comments to multiline comments. * Update versionManagement.js * Update versionManagement.js Co-authored-by: Harsh Khandeparkar <34770591+HarshKhandeparkar@users.noreply.github.com> Co-authored-by: Jeffrey Warren <jeff@unterbahn.com>
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
const staticCacheName = 'image-sequencer-static-v3.5.1';
|
|
self.addEventListener('install', event => {
|
|
console.log('Attempting to install service worker');
|
|
});
|
|
|
|
self.addEventListener('activate', function(e) {
|
|
console.log('[ServiceWorker] Activate');
|
|
e.waitUntil(
|
|
caches.keys().then(function(cacheNames) {
|
|
return Promise.all(
|
|
cacheNames.filter(function(cacheName){
|
|
return cacheName.startsWith('image-sequencer-') &&
|
|
cacheName != staticCacheName;
|
|
}).map(function(cacheName){
|
|
return caches.delete(cacheName);
|
|
})
|
|
);
|
|
})
|
|
);
|
|
});
|
|
|
|
self.addEventListener('fetch', function(event) {
|
|
event.respondWith(
|
|
caches.open(staticCacheName).then(function(cache) {
|
|
return cache.match(event.request).then(function (response) {
|
|
return response || fetch(event.request).then(function(response) {
|
|
if(event.request.method == 'GET')
|
|
cache.put(event.request, response.clone());
|
|
return response;
|
|
});
|
|
});
|
|
})
|
|
);
|
|
});
|
|
|
|
// When the update modal sends a 'skipWaiting' message, call the skipWaiting method.
|
|
self.addEventListener('message', function(event) {
|
|
if(event.data.action === 'skipWaiting') {
|
|
self.skipWaiting();
|
|
}
|
|
});
|