1self.addEventListener('install', () => self.skipWaiting()); 2self.addEventListener('activate', (event) => event.waitUntil(self.clients.claim())); 3 4self.addEventListener('push', (event) => { 5 let notificationTitle = 'IIR News Intelligence'; 6 let notificationOptions = { 7 body: 'New industry intelligence and market developments have just been published.', 8 icon: "https://media.industrialinfo.com/iir-media-kit/IIR/Globe Only/webp/iir-globe.webp", 9 image: "https://www.industrialinfo.com/images/site-share-image.jpg", 10 badge: 'https://media.industrialinfo.com/iir-media-kit/IIR/Globe Only/webp/iir-globe.webp', 11 tag: 'iir-daily-news', 12 data: { url: 'https://www.industrialinfo.com/news/' }, 13 }; 14 15 if (event.data) { 16 try { 17 const payload = event.data.json(); 18 notificationTitle = payload.title || notificationTitle; 19 notificationOptions.body = payload.body || notificationOptions.body; 20 if (payload.url) notificationOptions.data.url = payload.url; 21 } catch (e) { 22 notificationOptions.body = event.data.text(); 23 } 24 } 25 26 event.waitUntil(self.registration.showNotification(notificationTitle, notificationOptions)); 27}); 28 29self.addEventListener('notificationclick', (event) => { 30 event.notification.close(); 31 32 const targetUrl = event.notification.data.url; 33 34 event.waitUntil( 35 self.clients.matchAll({ type: 'window', includeUncontrolled: true }).then((clientList) => { 36 for (const client of clientList) { 37 if (client.url === targetUrl && 'focus' in client) return client.focus(); 38 } 39 if (self.clients.openWindow) return self.clients.openWindow(targetUrl); 40 }) 41 ); 42});
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.