From d58c0723b147745f2a8e8cdc8615f0d77b9f4fea Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 13 Oct 2025 22:48:34 -0600 Subject: [PATCH] feat: add pwa support --- app.js | 5 ++++ icons/icon-192.png | Bin 0 -> 1099 bytes icons/icon-512.png | Bin 0 -> 2722 bytes index.html | 9 ++++++- manifest.webmanifest | 25 +++++++++++++++++++ service-worker.js | 56 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 icons/icon-192.png create mode 100644 icons/icon-512.png create mode 100644 manifest.webmanifest create mode 100644 service-worker.js diff --git a/app.js b/app.js index a2e5fe4..da526c7 100644 --- a/app.js +++ b/app.js @@ -361,6 +361,11 @@ hasExplicitThemePreference = Boolean(window.localStorage.getItem(THEME_STORAGE_K window.addEventListener('load', () => { startClock(); renderSearchResults(''); + if ('serviceWorker' in navigator) { + navigator.serviceWorker.register('service-worker.js').catch((error) => { + console.error('Service Worker Registrierung fehlgeschlagen:', error); + }); + } }); if (themeToggleButton) { diff --git a/icons/icon-192.png b/icons/icon-192.png new file mode 100644 index 0000000000000000000000000000000000000000..6751f82bad80b090eec8411dae08e2dd670e2bd9 GIT binary patch literal 1099 zcmeAS@N?(olHy`uVBq!ia0vp^2SAvE4M+yv$zf+;U=i|kaSW-L^Y;4w>^r40$3K?W zO<2aebjx)4uBEQ*TRrubh6(O^@gl_P^`Z+`m4be=zewwD_T$?1BBWGk`mvK1qPM)W zwD{UYoR|&8FJ>hjSn^zeL*)6B1J@rL*1iASdi~R$-!bPWZv5!yxZ++Oe?y)S!$lSc z6Gj1F1{dKG$9(<%Tf_g|;`gh!PfJhBdU>oQG<5H$r(dIXR&I_8UmqHJwK)9V%Bx|k zr!CvR+Iaf?b&HoDTfJ)4^7Y%L&ZfoM|8}~*O$rsesB|GyAWx^4Ta zi#hM=?q!(0UhZ!XRDW$Nf7yKdzqeLj%{%+<`yGpQ4%KUHt;3J2mF>IQzI@hJo6pW) z`T4@$A8`2k?R)tB2MM|B*4lnLcW~mws#k|vXZ`;%InSr>k$6J?-;EmroR9a1fBkah z!^_KCt9FO7ySu-7vH5&R`tQWQW#8Y`-?J=!T6Fj4hsC$<-Fb89kq*<1?74on5ix5H ztNUNuc=F`0pP%(#T}VzgwJ{Cl-@g6z_2}(#mj8b2EWUdAcKB&y<5;OVM@2K_x1>K` zWoQ}rx0yXFySDau{lSpUQfE&_?Y(=;_Ii23f@Sx1g{=L)zN|1;jPXtLw>vSmmH%q~ z{yXgy8fqJ{C%oN%&I;$ni?`PO|Mza^$8Pc0_ss8KJ9f%z`?6z&thd;+%j?!$e187g zq449k;43@Z}p{b^_8dpqkx43gQu&X%Q~loCIGU|x^Dmg literal 0 HcmV?d00001 diff --git a/icons/icon-512.png b/icons/icon-512.png new file mode 100644 index 0000000000000000000000000000000000000000..b3977290ccdcd6c8fd11e57550eb029f789b7c74 GIT binary patch literal 2722 zcmeHJYfF;>6h7Y4CU(=9l})k050(owbvbXLObJG4c)@E3iaMK@U>kegoCGDSEF>@K zHiASWBvfbD1eA8fV39?EfHP->26}Jz5u=_0Rqke zoVn^L@XW!p569&$Y8Od>AX59TS+j036*uE^ayg>QXUdI}o3BMHrIMZ=^3=gJIyxSk zPqy>K9Lp#CcWzZxW#!K5E`#v^yQJh*SAQ3@cR|Y)29w2#$3(qD%+l_O;3##uOYbfr z@uZ_Dh3{Nbx=|WqI4Q-YO^~K=lZeD*VnIYc)IZXds6-3chAofZSlcvG=W1A9Ua2x3 z8VXB_dMoz!nlx&KZIknNY0x4MB+L6H_Jx?22;(-E`-V=sv?Wm30mQ%H3O@cKI>t zu+M7CQS)uI;&hl~cz-G`DV1HlF6=QOM=#>V2?ugse5C~@~=x*jQch$**MI^ z6nDDRxn&O7_IN5{>qogZQ>4Z_aO~hq&$$00$qTM^Mti=xN8LOsf1KTpHN2toWwda# RCd2JLAv=?vF><@S^*@MSA; Weltze.it — Alle Zeitzonen im Blick + + + + + + + @@ -51,7 +58,7 @@ diff --git a/manifest.webmanifest b/manifest.webmanifest new file mode 100644 index 0000000..b06c804 --- /dev/null +++ b/manifest.webmanifest @@ -0,0 +1,25 @@ +{ + "name": "Weltze.it — Alle Zeitzonen im Blick", + "short_name": "Weltze.it", + "description": "Alle Zeitzonen auf einen Blick vergleichen und Termine koordinieren.", + "lang": "de", + "start_url": "./", + "scope": "./", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#0f172a", + "icons": [ + { + "src": "icons/icon-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "any" + }, + { + "src": "icons/icon-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "any maskable" + } + ] +} diff --git a/service-worker.js b/service-worker.js new file mode 100644 index 0000000..e67ec7e --- /dev/null +++ b/service-worker.js @@ -0,0 +1,56 @@ +const CACHE_NAME = 'weltzeit-cache-v1'; +const PRECACHE_RESOURCES = [ + './', + './index.html', + './styles.css', + './app.js', + './zones.js', + './manifest.webmanifest', + './icons/icon-192.png', + './icons/icon-512.png' +]; + +self.addEventListener('install', (event) => { + event.waitUntil( + caches.open(CACHE_NAME).then((cache) => cache.addAll(PRECACHE_RESOURCES)) + ); +}); + +self.addEventListener('activate', (event) => { + event.waitUntil( + caches.keys().then((cacheNames) => + Promise.all( + cacheNames.map((cacheName) => { + if (cacheName !== CACHE_NAME) { + return caches.delete(cacheName); + } + return undefined; + }) + ) + ) + ); +}); + +self.addEventListener('fetch', (event) => { + if (event.request.method !== 'GET') { + return; + } + + event.respondWith( + caches.match(event.request).then((cachedResponse) => { + if (cachedResponse) { + return cachedResponse; + } + + return fetch(event.request) + .then((response) => { + const responseClone = response.clone(); + caches.open(CACHE_NAME).then((cache) => { + cache.put(event.request, responseClone); + }); + return response; + }) + .catch(() => caches.match('./index.html')); + }) + ); +});