1/* 2 * Tento soubor je souÄástà projektu GCM. 3 * 4 * Copyright 2021 Galileo Corporation s.r.o. All rights reserved. 5 */ 6'use strict'; 7 8/** 9 * SpouÅ¡tà javascript dle požadované úrovnÄ souhlasu 10 * 11 * @type {{allowElements: CookiesConsent.allowElements, getConsentsFromCookie: ((function(): (*|[string]))|*)}} 12 */ 13let CookiesConsent = { 14 /** 15 * Read consents from cookie if exists 16 */ 17 getConsentsFromCookie: () => { 18 if (document.cookie.split('; ').find((row) => row.startsWith('igalileo_gcm_cookies_consent'))) { 19 const cookieValue = document.cookie 20 .split('; ') 21 .find((row) => row.startsWith('igalileo_gcm_cookies_consent=')) 22 .split('=')[1]; 23 24 return JSON.parse(cookieValue); 25 } 26 27 return {}; 28 }, 29 30 /** 31 * Check if has consent for google 32 * 33 * @returns {boolean} 34 */ 35 hasConsentForGoogleAnalytics: () => { 36 const consents = CookiesConsent.getConsentsFromCookie(); 37 38 return 'statistics' in consents && consents.statistics; 39 }, 40 41 /** 42 * Check if has consent for google 43 * 44 * @returns {boolean} 45 */ 46 hasConsentForGoogleAnalyticsMarketing: () => { 47 const consents = CookiesConsent.getConsentsFromCookie(); 48 49 return 'marketing' in consents && consents.marketing; 50 }, 51 52 /** 53 * Check if has consent for google 54 * 55 * @returns {string} 56 */ 57 getConsentForGoogleAnalytics: () => { 58 const consents = CookiesConsent.getConsentsFromCookie(); 59 const googleConsent = { ad_storage: 'denied', analytics_storage: 'denied', marketing_storage: 'denied' }; 60 61 if ('statistics' in consents && consents.statistics) { 62 googleConsent.ad_storage = 'granted'; 63 googleConsent.analytics_storage = 'granted'; 64 } 65 66 if ('marketing' in consents && consents.marketing) { 67 googleConsent.marketing_storage = 'granted'; 68 } 69 70 return googleConsent; 71 }, 72 73 /** 74 * Run javascripts 75 */ 76 allowElements: () => { 77 const cookiesConsents = CookiesConsent.getConsentsFromCookie(); 78 const kioskOverride = window.navigator.userAgent.includes('igalileo_kiosek'); 79 80 document.querySelectorAll('[data-cookies-consent]').forEach((element) => { 81 const requiredConsentType = element.getAttribute('data-cookies-consent'); 82 83 if ( 84 kioskOverride || 85 (requiredConsentType in cookiesConsents && cookiesConsents[requiredConsentType] === true) 86 ) { 87 const dataSrcAttributte = element.getAttribute('data-src'); 88 89 if (dataSrcAttributte !== null) { 90 element.removeAttribute('data-src'); 91 element.setAttribute('src', dataSrcAttributte); 92 } 93 94 if (element.nodeName === 'SCRIPT') { 95 let node = document.createElement('script'); 96 node.append(element.innerHTML); 97 element.parentNode.replaceChild(node, element); 98 } 99 } 100 }); 101 102 if (kioskOverride || ('marketing' in cookiesConsents && cookiesConsents.marketing === true)) { 103 document.querySelectorAll('.social-network-button-wrapper').forEach((e) => { 104 e.classList.remove('d-none'); 105 }); 106 } 107 108 if ( 109 (kioskOverride || 110 CookiesConsent.hasConsentForGoogleAnalytics() || 111 CookiesConsent.hasConsentForGoogleAnalyticsMarketing()) && 112 typeof gtag === 'function' 113 ) { 114 gtag('consent', 'update', CookiesConsent.getConsentForGoogleAnalytics()); 115 } 116 }, 117}; 118 119document.addEventListener('DOMContentLoaded', CookiesConsent.allowElements);
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.