1/* 2 * Tento soubor je souÄástà projektu GCM. 3 * 4 * Copyright 2021 Galileo Corporation s.r.o. All rights reserved. 5 */ 6 7const Widget = { 8 element: null, 9 consents: {}, 10 availableConsents: {}, 11 /** 12 * Init method 13 */ 14 init: () => { 15 if (Object.keys(CookiesConsent.getConsentsFromCookie()).length > 0) { 16 return; 17 } 18 19 Widget.loadBasic(); 20 21 document.addEventListener('click', (e) => { 22 if (e.target && e.target.id === 'cookies-consent-detail') { 23 e.preventDefault(); 24 Widget.loadDetail(); 25 26 return; 27 } 28 29 if (e.target && e.target.id === 'cookies-consent-close') { 30 e.preventDefault(); 31 Widget.remove(); 32 33 return; 34 } 35 36 if (e.target && e.target.id === 'cookies-consent-accept-all') { 37 Widget.consents = Widget.availableConsents; 38 Widget.setCookie(); 39 Widget.remove(); 40 CookiesConsent.allowElements(); 41 } 42 43 if (e.target && e.target.id === 'cookies-consent-accept-selected') { 44 Widget.consents = Widget.getCheckedOptions(); 45 Widget.setCookie(); 46 Widget.remove(); 47 CookiesConsent.allowElements(); 48 } 49 50 if (e.target && e.target.id === 'cookies-consent-reject') { 51 for (consentType in Widget.availableConsents) { 52 Widget.consents[consentType] = consentType === 'functional'; 53 } 54 Widget.setCookie(); 55 Widget.remove(); 56 } 57 }); 58 }, 59 60 /** 61 * Remove widget from DOM 62 */ 63 remove: () => { 64 document.getElementById('cookie_consent').remove(); 65 }, 66 67 /** 68 * Render widget into DOM 69 * 70 * @param data 71 */ 72 render: (data) => { 73 Widget.element = document.getElementById('cookie_consent'); 74 75 if (Widget.element != null) { 76 Widget.element.remove(); 77 } 78 79 const skipLinks = document.querySelector( 80 '.gcm-skip-links, .gcm-skip-link__container, .skip-links, .skip-link__container', 81 ); 82 83 if (skipLinks !== null) { 84 skipLinks.insertAdjacentHTML('afterend', data); 85 } else { 86 document.body.insertAdjacentHTML('afterbegin', data); 87 } 88 89 Widget.element = document.getElementById('cookie_consent'); 90 91 Widget.availableConsents = JSON.parse(Widget.element.getAttribute('data-available-consents')); 92 }, 93 94 /** 95 * Set cookie consent 96 */ 97 setCookie: () => { 98 document.cookie = 99 'igalileo_gcm_cookies_consent=' + 100 JSON.stringify(Widget.consents) + 101 '; SameSite=Strict; path=/; expires=Fri, 31 Dec 9999 23:59:59 GMT'; 102 }, 103 104 /** 105 * Return checked options of detail settings 106 * 107 */ 108 getCheckedOptions: () => { 109 if (Widget.element == null) { 110 return []; 111 } 112 113 const consents = {}; 114 115 Widget.element.querySelectorAll('input[type="checkbox"]').forEach((element) => { 116 consents[element.value] = element.checked; 117 }); 118 119 return consents; 120 }, 121 122 /** 123 * Load basic widget 124 */ 125 loadBasic: () => { 126 fetch(`/modules/CookiesConsent/ax_widget.php?lang=${window.gcm.lang}`) 127 .then((response) => response.text()) 128 .then(Widget.render); 129 }, 130 131 /** 132 * Load widget with detail settings 133 */ 134 loadDetail: () => { 135 fetch(`/modules/CookiesConsent/ax_widget.php?detail=1&lang=${window.gcm.lang}`) 136 .then((response) => response.text()) 137 .then(Widget.render); 138 }, 139}; 140 141Widget.init();
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.