-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice.js
70 lines (67 loc) · 2.37 KB
/
service.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const version = "1.13.3";
const cacheId = "FINANCE-" + version;
const files = [
'apps/android-chrome-192x192.png',
'apps/android-chrome-512x512.png',
'apps/apple-touch-icon.png',
'apps/browserconfig.xml',
'apps/favicon-16x16.png',
'apps/favicon-32x32.png',
'apps/favicon-194x194.png',
'apps/favicon.ico',
'apps/icon.svg',
'apps/manifest.json',
'apps/mstile-70x70.png',
'apps/mstile-144x144.png',
'apps/mstile-150x150.png',
'apps/mstile-310x150.png',
'apps/mstile-310x310.png',
'apps/safari-pinned-tab.svg',
'css/fonts/open-sans-regular-a.woff2',
'css/fonts/open-sans-regular-b.woff2',
'css/fonts/open-sans-regular-c.woff2',
'css/fonts/open-sans-regular-d.woff2',
'css/fonts/open-sans-regular-e.woff2',
'css/fonts/open-sans-regular-f.woff2',
'css/fonts/open-sans-regular-g.woff2',
'css/images/github.svg',
'css/images/paypal.svg',
'css/fonts.css',
'css/layout.css',
'js/model/payment.js',
'js/model/recurrence.js',
'js/model/template.js',
'js/utils/extensions.js',
'js/utils/encryption.js',
'js/utils/guid.js',
'js/dialogs.js',
'js/engine.js',
'js/storage.js',
'js/strings.js',
'js/ui.js',
'favicon.ico',
'./',
'index.html'
];
const cdnFiles = [{
'url': 'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.bundle.min.js',
'sri': 'sha256-MZo5XY1Ah7Z2Aui4/alkfeiq3CopMdV/bbkc/Sh41+s='
}];
self.addEventListener('install', e => e.waitUntil(
caches.open(cacheId).then(async cache => {
await cache.addAll(files);
for (let f = 0; f < cdnFiles.length; f++) {
let request = new Request({
method: "GET",
url: cdnFiles[f].url,
integrity: cdnFiles[f].sri,
mode: "cors",
credentials: "omit",
cache: "default"
});
let response = await fetch(cdnFiles[f].url, request);
await cache.put(request, response);
}
})));
self.addEventListener('activate', e => e.waitUntil(caches.keys().then(keys => Promise.all(keys.filter(name => name !== cacheId).map(name => caches.delete(name))))));
self.addEventListener('fetch', e => e.respondWith(caches.match(e.request).then(response => response ? response : fetch(e.request))));