1// Service Worker for Web Push Notifications 2// VAPID Push Notification Service Worker 3 4self.addEventListener('push', function(event) { 5 if (!event.data) return; 6 7 let data = {}; 8 try { 9 data = event.data.json(); 10 } catch(e) { 11 data = { title: 'Bildirim', body: event.data.text() }; 12 } 13 14 const title = data.title || 'Bildirim'; 15 const options = { 16 body: data.body || '', 17 icon: data.icon || '/img/logo-192.png', 18 badge: data.badge || '/img/logo-96.png', 19 image: data.image || undefined, 20 data: { url: data.url || '/' }, 21 tag: 'push-notification', 22 renotify: true, 23 requireInteraction: false, 24 vibrate: [200, 100, 200], 25 }; 26 27 event.waitUntil( 28 self.registration.showNotification(title, options) 29 ); 30}); 31 32self.addEventListener('notificationclick', function(event) { 33 event.notification.close(); 34 35 const url = (event.notification.data && event.notification.data.url) 36 ? event.notification.data.url 37 : '/'; 38 39 event.waitUntil( 40 clients.matchAll({ type: 'window', includeUncontrolled: true }).then(function(clientList) { 41 for (let client of clientList) { 42 if (client.url === url && 'focus' in client) { 43 return client.focus(); 44 } 45 } 46 if (clients.openWindow) { 47 return clients.openWindow(url); 48 } 49 }) 50 ); 51}); 52 53self.addEventListener('install', function(event) { 54 self.skipWaiting(); 55}); 56 57self.addEventListener('activate', function(event) { 58 event.waitUntil(clients.claim()); 59});
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.