-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9078ba3
commit c206969
Showing
5 changed files
with
50 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
{ | ||
"name": "Text Editor", | ||
"description": "A Simple Text Editor", | ||
"start_url": "/", | ||
"lang": "en-US", | ||
"theme_color": "cornflowerblue", | ||
"display": "standalone", | ||
"icons": [ | ||
{ | ||
"src": "texteditor.png", | ||
"sizes": "72x72", | ||
"type": "image/png" | ||
} | ||
] | ||
} | ||
"name":"Text Editor", | ||
"short_name":"TextEditor", | ||
"start_url":"texteditor.html", | ||
"display":"standalone", | ||
"background_color":"lightblue", | ||
"theme_color":"cornflowerblue", | ||
"scope": ".", | ||
"description":"A Simple Text Editor.", | ||
"icons":[ | ||
{ | ||
"src":"texteditor.icon.png", | ||
"sizes":"250x250", | ||
"type":"image/png" | ||
} | ||
] | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,19 @@ | ||
const CACHE_NAME = `simple-texteditor`; | ||
var staticCacheName = "texteditor"; | ||
|
||
// Use the install event to pre-cache all initial resources. | ||
self.addEventListener('install', event => { | ||
event.waitUntil((async () => { | ||
const cache = await caches.open(CACHE_NAME); | ||
cache.addAll([ | ||
'/', | ||
'/texteditor.html', | ||
'/texteditor.png' | ||
]); | ||
})()); | ||
self.addEventListener("install", function (e) { | ||
e.waitUntil( | ||
caches.open(staticCacheName).then(function (cache) { | ||
return cache.addAll(["/", "/texteditor.html"]); | ||
}) | ||
); | ||
}); | ||
|
||
self.addEventListener('fetch', event => { | ||
event.respondWith((async () => { | ||
const cache = await caches.open(CACHE_NAME); | ||
self.addEventListener("fetch", function (event) { | ||
console.log(event.request.url); | ||
|
||
// Get the resource from the cache. | ||
const cachedResponse = await cache.match(event.request); | ||
if (cachedResponse) { | ||
return cachedResponse; | ||
} else { | ||
try { | ||
// If the resource was not in the cache, try the network. | ||
const fetchResponse = await fetch(event.request); | ||
|
||
// Save the resource in the cache and return it. | ||
cache.put(event.request, fetchResponse.clone()); | ||
return fetchResponse; | ||
} catch (e) { | ||
// The network failed. | ||
} | ||
} | ||
})()); | ||
}); | ||
event.respondWith( | ||
caches.match(event.request).then(function (response) { | ||
return response || fetch(event.request); | ||
}) | ||
); | ||
}); |