PageSourceSearch

https://cravinhos.sp.gov.br/js/cookie-consent.js?v=b1dbfb37

js cravinhos.sp.gov.br collected 2026-10-02 13:39:07 UTC 5,716 bytes, 112 lines download raw bytes

1/* Consentimento de cookies/armazenamento — LGPD (Lei 13.709/2018).
2 *
3 * O portal NÃO usa rastreadores de terceiros. O único processamento não
4 * essencial é a ESTATÍSTICA de cliques (anonimizada por hash de IP, sem
5 * cookie) — fica como opt-in. Itens essenciais/funcionais (preferências de
6 * acessibilidade, favoritos, service worker) não dependem de consentimento.
7 *
8 * Módulo compartilhado pelo root (/) e pelo portal (/site/). Expõe:
9 *   window.agilizaConsent = { has(cat), decided(), open(), accept(), reject() }
10 * e dispara o evento 'agiliza:consent' quando a decisão muda.
11 */
12(function () {
13    'use strict';
14
15    var KEY = 'agiliza:consent';
16    var VERSION = 1;
17    var PRIVACY_URL = '/site/politica-de-privacidade/';
18
19    function read() {
20        try { return JSON.parse(localStorage.getItem(KEY) || 'null'); } catch (e) { return null; }
21    }
22    function decided() { var c = read(); return !!(c && c.v === VERSION); }
23    function has(cat) { var c = read(); return !!(c && c.v === VERSION && c[cat]); }
24    function save(statistics) {
25        try { localStorage.setItem(KEY, JSON.stringify({ v: VERSION, statistics: !!statistics, ts: Date.now() })); } catch (e) {}
26        try { document.dispatchEvent(new CustomEvent('agiliza:consent')); } catch (e) {}
27    }
28
29    function injectStyles() {
30        if (document.getElementById('cookie-consent-style')) return;
31        var s = document.createElement('style');
32        s.id = 'cookie-consent-style';
33        s.textContent = [
34            '.cookie-consent{position:fixed;left:0;right:0;bottom:0;z-index:1080;',
35            'background:#0c326f;color:#fff;box-shadow:0 -2px 12px rgba(0,0,0,.25);',
36            'font-family:inherit;font-size:.9rem;line-height:1.45}',
37            '.cookie-consent .cc-inner{max-width:1200px;margin:0 auto;padding:14px 20px;',
38            'display:flex;gap:16px;align-items:center;flex-wrap:wrap;justify-content:space-between}',
39            '.cookie-consent .cc-text{flex:1 1 420px;min-width:260px}',
40            '.cookie-consent .cc-text a{color:#fff;text-decoration:underline;font-weight:600}',
41            '.cookie-consent .cc-actions{display:flex;gap:8px;flex-wrap:wrap}',
42            '.cookie-consent .cc-actions button{cursor:pointer;border-radius:100px;border:1px solid #fff;',
43            'padding:7px 18px;font-weight:600;font-size:.85rem;font-family:inherit}',
44            '.cookie-consent .cc-accept{background:#fff;color:#0c326f}',
45            '.cookie-consent .cc-reject{background:transparent;color:#fff}',
46            '.cookie-consent .cc-accept:hover{background:#e8eef5}',
47            '.cookie-consent .cc-reject:hover{background:rgba(255,255,255,.12)}',
48            '@media (max-width:600px){.cookie-consent .cc-inner{flex-direction:column;align-items:stretch}',
49            '.cookie-consent .cc-actions{justify-content:flex-end}}'
50        ].join('');
51        document.head.appendChild(s);
52    }
53
54    function close() {
55        var b = document.getElementById('cookie-consent');
56        if (b && b.parentNode) b.parentNode.removeChild(b);
57    }
58
59    function render() {
60        injectStyles();
61        close();
62        var bar = document.createElement('section');
63        bar.id = 'cookie-consent';
64        bar.className = 'cookie-consent';
65        bar.setAttribute('role', 'dialog');
66        bar.setAttribute('aria-label', 'Aviso de privacidade e cookies');
67        bar.insertAdjacentHTML('beforeend', ''
68            + '<div class="cc-inner">'
69            +   '<div class="cc-text">'
70            +     '<strong>Privacidade e cookies.</strong> Usamos armazenamento local para lembrar suas '
71            +     'preferências (acessibilidade, favoritos) e coletamos estatísticas de uso '
72            +     '<strong>anonimizadas</strong> para melhorar os serviços. Não utilizamos rastreadores de '
73            +     'terceiros. Veja a <a href="' + PRIVACY_URL + '">Política de Privacidade</a>.'
74            +   '</div>'
75            +   '<div class="cc-actions">'
76            +     '<button type="button" class="cc-reject" data-consent="reject">Rejeitar não essenciais</button>'
77            +     '<button type="button" class="cc-accept" data-consent="accept">Aceitar</button>'
78            +   '</div>'
79            + '</div>');
80        document.body.appendChild(bar);
81        bar.querySelector('[data-consent="accept"]').addEventListener('click', function () { save(true); close(); });
82        bar.querySelector('[data-consent="reject"]').addEventListener('click', function () { save(false); close(); });
83    }
84
85    function init() { if (!decided()) render(); }
86
87    window.agilizaConsent = {
88        has: has,
89        decided: decided,
90        open: render,
91        accept: function () { save(true); close(); },
92        reject: function () { save(false); close(); }
93    };
94
95    // Reabrir o aviso pelo link "Preferências de cookies" (rodapé). Delegação no
96    // documento — funciona para links injetados depois e SEM onclick inline
97    // (a CSP do portal bloqueia handlers inline).
98    document.addEventListener('click', function (e) {
99        var t = e.target.closest ? e.target.closest('[data-cookie-prefs]') : null;
100        if (t) { e.preventDefault(); render(); }
101    });
102
103    // Mostra o aviso só após o load + ocioso: o banner é fixo (não empurra
104    // conteúdo), mas adiá-lo para fora da janela crítica evita que seu texto
105    // entre na contagem de layout shift (CLS) durante a montagem da página.
106    function deferInit() {
107        var ric = window.requestIdleCallback || function (cb) { return setTimeout(cb, 200); };
108        ric(init);
109    }
110    if (document.readyState === 'complete') deferInit();
111    else window.addEventListener('load', deferInit);
112})();

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.