Skip to content

Commit f34452c

Browse files
committed
trying to make PWA part 9
1 parent 3a8e0af commit f34452c

File tree

3 files changed

+38
-21
lines changed

3 files changed

+38
-21
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
4040

41-
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
41+
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
4242

4343
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js">
4444

index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,9 +1339,15 @@ var app = new Vue({
13391339

13401340
} else {
13411341

1342-
alert("Lost internet connection!")
1342+
if (confirm("No internet connection. Continue?") == true) {
13431343

1344-
return false
1344+
this.loadingHide()
1345+
1346+
} else {
1347+
1348+
return false
1349+
1350+
}
13451351

13461352
}
13471353

serviceWorker.js

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const cacheName = 'TODO';
2+
23
const assets = [
4+
35
'./',
46
'./index.html',
57
'./index.js',
@@ -12,28 +14,37 @@ const assets = [
1214
'https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js',
1315
'https://code.jquery.com/jquery-3.2.1.min.js',
1416
'https://cdn.jsdelivr.net/npm/vue@2.7.0'
17+
1518
]
1619

17-
// Cache all the files to make a PWA
1820
self.addEventListener('install', e => {
19-
e.waitUntil(
20-
caches.open(cacheName).then(cache => {
21-
// Our application only has two files here index.html and manifest.json
22-
// but you can add more such as style.css as your app grows
23-
return cache.addAll(assets);
24-
})
25-
);
21+
22+
e.waitUntil(
23+
24+
caches.open(cacheName).then(cache => {
25+
26+
return cache.addAll(assets);
27+
28+
})
29+
30+
);
31+
2632
});
2733

28-
// Our service worker will intercept all fetch requests
29-
// and check if we have cached the file
30-
// if so it will serve the cached file
3134
self.addEventListener('fetch', event => {
32-
event.respondWith(
33-
caches.open(cacheName)
34-
.then(cache => cache.match(event.request, { ignoreSearch: true }))
35-
.then(response => {
36-
return response || fetch(event.request);
37-
})
38-
);
35+
36+
event.respondWith(
37+
38+
caches.open(cacheName)
39+
40+
.then(cache => cache.match(event.request, { ignoreSearch: true }))
41+
42+
.then(response => {
43+
44+
return response || fetch(event.request);
45+
46+
})
47+
48+
);
49+
3950
});

0 commit comments

Comments
 (0)