PageSourceSearch

https://gardentopia.eu/wp-content/plugins/garden-footer/assets/js/banner.js?ver=1.1.0

js gardentopia.eu collected 2026-09-28 07:02:18 UTC 5,909 bytes, 177 lines download raw bytes

1(function () {
2  var STORAGE_KEY = 'gth_cookie_consent_v1';
3  var root = document.querySelector('[data-gth-consent-root]');
4  var floating = document.querySelector('[data-gth-reopen]');
5  if (!root || typeof GTH_COOKIE === 'undefined') return;
6
7  function readState() {
8    try {
9      var raw = localStorage.getItem(STORAGE_KEY);
10      if (!raw) return null;
11      return JSON.parse(raw);
12    } catch (e) {
13      return null;
14    }
15  }
16
17  function writeState(obj) {
18    try {
19      localStorage.setItem(STORAGE_KEY, JSON.stringify(obj));
20    } catch (e) {}
21  }
22
23  function normalizePrefs(p) {
24    if (!p || typeof p !== 'object') {
25      return { analytics: false, functional: false, ads: false };
26    }
27    return {
28      analytics: !!p.analytics,
29      functional: !!p.functional,
30      ads: !!p.ads
31    };
32  }
33
34  function pushGtagConsentOnly(prefs) {
35    prefs = normalizePrefs(prefs);
36    var analytics = prefs.analytics ? 'granted' : 'denied';
37    var functional = prefs.functional ? 'granted' : 'denied';
38    var ads = prefs.ads ? 'granted' : 'denied';
39    var payload = {
40      analytics_storage: analytics,
41      ad_storage: ads,
42      ad_user_data: ads,
43      ad_personalization: ads,
44      personalization_storage: functional === 'granted' ? 'granted' : 'denied',
45      functionality_storage: functional,
46      security_storage: 'granted'
47    };
48    window.dataLayer = window.dataLayer || [];
49    if (typeof window.gtag === 'function') {
50      window.gtag('set', 'ads_data_redaction', !prefs.ads);
51      window.gtag('consent', 'update', payload);
52    } else {
53      window.dataLayer.push(['set', 'ads_data_redaction', !prefs.ads]);
54      window.dataLayer.push(['consent', 'update', payload]);
55    }
56  }
57
58  function applyGtagConsent(prefs) {
59    prefs = normalizePrefs(prefs);
60    pushGtagConsentOnly(prefs);
61    if (typeof window.gthUpdateTcfFromPrefs === 'function') {
62      window.gthUpdateTcfFromPrefs(prefs);
63    }
64    window.dispatchEvent(new CustomEvent('gth:cookie-consent', { detail: prefs }));
65  }
66
67  /** Később betöltődő GTM/GA4: csak consent push, ne duplázza a TCF-t és a gth:cookie-consent eseményt. */
68  function scheduleGtagConsentRetries(prefs) {
69    [250, 1000, 3000].forEach(function (ms) {
70      setTimeout(function () {
71        pushGtagConsentOnly(prefs);
72      }, ms);
73    });
74  }
75
76  function show(el) {
77    el.removeAttribute('hidden');
78    document.documentElement.classList.add('gth-cookie-open');
79  }
80
81  function hide(el) {
82    el.setAttribute('hidden', 'hidden');
83    document.documentElement.classList.remove('gth-cookie-open');
84  }
85
86  function wireLinks() {
87    var privacy = GTH_COOKIE.urls && GTH_COOKIE.urls.privacy;
88    var cookie = GTH_COOKIE.urls && GTH_COOKIE.urls.cookie;
89    root.querySelectorAll('[data-gth-link]').forEach(function (a) {
90      var k = a.getAttribute('data-gth-link');
91      var href = k === 'privacy' ? privacy : cookie;
92      if (href) a.setAttribute('href', href);
93    });
94  }
95
96  var prefsBox = root.querySelector('[data-gth-prefs]');
97  var existing = readState();
98
99  wireLinks();
100
101  if (existing && existing.version === GTH_COOKIE.consentVersion) {
102    var savedPrefs = existing.prefs || {};
103    applyGtagConsent(savedPrefs);
104    scheduleGtagConsentRetries(savedPrefs);
105    hide(root);
106    if (floating) floating.removeAttribute('hidden');
107  } else {
108    show(root);
109    if (floating) floating.setAttribute('hidden', 'hidden');
110  }
111
112  root.addEventListener('click', function (e) {
113    var t = e.target;
114    if (!(t && t.closest)) return;
115    var act = t.closest('[data-gth-action]');
116    if (!act) return;
117    var action = act.getAttribute('data-gth-action');
118    var prefs = { analytics: false, functional: false, ads: false };
119
120    if (action === 'accept') {
121      prefs = { analytics: true, functional: true, ads: true };
122      writeState({ version: GTH_COOKIE.consentVersion, prefs: prefs, ts: Date.now() });
123      applyGtagConsent(prefs);
124      hide(root);
125      if (floating) floating.removeAttribute('hidden');
126    } else if (action === 'accept_recommended') {
127      prefs = { analytics: true, functional: false, ads: true };
128      writeState({ version: GTH_COOKIE.consentVersion, prefs: prefs, ts: Date.now() });
129      applyGtagConsent(prefs);
130      scheduleGtagConsentRetries(prefs);
131      hide(root);
132      if (floating) floating.removeAttribute('hidden');
133    } else if (action === 'customize') {
134      if (prefsBox) prefsBox.removeAttribute('hidden');
135    } else if (action === 'save') {
136      var a = root.querySelector('[data-gth-cat="analytics"]');
137      var f = root.querySelector('[data-gth-cat="functional"]');
138      var ad = root.querySelector('[data-gth-cat="ads"]');
139      prefs = {
140        analytics: a && a.checked,
141        functional: f && f.checked,
142        ads: ad && ad.checked
143      };
144      writeState({ version: GTH_COOKIE.consentVersion, prefs: prefs, ts: Date.now() });
145      applyGtagConsent(prefs);
146      hide(root);
147      if (floating) floating.removeAttribute('hidden');
148    }
149  });
150
151  root.addEventListener('click', function (e) {
152    var c = e.target.closest('[data-gth-close]');
153    if (c) {
154      var prefs = { analytics: false, functional: false, ads: false };
155      writeState({ version: GTH_COOKIE.consentVersion, prefs: prefs, ts: Date.now() });
156      applyGtagConsent(prefs);
157      hide(root);
158      if (floating) floating.removeAttribute('hidden');
159    }
160  });
161
162  if (floating) {
163    floating.addEventListener('click', function () {
164      var st = readState();
165      show(root);
166      if (st && st.prefs) {
167        var p = normalizePrefs(st.prefs);
168        var a = root.querySelector('[data-gth-cat="analytics"]');
169        var f = root.querySelector('[data-gth-cat="functional"]');
170        var ad = root.querySelector('[data-gth-cat="ads"]');
171        if (a) a.checked = p.analytics;
172        if (f) f.checked = p.functional;
173        if (ad) ad.checked = p.ads;
174      }
175    });
176  }
177})();

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.