PageSourceSearch

https://alumni.vse.cz/wp-content/themes/vse-redesigned/js/cookieconsent.js?ver=20260923

js vse.cz collected 2026-09-24 08:29:15 UTC 8,560 bytes, 229 lines download raw bytes

1"use strict";
2
3(function ($, root) {
4  $(function () {
5    var PRIVACY_API_URL='https://weby.vse.cz/privacy-api/consent';
6
7    function updateGoogleConsent(serviceConsentList){
8      window.dataLayer = window.dataLayer || [];
9      function gtag(){dataLayer.push(arguments);}
10
11      var adstorage = (serviceConsentList.gads ? 'granted' : 'denied');
12      var consentData = {
13        'analytics_storage':(serviceConsentList.ga ? 'granted' : 'denied'),
14        'ad_storage':adstorage,
15        'ad_user_data':adstorage,
16        'ad_personalization':(serviceConsentList.gads && serviceConsentList.gads_personalization ? 'granted' : 'denied'),
17      };
18      $.each(serviceConsentList, function(service, consent){
19        consentData['service_'+service+'_storage']=(consent ? 'granted' : 'denied');
20      });
21
22      gtag('consent', 'update', consentData);
23      consentData.event='custom_consent';
24      dataLayer.push(consentData);
25    }
26
27    /**
28     * @param name : string
29     * @param value : string
30     * @param expirationInDays : number
31     */
32    function setCookie(name, value, expirationInDays){
33      expirationInDays = typeof expirationInDays !== 'undefined' ? expirationInDays : 0;
34      var d = new Date();
35      d.setTime(d.getTime() + (expirationInDays*86400*1000));
36      document.cookie = name+"="+encodeURIComponent(value)+"; "+(expirationInDays!==0?'expires='+d.toUTCString()+'; ':'')+(location.hostname.substr(-7).toLowerCase()==='.vse.cz'?'Domain=.vse.cz; ':'')+"Path=/;SameSite=None; Secure";
37    }
38
39    /**
40     * @param name : string
41     * @return {string}
42     */
43    function getCookie(name) {
44      var ca = decodeURIComponent(document.cookie).split(';');
45      for(let i = 0; i <ca.length; i++) {
46        let c = ca[i];
47        while (c.charAt(0) === ' ') {
48          c = c.substring(1);
49        }
50        if (c.indexOf(name+'=') === 0) {
51          return c.substring(name.length+1, c.length);
52        }
53      }
54      return "";
55    }
56
57    function generateUUID() {
58      // Pokud prohlížeč podporuje crypto.randomUUID()
59      if (crypto && crypto.randomUUID) {
60        return crypto.randomUUID();
61      }
62
63      // Fallback pomocí crypto.getRandomValues()
64      if (crypto && crypto.getRandomValues) {
65        var array = new Uint8Array(16);
66        crypto.getRandomValues(array);
67
68        // Nastavení verzí a varianty UUID (verze 4)
69        array[6] = (array[6] & 0x0f) | 0x40; // verze 4
70        array[8] = (array[8] & 0x3f) | 0x80; // variant
71
72        var hex = Array.from(array, b => b.toString(16).padStart(2, '0')).join('');
73        return (
74          hex.slice(0, 8) + '-' +
75          hex.slice(8, 12) + '-' +
76          hex.slice(12, 16) + '-' +
77          hex.slice(16, 20) + '-' +
78          hex.slice(20, 32)
79        );
80      }
81
82      // Poslední fallback: čistě JS Math.random (méně bezpečné)
83      return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
84        var r = Math.random() * 16 | 0;
85        var v = c === 'x' ? r : (r & 0x3 | 0x8);
86        return v.toString(16);
87      });
88    }
89
90    function setCookieConsentData(version,allow){
91      var consentData=getCookieConsentData();
92      var uuid = (consentData.hasOwnProperty('uuid') && consentData.uuid!=='') ? consentData.uuid : generateUUID();
93
94      var consentJson=JSON.stringify({version:version,uuid:uuid,allow:allow});
95      setCookie('vse_cookie_consent', consentJson, 365);
96      $.ajax({
97        url:PRIVACY_API_URL,
98        type:'POST',
99        contentType:'application/json',
100        dataType:'json',
101        data:consentJson
102      });
103    }
104
105    function getCookieConsentData(){
106      try{
107        var data = JSON.parse(getCookie('vse_cookie_consent') || '{}');
108        return {
109          version:data.hasOwnProperty('version') ? data.version : '',
110          uuid:data.hasOwnProperty('uuid') ? data.uuid : '',
111          allow:data.hasOwnProperty('allow') ? data.allow : []
112        }
113      }catch(e){
114        return {
115          version:'',
116          uuid:'',
117          allow:[]
118        }
119      }
120    }
121
122    var cookieconsent = $('#cookieconsent');
123
124    function prepareControlStates(){
125      var cookieConsentData = getCookieConsentData();
126      if (cookieConsentData.version!==cookieconsent.data('version')){
127        cookieconsent.find('.cookieconsent-switch-input').prop('checked',true);
128      }else{
129        cookieconsent.find('.cookieconsent-switch-input').prop('checked',false);
130        jQuery.each(cookieConsentData.allow, function(index, service) {
131          cookieconsent.find('.cookieconsent-switch-input[value="'+service+'"]').prop('checked',true);
132        });
133      }
134    }
135
136    function showCookieConsent(){
137      cookieconsent.removeClass('d-none');
138      cookieconsent.attr('aria-hidden','false');
139      cookieconsent.find('a[href],button').first().focus();
140    }
141
142    cookieconsent.find('button.cookieconsent-accept-all').click(function(e){
143      e.preventDefault();
144      //uživatel chce povolit vše
145      var services = [];
146      cookieconsent.find('.cookieconsent-switch-input').each(function(){
147        services.push($(this).val());
148      });
149      setCookieConsentData(cookieconsent.data('version'),services);
150
151      cookieconsent.addClass('d-none');
152      var consentServices = {};
153      cookieconsent.find('input.cookieconsent-switch-input').each(function(){
154        $(this).prop('checked',true);
155        consentServices[$(this).val()]=true;
156      });
157      cookieconsent.find('#cookieconsent-gads').change();
158      updateGoogleConsent(consentServices);
159    });
160    cookieconsent.find('button.cookieconsent-accept-none').click(function(e){
161      e.preventDefault();
162      //uživatel chce zakázat vše
163      setCookieConsentData(cookieconsent.data('version'),[]);
164      cookieconsent.addClass('d-none');
165      var consentServices = {};
166      cookieconsent.find('input.cookieconsent-switch-input').each(function(){
167        $(this).prop('checked',false);
168        consentServices[$(this).val()]=false;
169      });
170      cookieconsent.find('#cookieconsent-gads').change();
171      updateGoogleConsent(consentServices);
172    });
173    cookieconsent.find('button.cookieconsent-save-customized').click(function(e){
174      e.preventDefault();
175      //uživatel ukládá vlastní nastavení
176      var result = [];
177      var consentServices = {};
178      cookieconsent.find('.cookieconsent-switch-input').each(function(){
179        var cookieService = $(this).val();
180        if ($(this).is(':checked')){
181          result.push(cookieService);
182          consentServices[cookieService]=true;
183        }else{
184          consentServices[cookieService]=false;
185        }
186      });
187      setCookieConsentData(cookieconsent.data('version'),result)
188      cookieconsent.addClass('d-none');
189      cookieconsent.attr('aria-hidden','true');
190      //nastavení stavu GA
191      updateGoogleConsent(consentServices);
192    });
193    cookieconsent.find('button.cookieconsent-customize').click(function(e){
194      e.preventDefault();
195      //zobrazení podrobného nastavení
196      prepareControlStates();
197      cookieconsent.find('.cookieconsent-buttons').addClass('d-none');
198      cookieconsent.find('.cookieconsent-customization').removeClass('d-none');
199    });
200    cookieconsent.find('button.cookieconsent-cancel-customized').click(function(e){
201      e.preventDefault();
202      //skrytí podrobného nastavení
203      cookieconsent.find('.cookieconsent-buttons').removeClass('d-none');
204      cookieconsent.find('.cookieconsent-customization').addClass('d-none');
205      if (getCookieConsentData().version===cookieconsent.data('version')){
206        //skrytí consentu (už je něco nastaveno)
207        cookieconsent.addClass('d-none');
208        cookieconsent.attr('aria-hidden','true');
209      }
210    });
211
212    cookieconsent.find('#cookieconsent-gads').change(function(e){
213      e.preventDefault();
214      cookieconsent.find('#cookieconsent-gads_personalization').prop('disabled',!$(this).is(':checked'));
215    }).change();
216    //cookieconsent.find('#cookieconsent-gads_personalization').prop('disabled',!$(this).is(':checked'));
217
218    //kontrola, jestli se má zobrazit nastavení cookies
219    if (getCookieConsentData().version!==cookieconsent.data('version')){
220      showCookieConsent();
221    }
222
223    $('.cookieconsent-show').click(function(e){
224      e.preventDefault();
225      showCookieConsent();
226    });
227
228  });
229})(jQuery, this);

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.