PageSourceSearch

https://www.jornaldenegocios.pt/sw.js

js jornaldenegocios.pt collected 2026-09-24 08:51:45 UTC 2,834 bytes, 97 lines download raw bytes

1var icon = '/i/pushnotifications/lg_n.png';
2var badge = '/i/pushnotifications/notification_neg.png';
3
4self.addEventListener('install', function (event) {
5    console.log('Installed', event);
6});
7self.addEventListener('activate', function (event) {
8    console.log('Activated', event);
9});
10
11self.addEventListener('push', function (event) {
12
13    if (!event.data) {
14        console.error('Push event but no data');
15        return;
16    }
17
18    try {
19        var data = event.data.json();
20    } catch (error) {
21        console.error('Failed to parse push event data as JSON', error);
22        return;
23    }
24
25    var title = data.Title ? data.Title : '';
26    var body = data.Body;
27    var urlOpen = data.UrlToOpen;
28
29    var options = {
30        body: body,
31        icon: icon,
32        badge: badge,
33        data: {
34            link: urlOpen
35        },
36        requireInteraction: true,
37        tag: 'require-interaction',
38        actions: [
39            {
40                action: 'facebook-share',
41                title: 'Partilhar',
42                icon: '/i/pushnotifications/facebook-like-btn-v5.png'
43            }
44        ]
45    };
46
47    if (data.Image !== null && data.Image !== '')
48        options["image"] = data.Image;
49
50
51    if (data.Actions !== undefined && data.Actions !== null) {
52        options.actions = data.Actions;
53    }
54
55    return self.registration.showNotification(title, options);
56});
57
58self.addEventListener('notificationclick', function (event) {
59    console.log('On notification click: ', event.notification.tag);
60
61    var link = event.notification.data.link;
62
63    if (link != '') {
64        link += ((link.indexOf('?') === -1) ? '?' : '&') + '?utm_campaign=Notificacao&utm_medium=email&utm_source=PushChrome';
65    } else {
66        link = 'http://www.jornaldenegocios.pt/';
67    }
68
69    event.notification.close();
70
71    switch (event.action) {
72        case 'facebook-share':
73            link = 'https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(link);
74            return clients.openWindow(link);
75            break;
76        case 'twitter-share':
77            link = 'https://twitter.com/intent/tweet?url=' + encodeURIComponent(link);
78            return clients.openWindow(link);
79            break;
80    }
81
82    event.waitUntil(
83        clients.matchAll({
84            type: "window"
85        })
86            .then(function (clientList) {
87                for (var i = 0; i < clientList.length; i++) {
88                    var client = clientList[i];
89                    if (client.url == link && 'focus' in client)
90                        return client.focus();
91                }
92                if (clients.openWindow) {
93                    return clients.openWindow(link);
94                }
95            })
96    );
97});

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.