-
Notifications
You must be signed in to change notification settings - Fork 0
/
service-worker.js
45 lines (43 loc) · 1.41 KB
/
service-worker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* This file NEEDS to be in the root directory to give the service worker access to all of the app files.
Service Workers only have permission to the same directory and sub-directories. */
var cacheName = 'glass-rpn-calculator-pwa';
var filesToCache = [
'./',
'./index.html',
'./resources/css/main.css',
'./resources/fonts/lcd_display_grid.ttf',
'./resources/images/themes/bg1.jpg',
'./resources/images/themes/bg2.jpg',
'./resources/images/themes/bg3.jpg',
'./resources/images/themes/bg4.jpg',
'./resources/images/themes/bg5.jpg',
'./resources/images/themes/bg6.jpg',
'./resources/images/themes/bg7.jpg',
'./resources/images/themes/bg8.jpg',
'./resources/images/themes/bg9.jpg',
'./resources/images/themes/bg10.jpg',
'./resources/images/themes/bg11.jpg',
'./resources/js/events.js',
'./resources/js/main.js',
'./resources/js/math.js',
'./resources/js/memory.js',
'./resources/js/stack.js',
'./resources/js/ui.js',
'./resources/js/utility.js'
];
/* Start the service worker and cache all of the app's content */
self.addEventListener('install', function (e) {
e.waitUntil(
caches.open(cacheName).then(function (cache) {
return cache.addAll(filesToCache);
})
);
});
/* Serve cached content when offline */
self.addEventListener('fetch', function (e) {
e.respondWith(
caches.match(e.request).then(function (response) {
return response || fetch(e.request);
})
);
});