PageSourceSearch

https://kuznica.ug.gov.pl/ServiceManager_skin_01.js

js kuznica.ug.gov.pl collected 2026-10-02 21:35:21 UTC 2,652 bytes, 87 lines download raw bytes

1
2/**
3 * kod JS zarzadzajacy powiadomieniami push do przegladarki
4 * @author  ??, Tomasz Glowinski, 2020
5 */
6  
7function pnAvailable() {
8    var bAvailable = false;
9    if (window.isSecureContext) {
10        // running in secure context - check for available Push-API
11        bAvailable = (('serviceWorker' in navigator) &&
12                ('PushManager' in window) &&
13                ('Notification' in window));
14    } else {
15        console.warn('[ServiceManager] site have to run in secure context!');
16    }
17    return bAvailable;
18}
19
20async function pnPopup() {
21    if (pnAvailable()) {        
22    
23        var registered = await navigator.serviceWorker.getRegistrations();
24        
25        if(registered && registered.length > 0)
26        {            
27            if(confirm("Czy na pewno chcesz wyłączyć subskrypcję powiadomień?"))
28            {
29                let unregistered = await pnUnregisterSW();
30                
31                if(unregistered > 0)
32                {
33                    alert('Subskrypcja powiadomień została wyłączona');
34                }
35            }
36        }
37        else
38        {
39                
40            // if not granted or denied so far...
41            if (window.Notification.permission === 'default') {
42                await window.Notification.requestPermission();
43            }
44            
45            if (Notification.permission === 'granted') {
46                // register service worker
47                await pnRegisterSW();
48            }
49        }
50    }
51    else
52    {
53        alert('Twoja przeglądarka nie obsługuje systemu powiadomień Web Push');
54    }
55}
56
57async function pnRegisterSW() {
58    return await navigator.serviceWorker.register(window.location.protocol + '//' + window.location.hostname + '/ServiceWorker_skin_01.js')
59            .then((swReg) => {
60                console.info('[ServiceManager] SW registered, scope is ', swReg.scope);                
61            }).catch((e) => {
62        console.error('[ServiceManager] SW registration failed with ', e);
63        //alert('Nie udało się włączyć subskrypcji (' + e + ')');
64    });
65}
66
67async function pnUnregisterSW()
68{
69    let ile = 0;
70    await navigator.serviceWorker.getRegistrations().then( function(registrations) { 
71        if(registrations)
72        {
73            for(let registration of registrations) { 
74                registration.unregister(); 
75                ile++;
76                console.info('[ServiceManager] Subscription unregistered.');
77            } 
78        }
79    }); 
80    return ile;
81}
82
83/** Forbidden by her majesty Mozilla Firefox the 93th
84jQuery(document).ready(function () {
85    pnPopup();
86});
87*/

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.