PageSourceSearch

https://detstrana.ru/resources/scripts/sw.js

js detstrana.ru collected 2026-10-02 09:57:11 UTC 2,604 bytes, 86 lines download raw bytes

1'use strict';
2
3var url = 'https://detstrana.ru';
4
5function showNotification(t, b, i, l, u) {
6    var n = {
7        body: b,
8        icon: i ? i : "images/touch/chrome-touch-icon-192x192.png",
9        tag: l ? l : Math.random()
10    };
11
12    if (!u || u == '' || u == null || u == false) {
13        var data = new FormData();
14        data.append( "json", JSON.stringify( n ) );
15
16        fetch('/detstrana/ajax/save-empty-url/', {
17            method: 'post',
18            headers: {
19                "X-Requested-With": "XMLHttpRequest"
20            },
21            body: data
22        });
23    }
24
25    url = u;
26    self.registration.showNotification(t, n)
27}
28
29console.log('Started', self);
30self.addEventListener('install', function(event) {
31    self.skipWaiting();
32    console.log('Installed', event);
33});
34self.addEventListener('activate', function(event) {
35    console.log('Activated', event);
36});
37self.addEventListener('push', function(event) {
38    console.log('Event ', event);
39    event.waitUntil(
40
41        fetch('/public/gcm.json?t' + new Date().getTime(), {
42            method: 'get',
43            headers: {
44                "Content-type": "application/x-www-form-urlencoded; charset=UTF-8",
45                "X-Requested-With": "XMLHttpRequest"
46            }
47        }).then(function(response) {
48            if (response.status !== 200) {
49                console.log('Looks like there was a problem. Status Code: ' + response.status);
50                throw new Error();
51            }
52
53            // Examine the text in the response
54            return response.json().then(function(data) {
55                var title = data.notification.title;
56                var message = data.notification.message;
57                var icon = data.notification.icon;
58                var notificationTag = data.notification.tag;
59                var url = data.notification.url;
60
61                showNotification(title, message, icon, notificationTag, url);
62            });
63        })
64    );
65});
66
67self.addEventListener('notificationclick', function(event) {
68    event.notification.close();
69
70    event.waitUntil(
71        clients.matchAll({
72            type: 'window'
73        })
74            .then(function(windowClients) {
75                for (var i = 0; i < windowClients.length; i++) {
76                    var client = windowClients[i];
77                    if (client.url === url && 'focus' in client) {
78                        return client.focus();
79                    }
80                }
81                if (clients.openWindow) {
82                    return clients.openWindow(url);
83                }
84            })
85    );
86});

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.