Files
Fociz/sw.js
NiekRabelink 9262b09c4d Add roadmap management, service worker, and user invitation features
- Implemented roadmap.php for managing roadmap items with filtering options by quarter and status.
- Added a service worker (sw.js) to handle push notifications and click events for calendar appointments.
- Created users.php for admin to manage team members and invitations, including user creation and deletion functionalities.
2026-09-09 15:54:24 +02:00

47 lines
1.6 KiB
JavaScript

/**
* Fociz Service Worker
* Beheert desktop push notificaties en click events voor agenda-afspraken.
*/
self.addEventListener('install', (event) => {
self.skipWaiting();
});
self.addEventListener('activate', (event) => {
event.waitUntil(self.clients.claim());
});
// Behandel klik op een notificatie
self.addEventListener('notificationclick', (event) => {
event.notification.close();
const targetUrl = (event.notification.data && event.notification.data.url)
? event.notification.data.url
: '/planner.php';
event.waitUntil(
clients.matchAll({ type: 'window', includeUncontrolled: true }).then((windowClients) => {
// Als er al een Fociz tabblad open staat, breng die naar voren
for (let i = 0; i < windowClients.length; i++) {
const client = windowClients[i];
if ('focus' in client) {
if (targetUrl.startsWith('http') && !targetUrl.includes(self.location.host)) {
// Externe meeting link (zoals Teams): open in nieuw tabblad
if (clients.openWindow) {
return clients.openWindow(targetUrl);
}
} else {
client.navigate(targetUrl);
return client.focus();
}
}
}
// Geen tabblad open: open een nieuw venster
if (clients.openWindow) {
return clients.openWindow(targetUrl);
}
})
);
});