1self.addEventListener('install', (event) => { 2 self.skipWaiting(); 3}); 4 5self.addEventListener('activate', (event) => { 6 event.waitUntil(clients.claim()); 7}); 8 9self.addEventListener('push', (event) => { 10 if (!event.data) { 11 return; 12 } 13 14 const data = event.data.json(); 15 const title = data.title || 'Lieferzeit.at'; 16 const options = { 17 body: data.body || '', 18 icon: '/favicon-192x192.png', 19 badge: '/favicon-48x48.png', 20 image: data.image || '/apple-touch-icon.png', 21 tag: data.tag || 'order-notification', 22 requireInteraction: true, 23 vibrate: [200, 100, 200], 24 data: { 25 url: data.url || '/', 26 orderId: data.orderId, 27 timestamp: Date.now() 28 }, 29 actions: [ 30 { 31 action: 'view', 32 title: 'Bestellung anzeigen' 33 }, 34 { 35 action: 'close', 36 title: 'SchlieÃen' 37 } 38 ] 39 }; 40 41 event.waitUntil( 42 self.registration.showNotification(title, options) 43 ); 44}); 45 46self.addEventListener('notificationclick', (event) => { 47 event.notification.close(); 48 49 if (event.action === 'view' || !event.action) { 50 const urlToOpen = event.notification.data.url; 51 52 event.waitUntil( 53 clients.matchAll({ type: 'window', includeUncontrolled: true }) 54 .then((clientList) => { 55 for (let i = 0; i < clientList.length; i++) { 56 const client = clientList[i]; 57 if (client.url === urlToOpen && 'focus' in client) { 58 return client.focus(); 59 } 60 } 61 if (clients.openWindow) { 62 return clients.openWindow(urlToOpen); 63 } 64 }) 65 ); 66 } 67}); 68 69self.addEventListener('notificationclose', (event) => { 70 console.log('Notification closed:', event.notification.tag); 71});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.