-
Notifications
You must be signed in to change notification settings - Fork 0
/
service-worker.js
executable file
·116 lines (111 loc) · 2.75 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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
var files = [
'index.php',
'lib.php',
'admin.php',
'login.php',
'conn.php',
'graph.php',
'manifest.json',
'files.json',
'logout.php',
'service-worker.js',
'verifLogin.php',
'css/estilo.css',
'css/c3.min.css',
'css/bootstrap.min.css',
'css/font-awesome.min.css',
'css/bootstrap.css',
'css/tether.min.css',
'fonts/fontawesome-webfont.eot',
'fonts/fontawesome-webfont.svg',
'fonts/fontawesome-webfont.ttf',
'fonts/fontawesome-webfont.woff',
'fonts/fontawesome-webfont.woff2',
'fonts/FontAwesome.otf',
'img/bg.png',
'img/ico.png',
'js/app.js',
'js/bootstrap.js',
'js/bootstrap.min.js',
'js/c3.min.js',
'js/d3.min.js',
'js/graph.js',
'js/install.js',
'js/jquery.min.js',
'js/spin.js',
'js/tether.min.js',
'less/animated.less',
'less/bordered-pulled.less',
'less/core.less',
'less/fixed-width.less',
'less/font-awesome.less',
'less/icons.less',
'less/larger.less',
'less/list.less',
'less/mixins.less',
'less/path.less',
'less/rotated-flipped.less',
'less/screen-reader.less',
'less/stacked.less',
'less/variables.less',
'scss/_animated.scss',
'scss/_bordered-pulled.scss',
'scss/_core.scss',
'scss/_fixed-width.scss',
'scss/_icons.scss',
'scss/_larger.scss',
'scss/_list.scss',
'scss/_mixins.scss',
'scss/_path.scss',
'scss/_rotated-flipped.scss',
'scss/_screen-reader.scss',
'scss/_stacked.scss',
'scss/_variables.scss',
'scss/font-awesome.scss'
];
// dev only
if (typeof files == 'undefined') {
var files = [];
} else {
files.push('./');
}
var CACHE_NAME = 'project_frozen1';
self.addEventListener('activate', function(event) {
console.log('[SW] Activate');
event.waitUntil(
caches.keys().then(function(cacheNames) {
return Promise.all(
cacheNames.map(function(cacheName) {
if (CACHE_NAME.indexOf(cacheName) == -1) {
console.log('[SW] Delete cache:', cacheName);
return caches.delete(cacheName);
}
})
);
})
);
});
self.addEventListener('install', function(event){
console.log('[SW] Install');
event.waitUntil(
caches.open(CACHE_NAME).then(function(cache) {
return Promise.all(
files.map(function(file){
return cache.add(file);
})
);
})
);
});
self.addEventListener('fetch', function(event) {
console.log('[SW] fetch ' + event.request.url)
event.respondWith(
caches.match(event.request).then(function(response){
return response || fetch(event.request.clone());
})
);
});
self.addEventListener('notificationclick', function(event) {
console.log('On notification click: ', event);
clients.openWindow('/');
});