diff --git a/icon-192x192.png b/icon-192x192.png new file mode 100644 index 0000000..8ae05d1 Binary files /dev/null and b/icon-192x192.png differ diff --git a/icon-512x512.png b/icon-512x512.png new file mode 100644 index 0000000..976466f Binary files /dev/null and b/icon-512x512.png differ diff --git a/index.html b/index.html index e0dc6a5..834ad22 100644 --- a/index.html +++ b/index.html @@ -22,6 +22,7 @@ + @@ -1695,6 +1696,9 @@

FIND US

+ + + diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..5e432f1 --- /dev/null +++ b/manifest.json @@ -0,0 +1,20 @@ +{ + "name": "Ticket-Booking", + "short_name": "Ticket-Booking", + "start_url": "/", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#000000", + "icons": [ + { + "src": "/icon-192x192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "/icon-512x512.png", + "sizes": "512x512", + "type": "image/png" + } + ] + } diff --git a/scripts.js b/scripts.js new file mode 100644 index 0000000..8df64f9 --- /dev/null +++ b/scripts.js @@ -0,0 +1,12 @@ +// Register the service worker +if ('serviceWorker' in navigator) { + window.addEventListener('load', () => { + navigator.serviceWorker.register('/sw.js') // Pointing to the sw.js file + .then(registration => { + console.log('ServiceWorker registration successful:', registration); + }) + .catch(error => { + console.error('ServiceWorker registration failed:', error); + }); + }); +} \ No newline at end of file diff --git a/sw.js b/sw.js new file mode 100644 index 0000000..2f85769 --- /dev/null +++ b/sw.js @@ -0,0 +1,43 @@ +const CACHE_NAME = 'my-pwa-cache-v1'; +const urlsToCache = [ + '/', + '/index.html', + '/styles.css', + '/scripts.js', + '/manifest.json', + '/icon-192x192.png', + '/icon-512x512.png' +]; + +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); + }) + ); +}); + +self.addEventListener('activate', (event) => { + const cacheWhitelist = [CACHE_NAME]; + event.waitUntil( + caches.keys().then((cacheNames) => { + return Promise.all( + cacheNames.map((cacheName) => { + if (!cacheWhitelist.includes(cacheName)) { + return caches.delete(cacheName); + } + }) + ); + }) + ); +}); \ No newline at end of file