-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsw.js
More file actions
87 lines (82 loc) · 1.75 KB
/
sw.js
File metadata and controls
87 lines (82 loc) · 1.75 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
/*global caches, fetch, Promise */
(function (worker) {
"use strict";
var PREFIX = 'wallpaper',
VERSION = '1.3',
FILES = [
'index.html',
'style.css',
'pages/cm.html',
'pages/cmm.html',
'pages/p1.html',
'pages/p2.html',
'pages/p3.html',
'pages/p31m.html',
'pages/p3m1.html',
'pages/p4.html',
'pages/p4g.html',
'pages/p4m.html',
'pages/p6.html',
'pages/p6m.html',
'pages/pg.html',
'pages/pgg.html',
'pages/pm.html',
'pages/pmg.html',
'pages/pmm.html',
'pages/q.html',
'pages/q1.html',
'pages/q1n.html',
'pages/q1y.html',
'pages/q2.html',
'pages/q2n.html',
'pages/q2y.html',
'pages/q2yy.html',
'pages/q3.html',
'pages/q3y.html',
'pages/q4.html',
'pages/q4y.html',
'pages/q6.html',
'pages/img/cm.svg',
'pages/img/cmm.svg',
'pages/img/p1.svg',
'pages/img/p2.svg',
'pages/img/p3.svg',
'pages/img/p31m.svg',
'pages/img/p3m1.svg',
'pages/img/p4.svg',
'pages/img/p4g.svg',
'pages/img/p4m.svg',
'pages/img/p6.svg',
'pages/img/p6m.svg',
'pages/img/pg.svg',
'pages/img/pgg.svg',
'pages/img/pm.svg',
'pages/img/pmg.svg',
'pages/img/pmm.svg'
];
worker.addEventListener('install', function (e) {
e.waitUntil(
caches.open(PREFIX + ':' + VERSION).then(function (cache) {
return cache.addAll(FILES);
})
);
});
worker.addEventListener('activate', function (e) {
e.waitUntil(
caches.keys().then(function (keys) {
return Promise.all(keys.map(function (key) {
if (key.indexOf(PREFIX + ':') === 0 && key !== PREFIX + ':' + VERSION) {
return caches.delete(key);
}
}));
})
);
});
worker.addEventListener('fetch', function (e) {
e.respondWith(caches.match(e.request, {ignoreSearch: true})
.then(function (response) {
return response || fetch(e.request);
})
);
});
})(this);