-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsw.js
63 lines (61 loc) · 2.01 KB
/
sw.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
var CACHE_NAME = 'ohcounterCashe';
// baseURL is used to switch between hosting structures.
// Set to null ('') for regular hosting
// Set to directory inside Github Pages
var baseURL = '/ohcounter-mycounter/';
var urlsToCache = [
baseURL + 'index.html',
baseURL + 'css/styles.css',
baseURL + 'css/fonts/Marvel/Marvel-Regular.ttf',
baseURL + 'css/fonts/Marvel/Marvel-Regular.woff',
baseURL + 'css/fonts/Marvel/Marvel-Regular.woff2',
baseURL + 'css/fonts/Marvel/OFL.txt',
baseURL + 'css/fonts/Exo_2/Exo2-Bold.tff',
baseURL + 'css/fonts/Exo_2/Exo2-Bold.woff',
baseURL + 'css/fonts/Exo_2/Exo2-Bold.woff2',
baseURL + 'css/fonts/Exo_2/Exo2-Thin.tff',
baseURL + 'css/fonts/Exo_2/Exo2-Thin.woff',
baseURL + 'css/fonts/Exo_2/Exo2-Thin.woff2',
baseURL + 'js/script.min.js',
baseURL + 'images/dice/Coin.svg',
baseURL + 'images/dice/d4.svg',
baseURL + 'images/dice/d6.svg',
baseURL + 'images/dice/d8.svg',
baseURL + 'images/dice/d10.svg',
baseURL + 'images/dice/d12.svg',
baseURL + 'images/dice/d20.svg',
baseURL + 'lib/json/game-list.json',
baseURL + 'lib/json/game-creation-cookie-template.json',
baseURL + 'lib/json/games/MTG-Commander.json',
baseURL + 'lib/json/games/MTG-Standard.json',
baseURL + 'lib/json/games/Munchkin.json',
baseURL + 'lib/json/games/YuGiOh.json',
baseURL + 'template/dice.html',
baseURL + 'template/fab.html',
baseURL + 'template/game-select.html',
baseURL + 'template/num-player-select.html',
baseURL + 'template/game.html'
];
self.addEventListener('install', function(event) {
// Perform install steps
event.waitUntil(
caches.open(CACHE_NAME)
.then(function(cache) {
console.log('Opened cache');
return cache.addAll(urlsToCache);
})
);
});
self.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request)
.then(function(response) {
// Cache hit - return response
if (response) {
return response;
}
return fetch(event.request);
}
)
);
});