-
Notifications
You must be signed in to change notification settings - Fork 0
/
service_worker.js
59 lines (53 loc) · 1.57 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
const cacheName = 'v1';
const filesToCache = [
'index.html',
'offline.html',
'./',
'./src/css/style.css',
'./src/css/contextmenu.css',
'./src/js/jquery.fcup.js',
'./src/js/tinylib.js',
'./src/js/offline.js',
'./src/js/longpress.min.js',
'./src/images/Actions-document-save-as-icon.png',
'./src/images/Button-Refresh-icon.png',
'./src/images/file.png',
'./src/images/icons8-menu-rounded-50.png',
'./src/images/rar-icon.png',
'./src/images/Other-html-5-icon.png',
'./src/images/css-3-icon.png',
'./src/images/javascript--v1.png',
'./src/images/Microsoft-Office-Word-icon.png',
'./src/images/app-json-icon.png',
'./src/images/open-folder.png',
'./src/images/Sql-runner-icon.png',
'./src/images/text-x-javascript-icon.png',
'./src/images/text-x-python-icon.png',
'./src/images/zip-icon.png',
'./src/images/loading_simple.gif',
'./src/images/Mimetype-php-icon.png',
'./src/images/Settings-icon.png',
];
// the event handler for the install event
// typically used to cache assets
self.addEventListener('install', e => {
e.waitUntil(
caches.open(cacheName)
.then(cache => cache.addAll(filesToCache))
);
});
// the event handler for the activate event
self.addEventListener('activate', e => {
return self.clients.claim()
});
// the fetch event handler, to intercept requests and serve all
// static assets from the cache
self.addEventListener('fetch', e => {
e.respondWith(
caches.match(e.request)
.then(response => response ? response : fetch(e.request))
.catch( err =>{
return caches.match('offline.html')
})
)
});