PageSourceSearch

https://mrramensan.com.au/sw.js

js mrramensan.com.au collected 2026-10-07 14:46:37 UTC 2,255 bytes, 77 lines download raw bytes

1var CACHE_STATIC_NAME = 'static-v25';
2
3self.addEventListener('install', function(event) {
4    event.waitUntil(
5      caches.open(CACHE_STATIC_NAME)
6        .then(function(cache) {
7          console.log('[Service Worker] Precaching App Shell');
8          cache.addAll([
9            './offline',
10            './assets/front/img/static/offline.png',
11            './assets/front/img/static/offline-breadcrumb.jpeg'
12          ]);
13        })
14    )
15});
16
17self.addEventListener('activate', function(event) {
18    console.log('[Service Worker] Activating Service Worker ....', event);
19    event.waitUntil(
20      caches.keys()
21        .then(function(keyList) {
22          return Promise.all(keyList.map(function(key) {
23            if (key !== CACHE_STATIC_NAME) {
24              console.log('[Service Worker] Removing old cache.', key);
25              return caches.delete(key);
26            }
27          }));
28        })
29    );
30    return self.clients.claim();
31});
32
33self.addEventListener('fetch', function(event) {
34    event.respondWith(
35      caches.match(event.request)
36        .then(function(response) {
37          if (response) {
38            return response;
39          } else {
40            return fetch(event.request)
41              .catch(function(err) {
42                return caches.open(CACHE_STATIC_NAME)
43                  .then(function(cache) {
44                    return cache.match('./offline');
45                  });
46              });
47          }
48        })
49    );
50});
51
52self.addEventListener('push', function(e) {
53    if (!(self.Notification && self.Notification.permission === 'granted')) {
54        //notifications aren't supported or permission not granted!
55        return;
56    }
57
58    if (e.data) {
59        var msg = e.data.json();
60        console.log(msg)
61        var options = {
62            body: msg.body,
63            icon: msg.icon
64        };
65        if (msg.actions && msg.actions.length > 0) {
66            options.actions = msg.actions;
67        }
68        e.waitUntil(self.registration.showNotification(msg.title, options));
69    }
70});
71
72
73self.addEventListener('notificationclick', function(e) {
74    if (e.action.length > 0) {
75        self.clients.openWindow(e.action);
76    }
77});

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.