1"use strict"; 2 3var VERSION = 'v0.0.13'; 4 5self.addEventListener('install', function(event) { 6 self.skipWaiting(); 7 event.waitUntil( 8 caches.open(VERSION).then(function(cache) { 9 return cache.addAll([ 10 '/manifest.json', 11 '/assets/push.css', 12 // '/assets/push.js' 13 ]); 14 }) 15 ); 16}); 17 18self.defaultLink='https://fo.ru'; 19 20/*self.addEventListener('fetch', function(event) { 21 var request = event.request; 22 23 if (request.method !== 'GET') return; 24 25 event.respondWith( 26 caches.match(request).then(function(response) { 27 return response || fetch(request); 28 }).catch(function() { 29 return caches.match('/'); 30 }) 31 ); 32});*/ 33 34self.addEventListener('activate', function(event) { 35 if (self.clients && clients.claim) { 36 clients.claim(); 37 } 38 event.waitUntil( 39 caches 40 .keys() 41 .then(function (keys) { 42 return Promise.all( 43 keys 44 .filter(function (key) { 45 return !key.startsWith(VERSION); 46 }) 47 .map(function (key) { 48 return caches.delete(key); 49 }) 50 ); 51 }) 52 .then(function() { 53 console.log('new service worker version registered', VERSION); 54 }).catch(function (error) { 55 console.error('error registering new service worker version', error); 56 }) 57 ); 58}); 59 60self.addEventListener('push', function(event) { 61 62 var notificationData = {}; 63 64 try { 65 notificationData = event.data.json(); 66 self.defaultLink= notificationData.link; 67 } catch (e) { 68 notificationData = { 69 title: 'Default title', 70 body: 'Default message', 71 icon: '/logo_4u_bigger.png' 72 }; 73 } 74 75 event.waitUntil( 76 self.registration.showNotification(notificationData.title, { 77 body: notificationData.body, 78 icon: notificationData.icon 79 }) 80 81 82 ); 83 //self.defaultLink= notificationData.link; 84}); 85 86self.addEventListener('notificationclick', function(event) { 87 88 // close the notification 89 //event.notification.close(); 90 self.clients.openWindow(self.defaultLink); 91 92 // see if the current is open and if it is focus it 93 // otherwise open new tab 94 event.waitUntil( 95 96 self.clients.matchAll().then(function(clientList) { 97 98 if (clientList.length > 0) { 99 return clientList[0].focus(); 100 } 101 102 return self.clients.openWindow('/'); 103 }) 104 ); 105}); 106
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.