PageSourceSearch

https://www.addiko-fbih.ba/static/plugins/addiko-popup-notices/assets/popup.js?ver=1783685234

js addiko-fbih.ba collected 2026-09-30 18:54:46 UTC 3,974 bytes, 117 lines download raw bytes

1document.addEventListener("DOMContentLoaded", function () {
2
3    const overlay = document.getElementById("addiko-popup-overlay");
4    if (!overlay) return;
5
6    const popupData = window.AddikoPopupData || {};
7    const version = popupData.messageVersion || "";
8    const toBool = function (value) {
9        return value === true || value === 1 || value === "1" || value === "true";
10    };
11    const displayMode = popupData.displayMode || (toBool(popupData.showOnceEnabled) || toBool(popupData.showOnceForGuests) ? "once" : ((toBool(popupData.showOnceDaily) || toBool(popupData.showOnceDailyGuests)) ? "daily_guests" : "always"));
12    const currentDate = popupData.currentDate || new Date().toISOString().slice(0, 10);
13
14    const hiddenByVersionKey = "addiko_popup_hidden";
15    const shownOnceKey = "addiko_popup_seen_once_" + version;
16    const legacyShownOnceGuestKey = "addiko_popup_seen_once_guest_" + version;
17    const shownDailyKey = "addiko_popup_seen_daily_" + version;
18    const legacyShownDailyGuestKey = "addiko_popup_seen_daily_guest_" + version;
19    const cookieMaxAge = 60 * 60 * 24 * 400;
20
21    const safeGetCookie = function (key) {
22        const encodedKey = encodeURIComponent(key) + "=";
23        const cookies = document.cookie ? document.cookie.split(";") : [];
24
25        for (let i = 0; i < cookies.length; i++) {
26            const cookie = cookies[i].trim();
27            if (cookie.indexOf(encodedKey) === 0) {
28                return decodeURIComponent(cookie.substring(encodedKey.length));
29            }
30        }
31
32        return null;
33    };
34
35    const safeSetCookie = function (key, value) {
36        const secureFlag = window.location.protocol === "https:" ? "; Secure" : "";
37
38        document.cookie = encodeURIComponent(key) + "=" + encodeURIComponent(value) +
39            "; path=/; max-age=" + cookieMaxAge + "; SameSite=Lax" + secureFlag;
40    };
41
42    const safeGet = function (key) {
43        try {
44            const stored = window.localStorage.getItem(key);
45            if (stored !== null) {
46                return stored;
47            }
48        } catch (error) {
49            // Ako localStorage nije dostupan, koristi se cookie fallback.
50        }
51
52        return safeGetCookie(key);
53    };
54
55    const safeSet = function (key, value) {
56        try {
57            window.localStorage.setItem(key, value);
58        } catch (error) {
59            // Ako localStorage nije dostupan, stanje se pamti kroz cookie fallback.
60        }
61
62        safeSetCookie(key, value);
63    };
64
65    const showPopup = function () {
66        overlay.style.display = "flex";
67        overlay.style.animation = "addikoFadeIn 0.25s ease";
68    };
69
70    if (displayMode === "once") {
71        const seenOnce = safeGet(shownOnceKey);
72        const seenLegacyGuest = safeGet(legacyShownOnceGuestKey);
73        if (seenOnce === "1" || seenLegacyGuest === "1") {
74            return;
75        }
76
77        showPopup();
78        safeSet(shownOnceKey, "1");
79    } else if (displayMode === "daily_guests") {
80        const lastShownDate = safeGet(shownDailyKey) || safeGet(legacyShownDailyGuestKey);
81        if (lastShownDate === currentDate) {
82            return;
83        }
84
85        showPopup();
86        safeSet(shownDailyKey, currentDate);
87    } else {
88        const stored = safeGet(hiddenByVersionKey);
89        if (stored && stored === version) {
90            return;
91        }
92
93        showPopup();
94    }
95
96    // Close dugme
97    const closeBtn = document.getElementById("addiko-popup-close");
98    if (closeBtn) {
99        closeBtn.addEventListener("click", function () {
100            overlay.style.display = "none";
101        });
102    }
103
104    // Hide forever link
105    const hideLink = document.getElementById("addiko-popup-hide");
106    if (hideLink) {
107        hideLink.addEventListener("click", function (e) {
108            e.preventDefault();
109
110            // Zapamti verziju poruke
111            safeSet(hiddenByVersionKey, version);
112
113            overlay.style.display = "none";
114        });
115    }
116
117});

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.