From b047f1b5e83524bff13565d13978ba45825122b2 Mon Sep 17 00:00:00 2001 From: marlon-erler Date: Sun, 7 Jul 2024 16:56:12 +0200 Subject: [PATCH] update --- .DS_Store | Bin 6148 -> 0 bytes .gitignore | 3 +++ dist/index.html | 1 + dist/manifest.json | 2 +- dist/styles.css | 16 ++++++++++++++-- dist/support.js | 21 +++++++++++++++++++++ dist/sw.js | 38 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 78 insertions(+), 3 deletions(-) delete mode 100644 .DS_Store create mode 100644 .gitignore create mode 100644 dist/sw.js diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 4b4d30de49673f2a283451394f75fd458d6f8cbd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK!AiqG5Z!H~-BN@cR6H(tE!ct-#7l_!14i_qQWH}&7_+5G&7l->)F1Lw{2pg^ zH$|y}ClNaXvu`pxv&p`MoeX1)`_s73n9CRwpoon&3||P&qb^CqdYXV7*NDn|9HlCP z>(`}da{NUG@ZC8qW(mt#@$vmd<21>OUhj=Jn$FsKOSD8sTnG2642rOr=6*Q2#H%x< z(x|q>=sX#fLwEB?Wkr}|qlr#P;t_;gT_jnoN?%R0IM=y>nGkK!9=hAJS+6Sx`}3}x z9Sp$igUsh`v9-H*cshJYA2aoADCF?9Y1yz?!wVRT-NgBA8o|?H@WS~NOtMsEci^iR zsgntb0b+m{SQ!TF0Vp~vvt!yQF+dFblmR>+Bq*Y1u`;NS4j6O`0O){Q3)t98V2-rt zS*#4g3Mv|4+W}|8)=z!~ikyKN;Z8ad7Oz-fV4M+9lRn33>yHf^n6>MG6?Y6hkbQ;vG;e Z;Fo9sdKN2#-~pi@0Zju9#K5mI@D8Q;PWb=; diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..33c7462d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.DS_Store +**/.DS_Store +node_modules \ No newline at end of file diff --git a/dist/index.html b/dist/index.html index b112b2e0..503f8dbf 100644 --- a/dist/index.html +++ b/dist/index.html @@ -1,3 +1,4 @@ + My App diff --git a/dist/manifest.json b/dist/manifest.json index 2c8c9fdc..c1971134 100644 --- a/dist/manifest.json +++ b/dist/manifest.json @@ -1,5 +1,5 @@ { - "name": "My App", + "name": "Broadcast", "display": "standalone", "icons": [ { diff --git a/dist/styles.css b/dist/styles.css index f37586c3..42df8f4d 100644 --- a/dist/styles.css +++ b/dist/styles.css @@ -105,6 +105,10 @@ header { accent-color: var(--primary); } +a { + color: var(--link); +} + /* text */ .success { @@ -605,6 +609,7 @@ select + .icon, article, main, select + .icon, +.height-100, .modal > div, .modal main { height: 100%; @@ -683,6 +688,7 @@ code { } .secondary, +.secondary *, .helper-text, .error-text, label { @@ -749,7 +755,8 @@ input[type="radio"]:checked::before { LAYOUT */ /* basic */ -body { +body, +html { display: flex; flex-direction: column-reverse; @@ -758,12 +765,17 @@ body { height: 100%; } -body { +body, +.modal { padding-left: var(--safe-area-left); padding-right: var(--safe-area-right); padding-top: var(--safe-area-top); } +.modal { + padding-bottom: var(--safe-area-bottom); +} + menu { width: 100%; height: var(--menu-height-mobile); diff --git a/dist/support.js b/dist/support.js index 6a599200..2a9bce55 100644 --- a/dist/support.js +++ b/dist/support.js @@ -1,3 +1,4 @@ +// TABS document.querySelector("main").addEventListener("scroll", () => { const links = document.querySelectorAll(".tab-link"); links.forEach((element) => element.removeAttribute("active")); @@ -8,3 +9,23 @@ document.querySelector("main").addEventListener("scroll", () => { if (links[currentPage]) links[currentPage].setAttribute("active", ""); }); + +// SERVICE WORKER +async function registerServiceWorker() { + if ("serviceWorker" in navigator) { + try { + const registration = await navigator.serviceWorker.register("/sw.js", { + scope: "/", + }); + if (registration.installing) { + setTimeout(() => window.location.reload(), 500); + } else if (registration.active) { + console.log("Service worker active"); + } + } catch (error) { + console.error(`Could not install service worker: ${error}`); + } + } +} + +registerServiceWorker(); diff --git a/dist/sw.js b/dist/sw.js new file mode 100644 index 00000000..5768bc6c --- /dev/null +++ b/dist/sw.js @@ -0,0 +1,38 @@ +const CACHE_VERSION = "v1"; + +async function handleRequest(event) { + const responsePromise = getResponse(event); + event.respondWith(responsePromise); +} + +async function getResponse(event) { + try { + return await fetchAndCache(event); + } catch { + return await getFromCache(event); + } +} + +async function fetchAndCache(event) { + const request = event.request; + + const response = await fetch(request); + + const cache = await caches.open(CACHE_VERSION); + await cache.put(request, response.clone()); + + return response; +} + +async function getFromCache(event) { + const request = event.request; + + const cache = await caches.open(CACHE_VERSION); + const response = await cache.match(request); + + return response; +} + +self.addEventListener("fetch", (event) => { + handleRequest(event); +}); \ No newline at end of file