PageSourceSearch

https://www.elotoman.cz/templates/widgets/CookieOptOut/js/CookieOptOut.js?v=1718282985

js elotoman.cz collected 2026-10-09 17:08:22 UTC 10,381 bytes, 299 lines download raw bytes

1if (typeof Object.assign != "function") {
2    Object.assign = function (target) {
3        "use strict";
4        if (target == null) {
5            throw new TypeError("Cannot convert undefined or null to object");
6        }
7
8        target = Object(target);
9        for (var index = 1; index < arguments.length; index++) {
10            var source = arguments[index];
11            if (source != null) {
12                for (var key in source) {
13                    if (Object.prototype.hasOwnProperty.call(source, key)) {
14                        target[key] = source[key];
15                    }
16                }
17            }
18        }
19        return target;
20    };
21}
22
23(function (window, document, $) {
24    "use strict";
25
26    var privateVariable;
27
28    var privateFunction = function (arg) {
29        return arg;
30    };
31
32    window.publicVariable = 1;
33
34    var publicFunction = function () {
35        window.publicVariable = privateVariable;
36    };
37    window.publicFunction = publicFunction;
38
39
40    $(function () {
41        privateVariable = privateFunction(1);
42        publicFunction(); // nebo window.publicFunction();
43    });
44})(window, document, jQuery);
45
46// zde lze nacist window.publicVariable a zavolat window.publicFunction(); ale privateVariable a privateFunction uz neexistuji ...
47
48
49// uprav kod dole podle sablony nahore - napr. metoda addBlockDiv je pravdepodobne volana pouze tady a neni v planu ji volat od jinud takze by mela bejt privatni ....
50// proc? protoze nejakej jinej javascript muze pouzit stejny nazev funkce a bude v tom akorat gulas ...
51// navic se ten kod bude pravdepodobne rozsirovat, tak je lepsi to udelat ted dokud je relativne malej ...
52/////////////////////
53
54var cookieOptOutDefaultConsent = {
55    ad_storage: "denied",
56    analytics_storage: "denied",
57    functionality_storage: "denied",
58    personalization_storage: "denied",
59    security_storage: "denied",
60    ad_user_data: "denied",
61    ad_personalization: "denied"
62};
63
64var cookieOptOutConsent = cookieOptOutDefaultConsent;
65
66var blockAdsIframes = true;
67
68var iFrameSrcParts = ["google", "youtube"];//, "vimeo"
69
70window.blockIframes = function (cookieObj) {
71    if (!blockAdsIframes) return;
72
73    var forcedValue = cookieObj == undefined || cookieObj == null ? null : cookieObj["ad_storage"] == "granted";
74
75    var isAdsAllowed = forcedValue || cookieOptOutGet("ad_storage") == "granted";
76    var iframes = Array.from(document.querySelectorAll("iframe"));
77
78    if (!isAdsAllowed) {
79        iframes.forEach(frame => {
80            var frameNotAllowed = false;
81            iFrameSrcParts.forEach(part => {
82                frameNotAllowed = frameNotAllowed || frame.src.indexOf(part) !== -1;
83            });
84            if (frameNotAllowed) {
85                frame.setAttribute("data-blocked-src", frame.src);
86                frame.src = "";
87                addBlockDiv(frame, true);
88            }
89        });
90    } else {
91        var iframesBlocked = Array.from(document.querySelectorAll("iframe[data-blocked-src]"));
92        iframesBlocked.forEach(frame => {
93            frame.src = frame.getAttribute("data-blocked-src");
94            addBlockDiv(frame, false);
95        });
96    }
97}
98
99window.addBlockDiv = function (frame, add) {
100    if (add) {
101        var frameBounds = frame.getBoundingClientRect();
102        console.log(frameBounds);
103        var d = document.createElement("div");
104        d.className = "blockIframeDiv";
105        d.setAttribute("style", "display:flex; justify-items:center; align-items:center;position:absolute; left:0; top:0; background-color: gray;");
106        d.style.width = "100%";//frameBounds.width + "px";
107        d.style.height = "100%";//frameBounds.height + "px";
108
109        var a = document.createElement("a");
110        a.href = "javascript: openCookieOptOut('true')";
111        a.innerText = "Nastavit cookies";
112        a.setAttribute("style", "color:white;width: 100%;display: block;text-align: center;");
113        d.appendChild(a);
114
115        frame.parentNode.setAttribute("data-old-position", frame.style.position);
116        frame.parentNode.style.position = "relative";
117        frame.parentNode.appendChild(d);
118        return;
119    }
120
121    var ifDiv = frame.parentNode.querySelector(".blockIframeDiv");
122    frame.parentNode.style.position = frame.getAttribute("data-old-position");
123    if (ifDiv != undefined && ifDiv != null) {
124        ifDiv.remove();
125    }
126}
127
128window.cookieOptOutGtag = function () {
129    if (window.dataLayer) {
130        window.dataLayer.push(arguments);
131    }
132};
133
134window.cookieOptOutPost = function (state) {
135    state = state || "update";
136
137    if (!window.dataLayer) {
138        console.log("no dataLayer: cookieOptOutPost('" + state + "')");
139        return;
140    }
141
142    var fakeCookieOptOutConsent = Object.assign({}, cookieOptOutConsent);
143    if (state == "default") {
144        fakeCookieOptOutConsent["wait_for_update"] = 5000;
145        window.dataLayer.push({ 'event': "cookie_consent_default" });
146    } else {
147        window.dataLayer.push({ 'event': "cookie_consent_update" });
148    }
149
150	/*if(state != "update"){
151		fakeCookieOptOutConsent.add_user_data = "denied";
152		fakeCookieOptOutConsent.add_personalization = "denied";
153	} else {
154		fakeCookieOptOutConsent.add_user_data = "granted";
155		fakeCookieOptOutConsent.add_personalization = "granted";
156	}*/
157
158    cookieOptOutGtag("consent", state, fakeCookieOptOutConsent);
159    blockIframes(fakeCookieOptOutConsent);
160    hideInPageOptOutForm();
161}
162
163var cookieOptOutConsentCookie;
164
165var cookieOptOutStatus;
166
167window.cookieOptOutSetConsent = function (key, allowed) {
168    var state = ["denied", "granted"];
169    cookieOptOutConsent[key] = state[allowed];
170    EwUtils.setCookie("_GTM_Consent", JSON.stringify(cookieOptOutConsent), { days: 1000 });
171    if (key == "ad_storage") {
172        blockIframes(cookieOptOutConsent);
173    }
174    pingBcg();
175    hideInPageOptOutForm();
176};
177
178window.cookieOptOutSetConsentAllTechnical = function () {
179    var fakeCookieOptOutConsent = Object.assign({}, cookieOptOutConsent);
180    fakeCookieOptOutConsent["ad_storage"] = "denied";
181    fakeCookieOptOutConsent["analytics_storage"] = "denied";
182    fakeCookieOptOutConsent["functionality_storage"] = "granted";
183    fakeCookieOptOutConsent["personalization_storage"] = "granted";
184    fakeCookieOptOutConsent["security_storage"] = "granted";
185    fakeCookieOptOutConsent["add_user_data"] = "denied";
186    fakeCookieOptOutConsent["add_personalization"] = "denied";
187    EwUtils.setCookie("_GTM_Consent", JSON.stringify(fakeCookieOptOutConsent), { days: 1000 });
188    cookieOptOutConsent = fakeCookieOptOutConsent;
189    blockIframes(cookieOptOutConsent);
190    cookieOptOutPost("update");
191    pingBcg();
192    hideInPageOptOutForm();
193}
194
195window.cookieOptOutSetConsentAll = function () {
196    for (var property in cookieOptOutConsent) {
197        cookieOptOutConsent[property] = "granted";
198    }
199    EwUtils.setCookie("_GTM_Consent", JSON.stringify(cookieOptOutConsent), { days: 1000 });
200    cookieOptOutPost("update");
201    blockIframes(cookieOptOutConsent);
202    pingBcg();
203    hideInPageOptOutForm();
204};
205
206window.hideInPageOptOutForm = function () {
207    var inPageForm = document.querySelector(".inpage_cookieOptOutForm");
208    var isInPage = inPageForm != undefined && inPageForm != null;
209
210    if (isInPage) {
211        inPageForm.classList.add("hidden");
212        inPageForm.style.display = "none";
213    }
214}
215
216window.openCookieOptOut = function (detailed) {
217    var inPageForm = document.querySelector(".inpage_cookieOptOutForm");
218    var isInPage = inPageForm != undefined && inPageForm != null;
219
220    if (isInPage) {
221        inPageForm.classList.remove("hidden");
222        inPageForm.style.display = "block";
223        return;
224    }
225
226    detailed = detailed != undefined && detailed != null && detailed !== false;
227    $.magnificPopup.open({
228        items: {
229            type: "ajax",
230            src: EwCore.ajaxUrlGet("Form/CookieForm", { Detailed: detailed }),
231            ajax: {
232                settings: { cache: false, async: false },
233                cursor: "mfp-ajax-cur"
234            }
235        },
236        closeOnBgClick: false,
237        enableEscapeKey: false,
238        showCloseBtn: detailed,
239        callbacks: {
240            beforeOpen: function () {
241                jQuery("body").css("overflow", "hidden");
242            },
243            beforeClose: function () {
244                jQuery("body").css("overflow", "auto");
245            }
246        }
247    });
248};
249
250window.cookieOptOutGet = function (prop) {
251    return cookieOptOutConsent[prop];
252}
253
254window.pingBcg = function () {
255    if (window.location.href.indexOf("cstech") > -1) {
256        return;
257    }
258
259    var cookieIdIdentifier = "_GTM_Id";
260    var fakeCookieOptOutConsent = Object.assign({}, cookieOptOutConsent);
261    var x = cookieOptOutGetCookie(cookieIdIdentifier);
262    var cookieId = x == undefined || x == "undefined" || isNaN(x) || x == "NaN" || x == "null" || x == null ? 0 : x;
263    fakeCookieOptOutConsent["Id"] = Number(cookieId);
264    EwCore.ajaxCookieOptOutSet(fakeCookieOptOutConsent, {
265        success: function (data) {
266            EwUtils.setCookie(cookieIdIdentifier, data.id, { days: 1000 });
267        },
268        async: false
269    });
270};
271
272function cookieOptOutGetCookie(name) {
273    //var value = `; ${document.cookie}`;
274    //var parts = value.split(`; ${name}=`);
275    //if (parts.length === 2) return parts.pop().split(';').shift();
276    var match = document.cookie.match(new RegExp("(^| )" + name + "=([^;]+)"));
277    if (match) return match[2];
278}
279
280window.cookieOptOutLoad = function () {
281    cookieOptOutConsentCookie = cookieOptOutGetCookie("_GTM_Consent");//EwUtils.getCookie("_GTM_Consent");
282    cookieOptOutConsent = cookieOptOutConsentCookie ? JSON.parse(cookieOptOutConsentCookie) : cookieOptOutDefaultConsent;
283}
284
285window.cookieOptOutInit = function () {
286    cookieOptOutLoad();
287    cookieOptOutStatus = cookieOptOutConsentCookie ? "update" : "default";
288    cookieOptOutPost(cookieOptOutStatus);
289}
290
291cookieOptOutInit();
292
293$(function () {
294    blockIframes();
295    if (cookieOptOutConsentCookie == null && window.location.pathname.indexOf("pages/cookie
295s") === -1) {
296        openCookieOptOut();
297    }
298});
299

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.