-
Notifications
You must be signed in to change notification settings - Fork 0
/
sw.js
109 lines (101 loc) · 2.41 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
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
var inlineEx={
"examples": [
{
"name": "All The Places",
"loc": "examples/atp/",
"align": "align.json",
"sound": "atp_vocals.mp3",
"images": true,
"bpm": 72.22,
"offset": -1.15,
"audio_duration": 30.0
},{
"name": "Runs in the Family",
"loc": "examples/palmer/",
"align": "align.json",
"sound": "a.wav",
"images": true,
"bpm": 55.5,
"offset": -0.65,
"audio_duration": 30.0
},
{
"name": "All Star - clip",
"loc": "examples/allstar/",
"align": "align.json",
"sound": "source_v2.wav",
"images": true,
"bpm": 104,
"offset": -0.4,
"audio_duration": 9.65
},{
"name": "All Star - google TTS",
"loc": "examples/allstar-gtts/",
"align": "align.json",
"sound": "a.wav",
"images": true,
"bpm": 104,
"offset": -0.4,
"audio_duration": 12.31
},{
"name": "hogs_espeak",
"loc": "examples/hogs_espeak/",
"align": "align.json",
"sound": "a.wav",
"images": false,
"bpm": 104,
"offset": -0.4,
"audio_duration": 10.12
},{
"name": "hogs_gtts",
"loc": "examples/hogs_gtts/",
"align": "align.json",
"sound": "a.wav",
"images": false,
"bpm": 104,
"offset": -0.4,
"audio_duration": 12.64
},
{
"name": "Hogs Start Coming",
"loc": "examples/hogstar/",
"align": "align.json",
"sound": "feral_hogs.wav",
"images": true,
"bpm": 104,
"offset": -0.4,
"audio_duration": 9.65
}]
};
var cachable=[
// 'index.html',
'style.css',
// 'loader.js',
// 'editor.js',
'examples/examples.json'
];
examples = inlineEx['examples'] || [];
examples.forEach(function(ex) {
cachable.push(ex['loc']+ex['align']);
// cachable.push(ex['loc']+ex['sound']);
if(ex['images']){
cachable.push(ex['loc']+"spectrogram.png");
cachable.push(ex['loc']+"waveform.png");
}
});
// console.log(cachable);
self.addEventListener('install', function(e) {
e.waitUntil(
caches.open('video-store').then(function(cache) {
return cache.addAll(cachable);
})
);
});
self.addEventListener('fetch', function(e) {
console.log(e.request.url);
e.respondWith(
caches.match(e.request).then(function(response) {
return response || fetch(e.request);
})
);
});