diff --git a/Script/manifest.json b/Script/manifest.json new file mode 100644 index 0000000..4ef2b42 --- /dev/null +++ b/Script/manifest.json @@ -0,0 +1,21 @@ +{ + "name": "Guess the Number Game", + "short_name": "Number Game", + "start_url": "Script/guess_number.html", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#4a90e2", + "icons": [ + { + "src": "Script/Assets/icon.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "Script/Assets/icon-large.png", + "sizes": "512x512", + "type": "image/png" + } + ] + } + \ No newline at end of file diff --git a/Script/service-worker.js b/Script/service-worker.js new file mode 100644 index 0000000..421d769 --- /dev/null +++ b/Script/service-worker.js @@ -0,0 +1,28 @@ +const CACHE_NAME = 'v1'; +const urlsToCache = [ + './', + './Script/guess_number.html', + './Script/style-guess.css', + './Script/game.js', + './Script/manifest.json', + './Assets/icon.png', // Update with the path to your icons + './Assets/icon-large.png' // Update with the path to your large icon +]; + +self.addEventListener('install', event => { + event.waitUntil( + caches.open(CACHE_NAME) + .then(cache => { + return cache.addAll(urlsToCache); + }) + ); +}); + +self.addEventListener('fetch', event => { + event.respondWith( + caches.match(event.request) + .then(response => { + return response || fetch(event.request); + }) + ); +});