PageSourceSearch

https://booked4.us/js/globalModule.js?v=4.1

js booked4.us collected 2026-10-01 13:52:52 UTC 13,385 bytes, 376 lines download raw bytes

1var global = (function (my) {
2    // #region Private variables
3
4    const globalLoadingContainerId = 'global-loading-container';
5
6    // #endregion
7
8    // #region Private functions
9    function addListenerToHeader() {
10        window.addEventListener('scroll', function () {
11            const header = document.querySelector('.header');
12            if (header) {
13                if (window.scrollY > 0) {
14                    header.classList.add('transparent');
15                } else {
16                    header.classList.remove('transparent');
17                }
18            }
19        });
20    }
21
22    function setLanguageButtonText() {
23        const langs = { hu: 'HU', de: 'DE', en: 'EN' };
24        const path = window.location.pathname;
25        const langCode = path.split('/')[1];
26        const elements = document.querySelectorAll('.language-btn-text');
27
28        elements.forEach(element => {
29            element.textContent = langs[langCode] || langs[config.default_language];
30        });
31    }
32
33    function eventHandlersInit() {
34        globalNative.addClickListenersToClass(".close-menu-icon", function () {
35            document.getElementById("menu-items").classList.remove("mobile-menu");
36            document.getElementById("header").classList.remove("mobile-menu-open");
37            globalNative.hideByClass(".close-menu-icon");
38            globalNative.showByClass(".menu-icon");
39        });
40
41        globalNative.addClickListenersToClass(".menu-icon", function () {
42            document.getElementById("menu-items").classList.add("mobile-menu");
43            document.getElementById("header").classList.add("mobile-menu-open");
44            globalNative.hideByClass(".menu-icon");
45            globalNative.showByClass(".close-menu-icon");
46        });
47
48        globalNative.addClickListenersToClass(".language", function (event) {
49            switchLanguage(event, this);
50        });
51    }
52
53    function leadSectionInit() {
54        var language = my.getLanguage();
55        var leadSectionTextArray;
56        switch (language) {
57            case "hu":
58                leadSectionTextArray = ["14 napos ingyenes tesztidőszak.", "Bankkártya adatok nélkül.", "Teljes funkcionalitással."];
59                break;
60            case "de":
61                leadSectionTextArray = ["Testen Sie 14 Tage kostenlos!", "Keine Kreditkarte erforderlich.", "Alle Funktionen verfügbar."];
62                break;
63            case "en":
64                leadSectionTextArray = ["14 day free trial.", "No credit card required.", "Access to all features."];
65                break;
66        }
67
68        var index = 0;
69        var changeText = document.getElementById("changeText");
70        if (changeText) {
71            setInterval(function () {
72                changeText.style.opacity = 0;
73
74                if (leadSectionTextArray.length > index) {
75                    changeText.textContent = leadSectionTextArray[index];
76                    changeText.style.opacity = 1;
77                    index++;
78                } else {
79                    index = 0;
80                }
81            }, 2000);
82        }
83    }
84
85    function setRegistrationCookies() {
86        const mainPageLeadSources = ['main-header', 'main-hero', 'main-footer', 'industries-header', 'industries-hero', 'industries-footer',
87            'functions-header', 'functions-hero', 'functions-footer', 'prices-header', 'prices-hero', 'prices-footer', 'aboutus-header', 'aboutus-hero', 'aboutus-footer'];
88        const params = new URLSearchParams(window.location.search);
89        let lsrc = null;
90
91        if (document.referrer) {
92            const referrerUrl = document.referrer;
93
94            if (isExternalReferrer(referrerUrl)) {
95                cookieConsent.setCookie('referrerUrl', referrerUrl);
96            }
97        }
98
99        if (params.has('utm_campaign')) {
100            const utm = params.get('utm_campaign');
101            cookieConsent.setCookie('utm_campaign', utm)
102        }
103
104        lsrc = cookieConsent.getCookie('lsrc');
105
106        if (lsrc && !mainPageLeadSources.includes(lsrc)) {
107            return;
108        }
109
110        lsrc = params.get('lsrc');
111        cookieConsent.setCookie('lsrc', lsrc);
112    }
113
114    function isExternalReferrer(referrerUrl) {
115        if (!referrerUrl) {
116            return false;
117        }
118
119        try {
120            const referrerHost = new URL(referrerUrl).hostname;
121            const currentHost = window.location.hostname;
122
123            return referrerHost !== currentHost;
124        } catch {
125            return true;
126        }
127    }
128
129    function restoreSessionStorage() {
130        try {
131            if (prices != undefined) {
132                return;
133            }
134        } catch (error) {
135            sessionStorage.clear();
136            var language = my.getLanguage();
137            sessionStorage.setItem("language", language);
138        }
139    }
140
141    function switchLanguage(event, eventTarget) {
142        event.preventDefault();
143        if (eventTarget.dataset.lang !== my.getLanguage()) {
144            const lang = eventTarget.dataset.lang;
145            const currentPath = window.location.pathname;
146
147            if (/\/(de|en|hu)/.test(currentPath)) {
148                window.location.href = currentPath.replace(/\/(de|en|hu)/, `/${lang}`);
149            } else {
150                window.location.href = `/${lang}${currentPath}`;
151            }
152        }
153    }
154
155    function initContent() {
156        if (config.environment == "termin-direkt.de") {
157            globalNative.removeByClass(".hide-termin");
158            if (my.getLanguage() != "de") {
159                globalNative.removeByClass(".termin-native");
160                globalNative.removeByClass(".termin-de-b4us-hu-visible");
161            }
162        } else {
163            globalNative.removeByClass(".termin-native");
164            if (my.getLanguage() != "hu") {
165                globalNative.removeByClass(".termin-de-b4us-hu-visible");
166            }
167        }
168
169        if (my.getLanguage() != "hu") {
170            globalNative.removeByClass(".visible-hu");
171        }
172
173        var video = document.getElementById("videos-button-container");
174        if (video) {
175            video.classList.remove("default-hide");
176            video.removeAttribute("style");
177        }
178    }
179
180    // #endregion
181
182    // #region Public variables
183
184    my.links = {};
185    my.loadingAnimation;
186
187    // #endregion
188
189    // #region Public functions
190
191    my.init = function () {
192        leadSectionInit();
193        eventHandlersInit();
194        setRegistrationCookies();
195        restoreSessionStorage();
196        initContent();
197        setLanguageButtonText();
198        addListenerToHeader();
199    }
200
201    my.loadIframe = function (iframeName, url) {
202        var iframe = document.getElementById(iframeName);
203
204        if (iframe) {
205            iframe.src = url;
206            return false;
207        }
208
209        return true;
210    }
211
212    my.getLanguage = function () {
213        var url = window.location.pathname;
214
215        if (url.includes("/hu")) {
216            return "hu";
217        } else if (url.includes("/de")) {
218            return "de";
219        } else if (url.includes("/en")) {
220            return "en";
221        } else {
222            return config.default_language;
223        }
224    }
225
226    my.initJsons = async function () {
227        try {
228            var language = my.getLanguage();
229            var path = `/i18n/env/${language}/links.json`;
230            var response = await fetch(path);
231
232            if (!response.ok) {
233                throw new Error('Network response was not ok');
234            }
235
236            my.links = await response.json();
237        } catch (error) {
238            console.error('There was a problem while trying to fetch at initJsons:', error);
239        }
240    };
241
242    my.initJson = async function (path) {
243        try {
244            const response = await fetch(path);
245            if (!response.ok) {
246                throw new Error('Network response was not ok');
247            }
248            return await response.json();
249        } catch (error) {
250            console.error('There was a problem while trying to fetch at initJson:', error);
251            throw error;
252        }
253    }
254
255    my.openInNewTab = function (element) {
256        if (element) {
257            var href = element.getAttribute('href');
258
259            if (href) {
260                window.open(href, '_blank');
261            }
262        }
263    }
264
265    my.handleChangeOffersImgByHovering = function () {
266        var offersTextBlockHover = 'offers-text-block-hover';
267        var [firstBlock, secondBlock] = document.querySelectorAll('.offers-text-block');
268        var offersImg = document.querySelector('.offers-img');
269
270        firstBlock.addEventListener('mouseover', function () {
271            firstBlock.classList.add(offersTextBlockHover);
272            secondBlock.classList.remove(offersTextBlockHover);
273            offersImg.src = `/assets/env/${global.getLanguage()}/hero_big_img_1.webp`;
274        });
275
276        secondBlock.addEventListener('mouseover', function () {
277            secondBlock.classList.add(offersTextBlockHover);
278            firstBlock.classList.remove(offersTextBlockHover);
279            offersImg.src = `/assets/env/${global.getLanguage()}/hero_big_img_2.webp`;
280        });
281    }
282
283    my.handleChangeOfferDetailsByTab = function () {
284        var offersMobileTabSelected = 'offers-mobile-tab-selected';
285        var offersMobileDescriptionHidden = 'offers-mobile-description-hidden';
286        var [firstTab, secondTab] = document.querySelectorAll('.offers-mobile-tab');
287        var [firstDescription, secondDescription] = document.querySelectorAll('.offers-mobile-description');
288        var offersImg = document.querySelector('.offers-img');
289
290        firstTab.addEventListener('click', function () {
291            firstTab.classList.add(offersMobileTabSelected);
292            secondTab.classList.remove(offersMobileTabSelected);
293            firstDescription.classList.remove(offersMobileDescriptionHidden);
294            secondDescription.classList.add(offersMobileDescriptionHidden);
295            offersImg.src = `/assets/env/${global.getLanguage()}/hero_big_img_1.webp`;
296        });
297
298        secondTab.addEventListener('click', function () {
299            secondTab.classList.add(offersMobileTabSelected);
300            firstTab.classList.remove(offersMobileTabSelected);
301            secondDescription.classList.remove(offersMobileDescriptionHidden);
302            firstDescription.classList.add(offersMobileDescriptionHidden);
303            offersImg.src = `/assets/env/${global.getLanguage()}/hero_big_img_2.webp`;
304        });
305    }
306
307    my.handleOpenFaqCard = function () {
308        var faqCards = document.querySelectorAll('.FAQ-card');
309        faqCards.forEach(card => {
310            card.addEventListener('click', function () {
311                const FAQCardActive = 'FAQ-card-active';
312                var alreadyOpenCard = document.querySelector('.FAQ-card-active');
313                var cardIcon = card.getElementsByTagName('img')[0];
314                var alreadyOpenCardIcon = alreadyOpenCard ? alreadyOpenCard.getElementsByTagName('img')[0] : null;
315
316                if (card === alreadyOpenCard) {
317                    card.classList.remove(FAQCardActive);
318                    cardIcon.src = '/assets/icons/add.svg';
319                } else {
320                    card.classList.add(FAQCardActive);
321                    cardIcon.src = '/assets/icons/remove.svg';
322                    if (alreadyOpenCard) {
323                        alreadyOpenCard.classList.remove(FAQCardActive);
324                        alreadyOpenCardIcon.src = '/assets/icons/add.svg';
325                    }
326                }
327            });
328        })
329    }
330
331    my.loadLottiAnimation = function (animationConfig) {
332        return bodymovin.loadAnimation(animationConfig);
333    }
334
335    my.addLoadingAnimation = function () {
336        const loadingContainer = document.getElementById(globalLoadingContainerId);
337
338        my.loadingAnimation = my.loadLottiAnimation({
339            container: loadingContainer, // required
340            path: '/assets/animations/loading-lotti.json', // required
341            renderer: 'svg', // required
342            loop: true, // optional
343            autoplay: false, // optional
344            name: "Loading Animation", // optional
345        });
346
347        globalNative.hideElement(loadingContainer);
348    }
349
350    my.showLoadingAnimation = function () {
351        const loadingContainer = document.getElementById(globalLoadingContainerId);
352        globalNative.showElement(loadingContainer, 'flex');
353
354        if (my.loadingAnimation) {
355            my.loadingAnimation.play();
356        }
357    }
358
359    my.hideLoadingAnimation = function () {
360        const loadingContainer = document.getElementById(globalLoadingContainerId);
361        globalNative.hideElement(loadingContainer);
362        
363        if (my.loadingAnimation) {
364            my.loadingAnimation.stop();
365        }
366    }
367
368    // #endregion
369
370    return my;
371}(global || {}));
372
373document.addEventListener("DOMContentLoaded", async function () {
374    global.init();
375    await global.initJsons();
376});

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.