-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.js
47 lines (45 loc) · 1.17 KB
/
install.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
// Caches the files for installation
self.addEventListener("install", (e) => {
e.waitUntil(
caches
.open("laine-store.23.04.23")
.then((cache) =>
cache.addAll([
"./",
"./index.html",
"./img/laine.png",
"./styles/style.css",
"./styles/codemirror.css",
"./scripts/functions.js",
"./scripts/laine.js",
"./scripts/plots.js",
"./scripts/ui.js",
"./scripts/editor.js",
"./scripts/laine_wasm/laine.js",
"./scripts/laine_wasm/laine.wasm",
"./scripts/laine_wasm/CoolProp_LICENSE",
])
)
);
});
// Delete old cache
self.addEventListener("activate", (event) => {
var cacheKeeplist = ["laine-store.23.04.23"];
event.waitUntil(
caches.keys().then((keyList) => {
return Promise.all(
keyList.map((key) => {
if (cacheKeeplist.indexOf(key) === -1) {
return caches.delete(key);
}
})
);
})
);
});
// Fetch from cache then network
self.addEventListener("fetch", (e) => {
e.respondWith(
caches.match(e.request).then((response) => response || fetch(e.request))
);
});