-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathservice-worker.js
44 lines (42 loc) · 1.36 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
const staticSimonGame = "simon-game-v1";
const assets = [
"/",
"/index.html",
"/style.css",
"/index.js",
"/img/favicon.jpg",
"https://fonts.googleapis.com/css2?family=Inconsolata:wght@500&family=Roboto:wght@300&display=swap",
"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css",
"https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js",
"https://cdn.jsdelivr.net/npm/[email protected]/dist/howler.min.js",
"https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css",
"https://unpkg.com/[email protected]/dist/css/main.min.css",
"https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=whit",
"/sound/stage.wav",
"/sound/level.wav",
"/sound/lose.wav",
"/sound/black.wav",
"/sound/yellow.wav",
"/sound/red.wav",
"/sound/aqua.wav",
"/sound/purple.wav",
"/sound/forestgreen.wav",
"/sound/orange.wav",
"/sound/mediumslateblue.wav",
"/sound/coral.wav",
"/sound/blue.wav",
];
self.addEventListener("install", (installEvent) => {
installEvent.waitUntil(
caches.open(staticSimonGame).then((cache) => {
cache.addAll(assets);
})
);
});
self.addEventListener("fetch", (fetchEvent) => {
fetchEvent.respondWith(
caches.match(fetchEvent.request).then((res) => {
return res || fetch(fetchEvent.request);
})
);
});