From dce93820b8c19dac96fa704a2c33da172e0140f1 Mon Sep 17 00:00:00 2001 From: Brian Daley Date: Thu, 19 Sep 2024 16:53:11 -0400 Subject: [PATCH 1/3] ionic files --- index.html | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 92 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index c369b72..b0f56a1 100644 --- a/index.html +++ b/index.html @@ -5,6 +5,11 @@ Home | Offline First Demo + + + + + - - - - - - - - - - - - - - - diff --git a/index.html b/index.html index b0f56a1..29a8af6 100644 --- a/index.html +++ b/index.html @@ -1,109 +1,115 @@ - - - - - Home | Offline First Demo - - - - - - - - - - - - - - -
- - - Listen now - - - -
Listen now content
-
-
-
- -
- - - Radio - - - -
Radio content
-
-
-
- -
- - - Library - - - -
Library content
-
-
-
- -
+ + + + + + Home | Offline First Demo + + + + + + + + + + + + + +
- Search + + + + Photo Gallery -
Search content
+ + + Antelope + + Antelope + + + + + Bobcat + + Bobcat + + + + + + + Caracal + + Caracal + + + + + Caribou + + Caribou Bulls + + + + + Caribou + + Caribou + + + + + Cheetah + + Cheetah + + + + + Coyote + + Coyote + + + + + Ferrets + + Ferrets + + + + + Ox + + Ox + + + + + Coyote + + Tiger + + +
- - - - - - Listen Now - - - - Radio - - - - Library - - - - Search - - - - - -
- + + + + \ No newline at end of file diff --git a/sw.js b/sw.js new file mode 100644 index 0000000..334ea24 --- /dev/null +++ b/sw.js @@ -0,0 +1,28 @@ +// Name of our cache +const cacheName = 'offline-pwa-gallery-v1'; + +const urlsToCache = [ + +]; + +// Cache files on service worker registration +self.addEventListener('install', (event) => { + event.waitUntil( + caches.open(cacheName).then((cache) => { + return cache.addAll(urlsToCache); + }) + ); +}); + +// Intercept fetch requests to serve cached assets +self.addEventListener('fetch', (event) => { + if(event.request.url.match(/^https:\/\//)){ + console.log('Browser is requesting', event.request.url); + } + event.respondWith( + caches.match(event.request).then((cachedResponse) => { + // It can update the cache to serve updated content on the next request + return cachedResponse || fetch(event.request); + }) + ); +}); From 40fc49086bcb48996de1b6a4317756f122b62c1f Mon Sep 17 00:00:00 2001 From: Brian Daley Date: Tue, 24 Sep 2024 15:53:33 -0400 Subject: [PATCH 3/3] fixes --- index.html | 9 ++++----- sw.js | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index 29a8af6..1ef4966 100644 --- a/index.html +++ b/index.html @@ -11,12 +11,11 @@ - + + + + diff --git a/sw.js b/sw.js index 334ea24..9195f20 100644 --- a/sw.js +++ b/sw.js @@ -1,6 +1,7 @@ // Name of our cache const cacheName = 'offline-pwa-gallery-v1'; +// URLs to cache for offline mode const urlsToCache = [ ]; @@ -17,7 +18,7 @@ self.addEventListener('install', (event) => { // Intercept fetch requests to serve cached assets self.addEventListener('fetch', (event) => { if(event.request.url.match(/^https:\/\//)){ - console.log('Browser is requesting', event.request.url); + console.log('Browser is requesting:', event.request.url); } event.respondWith( caches.match(event.request).then((cachedResponse) => {