PageSourceSearch

https://podatki.gov.pl/scripts/zawbi_banner.js

js podatki.gov.pl collected 2026-09-24 08:27:10 UTC 15,058 bytes, 345 lines download raw bytes

1"use strict";
2
3function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
5(function (root, factory) {
6    if ((typeof module === "undefined" ? "undefined" : _typeof(module)) === 'object' && module.exports) {
7        module.exports = factory(); // CommonJS (Node, bundlery)
8    } else {
9        root.MatomoConsentSDK = factory(); // global w przeglÄdarce
10    }
11})(typeof self !== 'undefined' ? self : void 0, function () {
12    var DEFAULT_CONFIG = {
13        // Czy wymusić pokazanie bannera nawet, jeśli decyzja już była zapisana
14        forceShow: false,
15        // Czy pokazać panel szczegółów i ustawień od razu
16        forceCookiePanel: false,
17        // Czy przed pokazaniem wyczyścić wybór i zgody po stronie Matomo (do testów)
18        resetChoice: false,
19        // Link do polityki prywatności
20        policyUrl: "/polityka-prywatnosci",
21        // Wersja bannera - logowana w eventach Matomo
22        bannerVersion: "1.0.0",
23        // Tabela cookies - włÄcz/wyłÄcz
24        cookieTableEnabled: true,
25        // Wiersze tabeli cookies
26        cookieTableRows: [{
27            name: "_pk_id",
28            purpose: "Identyfikator odwiedzającego (statystyki)",
29            type: "First-party, statystyczne",
30            duration: "~13 mies."
31        }, {
32            name: "_pk_ses",
33            purpose: "Sesja Matomo",
34            type: "First-party, statystyczne",
35            duration: "~30 min"
36        }, {
37            name: "_pk_ref",
38            purpose: "Źródło wejścia",
39            type: "First-party, statystyczne",
40            duration: "~6 mies."
41        }, {
42            name: "mtm_consent",
43            purpose: "Pamięć zgody",
44            type: "First-party, funkcjonalne",
45            duration: "zgodnie z remember*"
46        }, {
47            name: "matomo_sessid",
48            purpose: "Techniczne sesyjne",
49            type: "First-party, techniczne",
50            duration: "sesja"
51        }],
52        // Czy po stronie Matomo masz włÄczonÄ anonimizację IP
53        anonymizeIpEnabled: true
54    };
55    var LS_KEY_CHOICE = 'matomoConsentChoice:v2'; // 'accepted' | 'declined' | 'custom'
56
57    var LS_KEY_ID = 'matomoConsentId:v1';
58    var runtimeConfig = Object.assign({}, DEFAULT_CONFIG);
59    var bannerEl = null;
60    var handlersBound = false; // ---- POMOCNICZE ----
61
62    function getOrCreateConsentId() {
63        var id = null;
64
65        try {
66            id = localStorage.getItem(LS_KEY_ID);
67        } catch (e) { }
68
69        if (!id) {
70            try {
71                id = ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) {
72                    return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16);
73                });
74            } catch (e) {
75                id = String(Date.now());
76            }
77
78            try {
79                localStorage.setItem(LS_KEY_ID, id);
80            } catch (e) { }
81        }
82
83        return id;
84    } // Event do Matomo z JSON-em w polu "name" (e_n)
85
86
87    function sendConsentLog(action, statsEnabled) {
88        var cfg = runtimeConfig || DEFAULT_CONFIG;
89        var consents = {
90            necessary: 1,
91            statistics: statsEnabled ? 1 : 0
92        };
93        var userIpValue = cfg.anonymizeIpEnabled ? "anonymized_or_processed_server_side" : "unknown_on_client";
94        var payload = {
95            "DATE-TIME": new Date().toISOString(),
96            "CONSENT-ID": getOrCreateConsentId(),
97            "CONSENT-URL": location.href,
98            "CONSENTS": consents,
99            "USER-IP": userIpValue,
100            "USER-AGENT": navigator.userAgent,
101            "BANNER-TYPE": "overlay-bottom",
102            "BANNER-VERSION": cfg.bannerVersion || ""
103        };
104        var namePayload;
105
106        try {
107            namePayload = JSON.stringify(payload);
108        } catch (e) {
109            namePayload = String(payload);
110        }
111
112        window._paq = window._paq || [];
113
114        window._paq.push(['trackEvent', 'consent', // kategoria
115            action, // akcja: cookie_accept / cookie_partial / cookie_reject
116            namePayload // name (e_n)
117        ]);
118    }
119
120    function ensureStyle() {
121        // aktualnie style sÄ w osobnym pliku CSS
122        if (document.getElementById('cb2-style')) return;
123        var css = '';
124        var s = document.createElement('style');
125        s.id = 'cb2-style';
126        s.textContent = css;
127        document.head.appendChild(s);
128    }
129
130    function ensureHtml() {
131        var existing = document.getElementById('cb2-banner');
132        if (existing) return existing;
133        var cfg = runtimeConfig || DEFAULT_CONFIG;
134        var tableHtml = "";
135
136        if (cfg.cookieTableEnabled !== false && Array.isArray(cfg.cookieTableRows) && cfg.cookieTableRows.length) {
137            var rowsHtml = cfg.cookieTableRows.map(function (row) {
138                return '<tr>' + '<td>' + (row.name || '') + '</td>' + '<td>' + (row.purpose || '') + '</td>' + '<td>' + (row.type || '') + '</td>' + '<td>' + (row.duration || '') + '</td>' + '</tr>';
139            }).join('');
140            tableHtml = '<div class="cb2-table-container">' + '<table class="cb2-table" cellspacing="0" cellpadding="0" aria-label="Szczegóły plików cookie Matomo">' + '<thead><tr><th>Nazwa</th><th>Cel</th><th>Typ</th><th>Okres</th></tr></thead>' + '<tbody>' + rowsHtml + '</tbody>' + '</table>' + '</div>';
141        }
142
143        var div = document.createElement('div');
144        div.id = 'cb2-banner';
145        div.className = 'cb2-wrap';
146        div.setAttribute('role', 'dialog');
147        div.setAttribute('aria-live', 'polite');
148        div.setAttribute('aria-label', 'Ustawienia plikĂłw cookie');
149        div.setAttribute('data-open', 'false');
150        div.style.display = 'none';
151        div.innerHTML = '<div class="cb2-inner">' + '  <div class="cb2-row">' + '    <div class="cb2-col-text" id="cb2-desc">' + '      <div class="cb2-title">Dbamy o Twoją  prywatność‡</div>' + '      <div class="cb2-desc">' + '        Wykorzystujemy pliki cookie w celu zapewnienia prawidłowego funkcjonowania naszej witryny oraz do analizy ruchu i optymalizacji działania strony.' + '        Dzięki nim możemy lepiej dostosować treści do potrzeb użytkowników i stale ulepszać nasze usługi.' + '        Pamiętaj, że informacje przechowywane w plikach cookie mogą pozwalać na identyfikację konkretnego urządzenia lub przeglądarki użytkownika, a więc potencjalnie stanowią dane osobowe.' + '        <span class="cb2-hint"><a class="cb2-link" href="' + cfg.policyUrl + '" rel="nofollow noopener">Polityka cookies</a></span>' + '      </div>' + '      <div id="cb2-panel" class="cb2-panel form" hidden aria-label="Szczegół‚y i ustawienia">' + '        <ul class="cb2-cats">' + '          <li class="cb2-switch custom-checkbox">' + '            <input type="checkbox" id="cb2-necessary" checked disabled>' + '            <label for="cb2-necessary"><strong>Niezbędne</strong> -- zawsze aktywne, wymagane do prawidłowego działania strony.</label>' + '          </li>' + '          <li class="cb2-switch custom-checkbox">' + '            <input type="checkbox" id="cb2-stats">' + '            <label for="cb2-stats"><strong>Statystyczne</strong> -- pomagają analizować sposób korzystania z serwisu i ulepsza㇠jego działanie.</label>' + '          </li>' + '        </ul>' + tableHtml + '        <div class="cb2-save-container">' + '          <button id="cb2-save" class="btn btn-secondary"><span>Zapisz wybór</span></button>' + '        </div>' + '      </div>' + '    </div>' + '    <div class="cb2-actions" aria-label="Wybór zgody">' + '      <button id="cb2-reject" class="btn btn-secondary"><span>Odrzuć‡</span></button>' + '      <button id="cb2-adjust" class="btn btn-secondary" aria-expanded="false" aria-controls="cb2-panel"><span>Spersonalizuj' + '        <svg xmlns="http://www.w3.org/2000/svg" width="8" height="14" viewBox="0 0 8 14" fill="none" style="margin-left:10px">' + '          <path d="M0.7475 13.4975C0.5575 13.4975 0.3675 13.4275 0.2175 13.2775C-0.0725 12.9875 -0.0725 12.5075 0.2175 12.2175L5.6875 6.7475L0.2175 1.2775C-0.0725 0.9875 -0.0725 0.5075 0.2175 0.2175C0.5075 -0.0725 0.987499 -0.0725 1.2775 0.2175L7.2775 6.2175C7.4175 6.3575 7.4975 6.5475 7.4975 6.7475C7.4975 6.9475 7.4175 7.1375 7.2775 7.2775L1.2775 13.2775C1.1275 13.4275 0.9375 13.4975 0.7475 13.4975Z" fill="#0452A8"/>' + '        </svg></span></button>' + '      <button id="cb2-accept" class="btn btn-primary"><span>Zezwól na wszystkie</span></button>' + '    </div>' + '  </div>' + '</div>';
152        document.body.appendChild(div);
153        return div;
154    }
155
156    function openBanner() {
157        if (!bannerEl) return;
158        bannerEl.style.display = 'block';
159        bannerEl.setAttribute('data-open', 'true');
160    }
161
162    function closeBanner() {
163        if (!bannerEl) return;
164        bannerEl.setAttribute('data-open', 'false');
165        bannerEl.style.display = 'none';
166    }
167
168    function resetChoiceIfNeeded() {
169        var cfg = runtimeConfig || DEFAULT_CONFIG;
170        if (!cfg.resetChoice) return;
171
172        try {
173            localStorage.removeItem(LS_KEY_CHOICE);
174        } catch (e) { }
175
176        try {
177            localStorage.removeItem(LS_KEY_ID);
178        } catch (e) { }
179
180        if (typeof window._paq !== 'undefined') {
181            window._paq.push(['forgetCookieConsentGiven']);
182
183            window._paq.push(['disableCookies']);
184
185            window._paq.push(['deleteCookies']);
186        }
187    }
188
189    function bindHandlersOnce() {
190        if (!bannerEl || handlersBound) return;
191        var btnAcc = bannerEl.querySelector('#cb2-accept');
192        var btnRej = bannerEl.querySelector('#cb2-reject');
193        var btnAdj = bannerEl.querySelector('#cb2-adjust');
194        var btnSave = bannerEl.querySelector('#cb2-save');
195        var panel = bannerEl.querySelector('#cb2-panel');
196        var cbStats = bannerEl.querySelector('#cb2-stats');
197
198        if (!btnAcc || !btnRej || !btnAdj || !btnSave || !panel || !cbStats) {
199            console.warn('[MatomoConsentSDK] Missing DOM elements, banner may not work correctly.');
200            return;
201        } // Spersonalizuj - otwiera panel
202
203
204        btnAdj.addEventListener('click', function () {
205            panel.hidden = !panel.hidden;
206            btnAdj.setAttribute('aria-expanded', String(!panel.hidden));
207
208            if (!panel.hidden && window.matchMedia('(max-width:640px)').matches) {
209                panel.scrollIntoView({
210                    block: 'nearest'
211                });
212            }
213        }); // Akceptacja wszystkich - event: cookie_accept
214
215        btnAcc.addEventListener('click', function () {
216            cbStats.checked = true;
217            window._paq = window._paq || [];
218
219            window._paq.push(['rememberCookieConsentGiven']);
220
221            try {
222                localStorage.setItem(LS_KEY_CHOICE, 'accepted');
223            } catch (e) { }
224
225            sendConsentLog('cookie_accept', true);
226            closeBanner();
227        }); // Odrzucenie - event: cookie_reject
228
229        btnRej.addEventListener('click', function () {
230            cbStats.checked = false;
231            window._paq = window._paq || [];
232
233            window._paq.push(['forgetCookieConsentGiven']);
234
235            window._paq.push(['disableCookies']);
236
237            window._paq.push(['deleteCookies']);
238
239            try {
240                localStorage.setItem(LS_KEY_CHOICE, 'declined');
241            } catch (e) { }
242
243            sendConsentLog('cookie_reject', false);
244            closeBanner();
245        }); // Zapisz wybĂłr z panelu - event: cookie_partial
246
247        btnSave.addEventListener('click', function () {
248            var enableStats = cbStats.checked;
249            window._paq = window._paq || [];
250
251            if (enableStats) {
252                window._paq.push(['rememberCookieConsentGiven']);
253                try {
254                    localStorage.setItem(LS_KEY_CHOICE, 'custom');
255                } catch (e) { }
256            } else {
257                window._paq.push(['forgetCookieConsentGiven']);
258
259                window._paq.push(['disableCookies']);
260
261                window._paq.push(['deleteCookies']);
262                try {
263                    localStorage.setItem(LS_KEY_CHOICE, 'customNO');
264                } catch (e) { }
265            }
266
267           
268
269            sendConsentLog('cookie_partial', enableStats);
270            closeBanner();
271        });
272        handlersBound = true;
273    } // ---- API SDK ----
274
275
276    function init(options) {
277        runtimeConfig = Object.assign({}, runtimeConfig, options || {});
278        return runtimeConfig;
279    }
280
281    function showBanner(options) {
282        runtimeConfig = Object.assign({}, runtimeConfig, options || {});
283        ensureStyle();
284        bannerEl = ensureHtml();
285
286        if (runtimeConfig.forceCookiePanel === true) {
287            var panel = bannerEl.querySelector('#cb2-panel');
288            var btnAdj = bannerEl.querySelector('#cb2-adjust');
289            panel.hidden = false;
290            btnAdj.setAttribute('aria-expanded', String(panel.hidden));
291        }
292
293        resetChoiceIfNeeded();
294        var saved = null;
295
296        try {
297            saved = localStorage.getItem(LS_KEY_CHOICE);
298        } catch (e) { }
299
300        if (!saved || runtimeConfig.forceShow) {
301            console.log('[MatomoConsentSDK] Showing consent banner - saved', saved);
302            console.log('[MatomoConsentSDK] Config:', runtimeConfig);
303            openBanner();
304        }
305
306        bindHandlersOnce();
307        return bannerEl;
308    }
309
310    function resetConsent() {
311        try {
312            localStorage.removeItem(LS_KEY_CHOICE);
313        } catch (e) { }
314
315        try {
316            localStorage.removeItem(LS_KEY_ID);
317        } catch (e) { }
318
319        if (typeof window._paq !== 'undefined') {
320            window._paq.push(['forgetCookieConsentGiven']);
321
322            window._paq.push(['disableCookies']);
323
324            window._paq.push(['deleteCookies']);
325        }
326    }
327
328    function getConsentState() {
329        try {
330            return localStorage.getItem(LS_KEY_CHOICE);
331        } catch (e) {
332            return null;
333        }
334    }
335
336    return {
337        init: init,
338        showBanner: showBanner,
339        resetConsent: resetConsent,
340        getConsentState: getConsentState,
341        _getCurrentConfig: function _getCurrentConfig() {
342            return runtimeConfig;
343        }
344    };
345});

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.