PageSourceSearch

https://athensgis.gr/JS/cookies.js?v=20260615-1

js athensgis.gr collected 2026-10-07 00:29:51 UTC 5,988 bytes, 190 lines download raw bytes

1(function () {
2  var STORAGE_KEY = "athensgis_cookie_consent_v2";
3  var LEGACY_STORAGE_KEY = "athensgis_cookie_consent";
4  var GA_MEASUREMENT_ID = "G-BSNF6CGQ5J";
5  var POSTHOG_KEY = "phc_MHHcy6vbXCCiNqQcOlSEmTZvBPIXI4bTv36F4vvQyf6";
6  var POSTHOG_API_HOST = "https://eu.i.posthog.com";
7  var analyticsLoaded = false;
8
9  function addMonths(date, months) {
10    var next = new Date(date.getTime());
11    next.setMonth(next.getMonth() + months);
12    return next;
13  }
14
15  function readStoredConsent() {
16    var raw = null;
17    try {
18      raw = localStorage.getItem(STORAGE_KEY);
19    } catch (e) {
20      return null;
21    }
22    if (!raw) return null;
23    try {
24      var parsed = JSON.parse(raw);
25      if (!parsed || (parsed.status !== "accepted" && parsed.status !== "rejected")) return null;
26      if (typeof parsed.expiresAt !== "number") return null;
27      return parsed;
28    } catch (e) {
29      return null;
30    }
31  }
32
33  function readLegacyConsent() {
34    var raw = null;
35    try {
36      raw = localStorage.getItem(LEGACY_STORAGE_KEY);
37    } catch (e) {
38      return null;
39    }
40    if (raw !== "accepted" && raw !== "rejected") return null;
41    return raw;
42  }
43
44  function clearLegacyConsent() {
45    try {
46      localStorage.removeItem(LEGACY_STORAGE_KEY);
47    } catch (e) { }
48  }
49
50  function writeConsent(status) {
51    var now = new Date();
52    var expiresAt = addMonths(now, status === "accepted" ? 2 : 1).getTime();
53    var payload = { status: status, expiresAt: expiresAt };
54    try {
55      localStorage.setItem(STORAGE_KEY, JSON.stringify(payload));
56    } catch (e) { }
57    clearLegacyConsent();
58    return payload;
59  }
60
61  function clearConsent() {
62    try {
63      localStorage.removeItem(STORAGE_KEY);
64    } catch (e) { }
65    clearLegacyConsent();
66  }
67
68  function loadScript(src, id) {
69    if (id && document.getElementById(id)) return;
70    var script = document.createElement("script");
71    if (id) script.id = id;
72    script.async = true;
73    script.src = src;
74    document.head.appendChild(script);
75  }
76
77  function loadGoogleAnalytics() {
78    if (window.__athensGaInitialized) return;
79    window.dataLayer = window.dataLayer || [];
80    window.gtag = window.gtag || function () {
81      window.dataLayer.push(arguments);
82    };
83    window.gtag("js", new Date());
84    window.gtag("config", GA_MEASUREMENT_ID);
85    loadScript("https://www.googletagmanager.com/gtag/js?id=" + encodeURIComponent(GA_MEASUREMENT_ID), "athens-ga-script");
86    window.__athensGaInitialized = true;
87  }
88
89  function loadPosthog() {
90    if (window.__athensPosthogInitialized) return;
91    (function (t, e) {
92      var o, n, p, r;
93      if (e.__SV) return;
94      window.posthog = e;
95      e._i = [];
96      e.init = function (i, s, a) {
97        function g(target, key) {
98          var parts = key.split(".");
99          if (parts.length === 2) {
100            target = target[parts[0]];
101            key = parts[1];
102          }
103          target[key] = function () {
104            target.push([key].concat(Array.prototype.slice.call(arguments, 0)));
105          };
106        }
107        p = t.createElement("script");
108        p.type = "text/javascript";
109        p.async = true;
110        p.id = "athens-posthog-script";
111        p.src = s.api_host.replace(".i.posthog.com", "-assets.i.posthog.com") + "/static/array.js";
112        r = t.getElementsByTagName("script")[0];
113        r.parentNode.insertBefore(p, r);
114        var u = e;
115        if (a !== undefined) u = e[a] = [];
116        else a = "posthog";
117        u.people = u.people || [];
118        u.toString = function (debug) {
119          var name = "posthog";
120          if (a !== "posthog") name += "." + a;
121          if (!debug) name += " (stub)";
122          return name;
123        };
124        u.people.toString = function () { return u.toString(1) + ".people (stub)"; };
125        o = "init capture register register_once register_for_session unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group identify setPersonProperties setPersonPropertiesForFlags resetPersonPropertiesForFlags setGroupPropertiesForFlags resetGroupPropertiesForFlags resetGroups onFeatureFlags addFeatureFlagsHandler onSessionId getSurveys getActiveMatchingSurveys render
125Survey canRenderSurvey getNextSurveyStep".split(" ");
126        for (n = 0; n < o.length; n += 1) g(u, o[n]);
127        e._i.push([i, s, a]);
128      };
129      e.__SV = 1;
130    })(document, window.posthog || []);
131
132    window.posthog.init(POSTHOG_KEY, {
133      api_host: POSTHOG_API_HOST,
134      defaults: "2026-01-30"
135    });
136    window.__athensPosthogInitialized = true;
137  }
138
139  function loadAnalytics() {
140    if (analyticsLoaded) return;
141    loadGoogleAnalytics();
142    loadPosthog();
143    analyticsLoaded = true;
144  }
145
146  function shouldReprompt(consent) {
147    if (!consent || typeof consent.expiresAt !== "number") return true;
148    return Date.now() >= consent.expiresAt;
149  }
150
151  document.addEventListener("DOMContentLoaded", function () {
152    var box = document.getElementById("cookie-consent-box");
153    var acceptBtn = document.getElementById("cookie-accept-btn");
154    var rejectBtn = document.getElementById("cookie-reject-btn");
155    if (!box || !acceptBtn || !rejectBtn) return;
156
157    var stored = readStoredConsent();
158    if (!stored) {
159      var legacy = readLegacyConsent();
160      if (legacy) {
161        stored = writeConsent(legacy);
162      }
163    }
164
165    if (stored && shouldReprompt(stored)) {
166      clearConsent();
167      stored = null;
168    }
169
170    if (stored && stored.status === "accepted") {
171      loadAnalytics();
172      box.hidden = true;
173    } else if (stored && stored.status === "rejected") {
174      box.hidden = true;
175    } else {
176      box.hidden = false;
177    }
178
179    acceptBtn.addEventListener("click", function () {
180      writeConsent("accepted");
181      loadAnalytics();
182      box.hidden = true;
183    });
184
185    rejectBtn.addEventListener("click", function () {
186      writeConsent("rejected");
187      box.hidden = true;
188    });
189  });
190})();

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.