PageSourceSearch

https://www.skills.sk/js/skilllab-consent.js

js skills.sk collected 2026-10-08 23:34:11 UTC 4,606 bytes, 101 lines download raw bytes

1/*!
2 * Skill Lab - súhlas s cookies (Google Consent Mode v2 + Meta Pixel)
3 *
4 * Ako to funguje:
5 *  - Voľba návštevníka sa ukladá do localStorage pod kľúčom "sl_consent"
6 *    ("all" = všetko povolené, "necessary" = len nevyhnutné).
7 *  - Inline skript v <head> každej stránky si voľbu prečíta ešte PRED
8 *    načítaním Google Analytics a Meta Pixelu a nastaví:
9 *        gtag('consent','default', ...)   a   window.SL_CONSENT
10 *  - Tento súbor len zobrazí lištu (ak voľba ešte nie je) a po kliknutí
11 *    zavolá gtag('consent','update') + window.slConsentGranted().
12 *  - Odkaz "Nastavenia cookies" v pätičke volá window.slOpenConsent().
13 */
14(function () {
15  'use strict';
16
17  var KEY = 'sl_consent';
18  var POLICY_URL = '/vop/';
19
20  // Voľba sa ukladá do localStorage (tento web) aj do cookie pre celú doménu
21  // .skills.sk, aby ju vedel prečítať aj rezervačný systém www2.skills.sk.
22  function readCookie() {
23    var m = document.cookie.match(/(?:^|;\s*)sl_consent=(all|necessary)(?:;|$)/);
24    return m ? m[1] : null;
25  }
26  function read() {
27    var v = null;
28    try { v = localStorage.getItem(KEY); } catch (e) {}
29    return v || readCookie();
30  }
31  function save(v) {
32    try { localStorage.setItem(KEY, v); } catch (e) {}
33    var domain = /(^|\.)skills\.sk$/i.test(location.hostname) ? '; Domain=.skills.sk' : '';
34    document.cookie = KEY + '=' + v + '; Path=/; Max-Age=31536000; SameSite=Lax' + domain +
35      (location.protocol === 'https:' ? '; Secure' : '');
36  }
37
38  function consentState(granted) {
39    var v = granted ? 'granted' : 'denied';
40    return { ad_storage: v, ad_user_data: v, ad_personalization: v, analytics_storage: v };
41  }
42
43  function applyChoice(all) {
44    save(all ? 'all' : 'necessary');
45    if (typeof window.gtag === 'function') {
46      window.gtag('consent', 'update', consentState(all));
47    }
48    if (all) {
49      window.SL_CONSENT = true;
50      if (typeof window.slConsentGranted === 'function') window.slConsentGranted();
51    }
52  }
53
54  var box = null;
55
56  function close() {
57    if (box && box.parentNode) box.parentNode.removeChild(box);
58    box = null;
59  }
60
61  function render() {
62    if (box) return;
63    box = document.createElement('div');
64    box.id = 'sl-consent';
65    box.setAttribute('role', 'dialog');
66    box.setAttribute('aria-label', 'Nastavenia cookies');
67    box.innerHTML =
68      '<style>' +
69      '#sl-consent{position:fixed;left:1rem;right:1rem;bottom:1rem;z-index:10000;max-width:34rem;margin:0 auto;' +
70        'background:#fff;color:#111827;border:1px solid #e5e7eb;border-radius:1rem;box-shadow:0 12px 40px rgba(0,0,0,.14);' +
71        'padding:1.125rem 1.25rem;font-family:Barlow,system-ui,sans-serif;font-size:.875rem;line-height:1.5}' +
72      '#sl-consent h2{font-family:"Barlow Condensed",Barlow,sans-serif;font-weight:900;font-size:1.125rem;text-transform:uppercase;margin:0 0 .375rem}' +
73      '#sl-consent p{margin:0 0 .875rem;color:#4b5563}' +
74      '#sl-consent a{color:#b02a32;text-decoration:underline}' +
75      '#sl-consent .sl-c-btns{display:flex;gap:.5rem;flex-wrap:wrap}' +
76      '#sl-consent button{font:inherit;font-weight:700;padding:.625rem 1.125rem;border-radius:10px;cursor:pointer;border:1.5px solid #b02a32}' +
77      '#sl-consent .sl-c-all{background:#b02a32;color:#fff}' +
78      '#sl-consent .sl-c-nec{background:#fff;color:#b02a32}' +
79      '#sl-consent button:focus-visible{outline:3px solid #111827;outline-offset:2px}' +
80      '@media(max-width:480px){#sl-consent{left:.5rem;right:.5rem;bottom:.5rem}#sl-consent button{flex:1 1 auto}}' +
81      '</style>' +
82      '<h2>Cookies na tomto webe</h2>' +
83      '<p>Nevyhnutné cookies fungujú vždy. Ak súhlasíte, použijeme aj cookies na meranie návštevnosti ' +
84      '(Google Analytics) a účinnosti reklamy (Meta Pixel). Voľbu môžete kedykoľvek zmeniť v pätičke. ' +
85      '<a href="' + POLICY_URL + '">Viac o spracúvaní údajov</a></p>' +
86      '<div class="sl-c-btns">' +
87        '<button type="button" class="sl-c-all">Prijať všetko</button>' +
88        '<button type="button" class="sl-c-nec">Len nevyhnutné</button>' +
89      '</div>';
90    document.body.appendChild(box);
91    box.querySelector('.sl-c-all').addEventListener('click', function () { applyChoice(true); close(); });
92    box.querySelector('.sl-c-nec').addEventListener('click', function () { applyChoice(false); close(); });
93    box.querySelector('.sl-c-all').focus({ preventScroll: true });
94  }
95
96  window.slOpenConsent = render;
97
98  if (!read()) {
99    if (document.body) render(); else document.addEventListener('DOMContentLoaded', render);
100  }
101})();

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.