diff options
Diffstat (limited to 'static')
| -rw-r--r-- | static/js/app.js | 23 | ||||
| -rw-r--r-- | static/js/worker.js | 22 | ||||
| -rw-r--r-- | static/manifest.json | 24 |
3 files changed, 69 insertions, 0 deletions
diff --git a/static/js/app.js b/static/js/app.js new file mode 100644 index 0000000..f1ec61e --- /dev/null +++ b/static/js/app.js @@ -0,0 +1,23 @@ +if ('serviceWorker' in navigator) { + window.addEventListener('load', () => { + navigator.serviceWorker.register('/worker.js') + .then(registration => { + console.log('ServiceWorker registered:', registration); + }) + .catch(error => { + console.log('ServiceWorker registration failed:', error); + }); + }); +} + +let deferredPrompt; +window.addEventListener('beforeinstallprompt', (e) => { + e.preventDefault(); + deferredPrompt = e; +}); + +document.body.addEventListener('htmx:afterSwap', (event) => { + event.detail.elt.querySelectorAll('.animate-slide-up').forEach((el, i) => { + el.style.animationDelay = `${i * 0.1}s`; + }); +});
\ No newline at end of file diff --git a/static/js/worker.js b/static/js/worker.js new file mode 100644 index 0000000..84d94df --- /dev/null +++ b/static/js/worker.js @@ -0,0 +1,22 @@ +const CACHE_NAME = 'cafe'; +const urlsToCache = [ + '/', + '/static/css/style.css', + '/static/js/htmx.min.js', + '/static/js/app.js', + '/static/manifest.json' +]; + +self.addEventListener('install', (event) => { + event.waitUntil( + caches.open(CACHE_NAME) + .then((cache) => cache.addAll(urlsToCache)) + ); +}); + +self.addEventListener('fetch', (event) => { + event.respondWith( + caches.match(event.request) + .then((response) => response || fetch(event.request)) + ); +});
\ No newline at end of file diff --git a/static/manifest.json b/static/manifest.json new file mode 100644 index 0000000..1bca313 --- /dev/null +++ b/static/manifest.json @@ -0,0 +1,24 @@ +{ + "name": "Shifoo's Cafe", + "short_name": "Cafe", + "description": "A cozy place for close friends!", + "start_url": "/", + "display": "standalone", + "background_color": "#0a0a0f", + "theme_color": "#1a1a2e", + "orientation": "portrait-primary", + "icons": [ + { + "src": "/static/icons/icon-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "any maskable" + }, + { + "src": "/static/icons/icon-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "any maskable" + } + ] +}
\ No newline at end of file |
