PageSourceSearch

https://superdjradio.hu/assets/js/main.js?v=2026100104

js superdjradio.hu collected 2026-10-08 09:22:23 UTC 9,653 bytes, 235 lines download raw bytes

1$(document).ready(function () {
2    // Carousel inicializálása
3    function initializeCarousel() {
4        const carousel = document.getElementById('myCarousel');
5        if (carousel) {
6            bootstrap.Carousel.getOrCreateInstance(carousel).cycle();
7        }
8    }
9
10    // A betöltött oldal címét, leírását, canonical linkjét és robots utasítását átvesszük a fejlécbe.
11    // Ami a betöltött oldalon nincs meg (pl. a 404-es oldal noindex jelzése máshol), azt eltávolítjuk.
12    function updateHead(doc) {
13        document.title = doc.title;
14        ['meta[name="description"]', 'link[rel="canonical"]', 'meta[name="robots"]'].forEach(function (selector) {
15            const current = document.head.querySelector(selector);
16            const loaded = doc.head.querySelector(selector);
17            if (current && loaded) {
18                const attribute = current.tagName === 'LINK' ? 'href' : 'content';
19                current.setAttribute(attribute, loaded.getAttribute(attribute));
20            } else if (loaded) {
21                document.head.appendChild(document.importNode(loaded, true));
22            } else if (current) {
23                current.remove();
24            }
25        });
26    }
27
28    // Amíg a videó hanggal megy, a rádiót elnémítjuk, hogy ne szóljon kétszer
29    function initializeLiveCam() {
30        const videoPlayer = document.getElementById('videojs-watermark-player');
31        if (!videoPlayer) return;
32
33        const player = videojs(videoPlayer);
34        const radio = document.getElementById('radio-player');
35        const syncRadio = function () {
36            radio.muted = !player.paused() && !player.muted() && player.volume() > 0;
37        };
38        player.on(['play', 'playing', 'pause', 'ended', 'volumechange'], syncRadio);
39        player.on('dispose', function () {
40            radio.muted = false;
41        });
42
43        // Offline jelzés: csak akkor tűnik el, ha tényleg megy a kép
44        const container = document.getElementById('video-player-container');
45        player.on('playing', function () {
46            container.classList.add('is-live');
47        });
48        player.on('error', function () {
49            container.classList.remove('is-live');
50            // Hibaüzenet helyett visszaállunk az induló állapotra, hogy újra lehessen próbálni
51            player.error(null);
52            player.hasStarted(false);
53        });
54        console.log('Video.js player initialized:', player);
55    }
56
57    // Tartalom cseréje újratöltés nélkül, hogy a rádió ne szakadjon meg
58    function loadPage(url, addToHistory) {
59        $.get(url, function (html) {
60            const doc = new DOMParser().parseFromString(html, 'text/html');
61            const content = doc.getElementById('main-content');
62            if (!content) {
63                console.error('Nincs #main-content az oldalon:', url);
64                return;
65            }
66
67            // A régi videólejátszót el kell távolítani, mielőtt a tartalma eltűnik
68            if (typeof videojs === 'function' && videojs.getPlayer('videojs-watermark-player')) {
69                videojs.getPlayer('videojs-watermark-player').dispose();
70            }
71
72            document.getElementById('main-content').innerHTML = content.innerHTML;
73            updateHead(doc);
74            if (addToHistory) {
75                history.pushState(null, '', url);
76            }
77            console.log('Tartalom betöltve:', url);
78
79            // Görgetés az oldal tetejére
80            window.scrollTo({ top: 0, behavior: 'smooth' });
81
82            // Süti modal újrainicializálása
83            if (typeof initializeCookieModal === 'function') {
84                initializeCookieModal();
85            }
86
87            // Hirdetési gomb inicializálása
88            if (typeof initializeAdvertisementButton === 'function') {
89                initializeAdvertisementButton();
90            }
91
92            // Carousel újrainicializálása
93            initializeCarousel();
94
95            // Műsorrend betöltése
96            if (typeof initializeSchedule === 'function') {
97                initializeSchedule();
98            }
99
100            // Adásban doboz frissítése
101            if (typeof fetchLiveBroadcast === 'function') {
102                fetchLiveBroadcast();
103            }
104
105            // Videólejátszó újrainicializálása
106            if (typeof initializeVideoPlayer === 'function') {
107                console.log('Calling initializeVideoPlayer after AJAX load'); // Naplózás
108                initializeVideoPlayer();
109            }
110
111            // Videólejátszó újrainicializálása
112            initializeLiveCam();
113
114            // Kapcsolati űrlap tokenje
115            loadFormToken();
116
117            // Kezdőlapi csatornakártyák
118            if (typeof refreshChannelCards === 'function') {
119                refreshChannelCards();
120            }
121        });
122    }
123
124    // Dinamikus navigáció kezelése delegált eseménykezeléssel
125    $(document).on('click', '.dynamic-link', function (e) {
126        // Új lapon megnyitást nem fogjuk el
127        if (e.ctrlKey || e.metaKey || e.shiftKey) return;
128        e.preventDefault(); // Megakadályozza az oldal újratöltését
129        loadPage($(this).attr('href'), true);
130    });
131
132    // Kapcsolati űrlap: a Tárgy lista kiválasztott eleme a rejtett mezőbe kerül
133    $(document).on('click', '.contact-select .dropdown-item', function () {
134        const select = $(this).closest('.contact-select');
135        select.find('input[type="hidden"]').val($(this).data('value'));
136        select.find('.form-select').text($(this).text());
137    });
138
139    // Botvédelem: az űrlap a szervertől kér egy időbélyeges tokent
140    function loadFormToken() {
141        const form = document.getElementById('contact-form');
142        if (!form) return;
143
144        const field = form.elements.token;
145        if (field.value || field.dataset.loading) return;
146        field.dataset.loading = '1';
147        fetch('form-token.php')
148            .then(response => response.json())
149            .then(data => {
150                field.value = data.token;
151            })
152            .catch(error => console.error('Error fetching form token:', error))
153            .finally(() => {
154                delete field.dataset.loading;
155            });
156    }
157
158    // Ha az oldal megjelenésekor nem sikerült, az űrlap első használatakor újra megpróbáljuk
159    $(document).on('focusin', '#contact-form', loadFormToken);
160
161    // Kapcsolati űrlap küldése újratöltés nélkül, hogy a rádió ne szakadjon meg
162    $(document).on('submit', '#contact-form', function (e) {
163        e.preventDefault();
164        const form = this;
165        const status = form.querySelector('.form-status');
166        const button = form.querySelector('button[type="submit"]');
167        const subjectButton = form.querySelector('#subject-button');
168
169        status.className = 'form-status mt-3 mb-0';
170
171        // A saját lenyíló listát a böngésző nem ellenőrzi, ezért itt nézzük meg
172        if (!form.elements.subject.value) {
173            status.textContent = 'Kérjük, válasszon tárgyat.';
174            status.classList.add('is-error');
175            subjectButton.focus();
176            return;
177        }
178
179        button.disabled = true;
180        status.textContent = 'Küldés...';
181
182        fetch(form.action, { method: 'POST', body: new FormData(form) })
183            .then(response => response.json())
184            .then(data => {
185                status.textContent = data.message;
186                status.classList.add(data.ok ? 'is-success' : 'is-error');
187                if (data.ok) {
188                    form.reset();
189                    form.elements.subject.value = '';
190                    form.elements.token.value = '';
191                    subjectButton.textContent = subjectButton.dataset.placeholder;
192                }
193            })
194            .catch(error => {
195                console.error('Error sending contact form:', error);
196                status.textContent = 'Az üzenetet nem sikerült elküldeni. Kérjük, próbálja újra később, vagy írjon a [email protected] címre.';
197                status.classList.add('is-error');
198            })
199            .finally(() => {
200                button.disabled = false;
201            });
202    });
203
204    // Vissza/Előre gomb: a címsorhoz tartozó tartalmat töltjük be
205    window.addEventListener('popstate', function () {
206        loadPage(window.location.href, false);
207    });
208
209    // A láblécben mindig az aktuális évszám áll
210    $('.current-year').text(new Date().getFullYear());
211
212    // Vissza a tetejére gomb: csak akkor látszik, ha már legörgettünk
213    const backToTop = $('#back-to-top');
214    $(window).on('scroll', function () {
215        backToTop.toggleClass('d-none', window.scrollY < window.innerHeight * 0.6);
216    });
217    backToTop.click(function () {
218        window.scrollTo({ top: 0, behavior: 'smooth' });
219    });
220
221    // Oldal betöltésekor a carousel inicializálása
222    initializeCarousel();
223
224    // Oldal betöltésekor a videó inicializálása
225    if (typeof initializeVideoPlayer === 'function') {
226        console.log('Calling initializeVideoPlayer on page load'); // Naplózás
227        initializeVideoPlayer();
228    }
229
230    // Oldal betöltésekor a videó inicializálása
231    initializeLiveCam();
232
233    // Oldal betöltésekor a kapcsolati űrlap tokenje
234    loadFormToken();
235});

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.