-
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
7e6e106
commit 4c48bb8
Showing
4 changed files
with
108 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Offline Website</title> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
<body> | ||
<div class="content"> | ||
<h1>Notice</h1> | ||
<p id="notice-text">Loading...</p> | ||
<p> </p> | ||
</div> | ||
<script src="script.js"></script> | ||
<!-- Register Service Worker --> | ||
<script> | ||
if ('serviceWorker' in navigator) { | ||
window.addEventListener('load', function() { | ||
navigator.serviceWorker.register('/service-worker.js').then(function(registration) { | ||
console.log('ServiceWorker registration successful with scope: ', registration.scope); | ||
}, function(err) { | ||
console.log('ServiceWorker registration failed: ', err); | ||
}); | ||
}); | ||
} | ||
</script> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Set the localNotice in the localStorage | ||
var localNotice = "This is a Local notice from the server!"; | ||
localStorage.setItem('notice', localNotice); | ||
|
||
// Update the content of the notice-text paragraph element | ||
var noticeTextElement = document.getElementById('notice-text'); | ||
noticeTextElement.textContent = localNotice; |
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,63 @@ | ||
// Service Worker for caching assets | ||
self.addEventListener('install', function(event) { | ||
event.waitUntil( | ||
caches.open('offline-v1').then(function(cache) { | ||
return cache.addAll([ | ||
'/', | ||
'/index.html', | ||
'/script.js', | ||
'/style.css' | ||
// Add other assets to cache here if needed | ||
]); | ||
}) | ||
); | ||
}); | ||
|
||
self.addEventListener('fetch', function(event) { | ||
event.respondWith( | ||
caches.match(event.request).then(function(response) { | ||
return response || fetch(event.request); | ||
}) | ||
); | ||
}); | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
// // Cache name | ||
// const CACHE_NAME = 'offline-cache-v1'; | ||
|
||
// // Assets to cache | ||
// const assetsToCache = [ | ||
// '/', | ||
// '/index.html', | ||
// '/style.css', | ||
// '/script.js' | ||
// // Add more assets as needed | ||
// ]; | ||
|
||
// // Install event | ||
// self.addEventListener('install', event => { | ||
// event.waitUntil( | ||
// caches.open(CACHE_NAME) | ||
// .then(cache => cache.addAll(assetsToCache)) | ||
// ); | ||
// }); | ||
|
||
// // Fetch event | ||
// self.addEventListener('fetch', event => { | ||
// event.respondWith( | ||
// caches.match(event.request) | ||
// .then(response => response || fetch(event.request)) | ||
// .catch(() => { | ||
// // Handle fetch errors | ||
// }) | ||
// ); | ||
// }); |
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,9 @@ | ||
body { | ||
background-color: black; | ||
color: white; | ||
font-family: Arial, sans-serif; | ||
} | ||
.content { | ||
text-align: center; | ||
margin-top: 50px; | ||
} |