Skip to content

Commit

Permalink
Fix PWA 4
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasMFR committed Mar 8, 2024
1 parent 3077c81 commit 8457348
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
14 changes: 13 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<link rel="manifest" href="manifest.json">
<link rel="icon" type="image/png" sizes="32x32" href="icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="icons/favicon-16x16.png">

<script src="script.js"></script>
</head>
<body>
<div id="compteur-container">
Expand All @@ -25,6 +27,16 @@
<button id="reinitialiser">Remettre le compteur à zéro</button>
</div>

<script src="script.js"></script>
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/service-worker.js').then(registration => {
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}, err => {
console.log('ServiceWorker registration failed: ', err);
});
});
}
</script>
</body>
</html>
11 changes: 0 additions & 11 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
// Service Worker registration
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/service-worker.js').then(registration => {
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}, err => {
console.log('ServiceWorker registration failed: ', err);
});
});
}

document.querySelectorAll('.bouton-compteur').forEach(bouton => {
bouton.addEventListener('click', function() {
const modificateur = parseInt(this.getAttribute('data-modificateur'), 10);
Expand Down
2 changes: 1 addition & 1 deletion service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const urlsToCache = [
'/',
'/index.html',
'/style.css',
'script.js',
'/script.js',
'/app.js',
'/icon/lowres.webp',
'/icon/hd_hi.ico'
Expand Down

0 comments on commit 8457348

Please sign in to comment.