Add service worker for push notifications, create calendar layout, and implement WLAN QR code page

- Implemented a service worker (sw.js) to handle push notifications with dynamic options and notification click events.
- Created a calendar layout in test.html with a grid system for displaying events across days and times.
- Developed a visually engaging WLAN QR code page (wlan.html) with animated backgrounds, particle effects, and tips for connecting to the network.
This commit is contained in:
2026-02-22 00:50:22 +01:00
parent 6b96cd2012
commit 038910e9f0
26 changed files with 32980 additions and 5 deletions

60
public/sw.js Normal file
View File

@@ -0,0 +1,60 @@
// sw.js
self.addEventListener("push", function (event) {
const data = event.data ? event.data.json() : {};
const title = data.title || "Shit da ist was falsch"; // title braucht man, sonst Error
// Dynamisch Options-Objekt nur mit vorhandenen Werten
const options = {};
if (data.body) options.body = data.body;
if (data.icon) options.icon = data.icon;
if (data.badge) options.badge = data.badge;
if (data.actions) options.actions = data.actions;
if (data.requireInteraction !== undefined) options.requireInteraction = data.requireInteraction;
if (data.renotify !== undefined) options.renotify = data.renotify;
if (data.tag) options.tag = data.tag;
if (data.vibrate) options.vibrate = data.vibrate;
if (data.url) options.data = { url: data.url };
event.waitUntil(
self.registration.showNotification(title, options)
);
});
self.addEventListener("notificationclick", function (event) {
event.notification.close(); // Notification schließen
// Prüfen, ob eine Action gedrückt wurde
if (event.action) {
// Dynamische Aktionen vom Server können hier behandelt werden
// Beispiel: Wir öffnen die URL, die im Notification-Data-Feld steht
if (event.notification.data && event.notification.data.url) {
event.waitUntil(
clients.openWindow(event.notification.data.url)
);
}
// Optional: Weitere Action-IDs können hier behandelt werden
console.log("Action clicked:", event.action);
} else {
// Notification selbst angeklickt (ohne Button)
if (event.notification.data && event.notification.data.url) {
event.waitUntil(
clients.openWindow(event.notification.data.url)
);
}
}
});
self.addEventListener('install', event => {
console.log("Service Worker installiert");
// Sofort aktivieren, ohne auf alte Version zu warten
self.skipWaiting();
});
self.addEventListener('activate', event => {
console.log("Service Worker aktiviert");
// Alte Clients übernehmen
event.waitUntil(self.clients.claim());
});