forked from avestech/ggcmaps.github.io
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsw.js
75 lines (73 loc) · 2.51 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
64
65
66
67
68
69
70
71
72
73
74
75
//when updates to the cached files are made, increment CACHE_NAME version
//then place old CACHE_NAME value in line 41 of index.html so that old caches
//are deleted from users browsers
var CACHE_NAME = 'GGCMaps-cache-v1.6.2';
// baseURL is used to switch between hosting structures.
// Set to null ('') for regular hosting
// Set to directory inside Github Pages
var baseURL = '/ggcmaps/';
var urlsToCache = [
baseURL + 'js/script.min.js',
baseURL + 'js/roomNames.json',
baseURL + 'index.html',
baseURL + 'images/bars.svg',
baseURL + 'images/caret-down.svg',
baseURL + 'images/arrow-right.svg',
baseURL + 'images/arrow-left.svg',
baseURL + 'favicon.ico',
baseURL + 'css/styles.css',
baseURL + 'images/launcher-icon-1x.png',
baseURL + 'images/launcher-icon-2x.png',
baseURL + 'images/launcher-icon-3x.png',
baseURL + 'images/launcher-icon-4x.png',
baseURL + 'Building/A/First-Floor.html',
baseURL + 'Building/B/first-floor.html',
baseURL + 'Building/B/second-floor.html',
baseURL + 'Building/B/third-floor.html',
baseURL + 'Building/C/First-Floor.html',
baseURL + 'Building/C/Second-Floor.html',
baseURL + 'Building/W/Ground-Floor.html',
baseURL + 'Building/W/First-Floor.html',
baseURL + 'Building/W/Second-Floor.html',
baseURL + 'Building/D/First-Floor.html',
baseURL + 'Building/D/Second-Floor.html',
baseURL + 'Building/E/First-Floor.html',
baseURL + 'Building/E/Second-Floor.html',
baseURL + 'Building/E/Third-Floor.html',
baseURL + 'Building/F/First-Floor.html',
baseURL + 'Building/F/Second-Floor.html',
baseURL + 'Building/H/First-Floor.html',
baseURL + 'Building/H/Second-Floor.html',
baseURL + 'Building/H/Third-Floor.html',
baseURL + 'Building/I/First-Floor.html',
baseURL + 'Building/I/Second-Floor.html',
baseURL + 'Building/I/Third-Floor.html',
baseURL + 'Building/L/First-Floor.html',
baseURL + 'Building/L/Second-Floor.html',
baseURL + 'Building/L/Third-Floor.html',
baseURL + 'help.html',
baseURL + "campusEvents.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);
}
)
);
});