This repository was archived by the owner on Sep 21, 2023. It is now read-only.
forked from ffrgb/meshviewer
-
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.
[TASK] Add simple offline service worker
- Loading branch information
Showing
6 changed files
with
59 additions
and
2 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
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
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
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Freifunk Regensburg e.V. - Meshviewer</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> | ||
<link rel="stylesheet" href="main.css" inline> | ||
</head> | ||
<body> | ||
<div class="loader"> | ||
<p> | ||
Your are Offline!<br /> | ||
<img inline src="logo.svg" class="spinner" alt="Loading ..."/> | ||
<br /> | ||
No connection available. | ||
<br /><br /><button onclick="location.reload(true)" class="btn text" aria-label="Try to reload">Try to reload</button><br /> | ||
</p> | ||
<noscript> | ||
<strong>JavaScript required</strong> | ||
</noscript> | ||
</div> | ||
</body> | ||
</html> |
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
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
self.addEventListener('install', function (event) { | ||
var offlineRequest = new Request('offline.html'); | ||
event.waitUntil( | ||
fetch(offlineRequest).then(function (response) { | ||
return caches.open('offline').then(function (cache) { | ||
return cache.put(offlineRequest, response); | ||
}); | ||
}) | ||
); | ||
}); | ||
|
||
self.addEventListener('fetch', function (event) { | ||
var request = event.request; | ||
if (request.method === 'GET') { | ||
event.respondWith( | ||
fetch(request).catch(function () { | ||
return caches.open('offline').then(function (cache) { | ||
return cache.match('offline.html'); | ||
}); | ||
}) | ||
); | ||
} | ||
}); |