-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathservice_worker.js
80 lines (77 loc) · 3.21 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
this.addEventListener('install', function(event) {
event.waitUntil(
caches.open('v1').then(function(cache) {
return cache.addAll([
'/jeepney_jump/',
'/jeepney_jump/index.html',
'/jeepney_jump/favicon.ico',
'/jeepney_jump/assets/style.css',
'/jeepney_jump/main.bundle.js',
'/jeepney_jump/lib/index.js',
'/jeepney_jump/lib/asset_manager.js',
'/jeepney_jump/lib/audio_player.js',
'/jeepney_jump/lib/background_object.js',
'/jeepney_jump/lib/bonus.js',
'/jeepney_jump/lib/game_object.js',
'/jeepney_jump/lib/game.js',
'/jeepney_jump/lib/jeepney.js',
'/jeepney_jump/lib/obstacle.js',
'/jeepney_jump/assets/images/bg.jpg',
'/jeepney_jump/assets/images/github.png',
'/jeepney_jump/assets/images/heart.png',
'/jeepney_jump/assets/images/restart.png',
'/jeepney_jump/assets/images/start.png',
'/jeepney_jump/assets/images/background/cloud.png',
'/jeepney_jump/assets/images/background/ground.png',
'/jeepney_jump/assets/images/background_objects/bank.png',
'/jeepney_jump/assets/images/background_objects/church.png',
'/jeepney_jump/assets/images/background_objects/green_building.png',
'/jeepney_jump/assets/images/background_objects/hospital.png',
'/jeepney_jump/assets/images/background_objects/mall.png',
'/jeepney_jump/assets/images/background_objects/palm_tree.png',
'/jeepney_jump/assets/images/background_objects/pink_building.png',
'/jeepney_jump/assets/images/background_objects/videoke_bar.png',
'/jeepney_jump/assets/images/bonuses/lumpia.png',
'/jeepney_jump/assets/images/bonuses/mango.png',
'/jeepney_jump/assets/images/jeepney/jeepney_damage_1.png',
'/jeepney_jump/assets/images/jeepney/jeepney_damage_2.png',
'/jeepney_jump/assets/images/jeepney/jeepney_full_damage.png',
'/jeepney_jump/assets/images/jeepney/jeepney_no_damage.png',
'/jeepney_jump/assets/images/obstacles/motorcycle.png',
'/jeepney_jump/assets/images/obstacles/street_dog.png',
'/jeepney_jump/assets/audio/bonus.wav',
'/jeepney_jump/assets/audio/dog_hit.mp3',
'/jeepney_jump/assets/audio/jeepney_jump.mp3',
'/jeepney_jump/assets/audio/jeepney.mp3',
'/jeepney_jump/assets/audio/lupang_hinirang.mp3',
'/jeepney_jump/assets/audio/motorcycle_hit.mp3'
]);
})
);
});
this.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request).then(function(resp) {
return resp || fetch(event.request).then(function(response) {
caches.open('v1').then(function(cache) {
cache.put(event.request, response.clone());
});
return response;
});
}).catch(function() {
return caches.match('/jeepney_jump/assets/images/start.png');
})
);
});
this.addEventListener('activate', function(event) {
const cacheWhitelist = ['v1'];
event.waitUntil(
caches.keys().then(function(keyList) {
return Promise.all(keyList.map(function(key) {
if (cacheWhitelist.indexOf(key) === -1) {
return caches.delete(key);
}
}));
})
);
});