--> //; // const PAGE_HOLD_MS = 10000; // const FIRST_PAGE_HOLD_MS = 16000; // const FLIP_STEP_MS = 130; // her scramble adımı // const FLIP_SCRAMBLE_STEPS = 18; // toplam 18 tur // const FLIP_REVEAL_STEP = 15; // 15. adımda asıl harf yerleşir // const FLIP_TOTAL_MS = FLIP_STEP_MS * (FLIP_SCRAMBLE_STEPS + 1); // // const FLIGHT_FLAP_CHARS = ' ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ÇĞİÖŞÜ:/-'; // // const RESTART_CHECK_INTERVAL_MS = 60000; // const RESTART_FILE_URL = '/restart.txt'; // const RESTART_RESET_URL = '/index.php?restart_check=reset'; // // const KIOSK_VIDEOS = [ // '/video/1.mp4', // '/video/video_ajet_2.mp4', // '/video/2.mp4', // '/video/3.mp4', // '/video/4.mp4', // '/video/5.mp4', // '/video/6.mp4', // '/video/7.mp4', // ]; // // // ─── SAYFA GEÇİŞİ ───────────────────────────────────────────────────────────── // // Sayfalar zaten DOM'da hazır. Sadece aktif class'ı değiştir, sonra flip başlat. // let activePage = 0; // // function switchToPage(pageIndex) { // const bar = document.getElementById('flightTDBar'); // if (!bar) return; // // const pages = bar.querySelectorAll('.boardPage'); // pages.forEach((p, i) => p.classList.toggle('isActive', i === pageIndex)); // activePage = pageIndex; // // // Aktif sayfanın tüm dolu satırlarını flip et // const activeDom = pages[pageIndex]; // if (!activeDom) return; // // // Boş satırları atla — sadece içerik olan .flightTDKat / .flightTDBirim // const targets = activeDom.querySelectorAll( // '.flightTDRow:not(.isEmpty) .flightTDKat, .flightTDRow:not(.isEmpty) .flightTDBirim:not([style*="width:0"])' // ); // // // Hepsini aynı frame'de başlat // requestAnimationFrame(() => flipAll(targets)); // } // // // ─── FLIP ENGİNE ────────────────────────────────────────────────────────────── // function randomChar(finalChar) { // if (finalChar === ' ' || finalChar === '\u00a0') return '\u00a0'; // return FLIGHT_FLAP_CHARS[Math.floor(Math.random() * FLIGHT_FLAP_CHARS.length)] || ' '; // } // // function setTextBoxWithFlip(sp, nextText) { // if (!sp || sp.classList.contains('isSpace')) return; // // sp.classList.remove('isFlipping'); // sp.classList.add('isFlipping'); // // window.setTimeout(() => { // sp.textContent = nextText; // }, 58); // // window.setTimeout(() => { // sp.classList.remove('isFlipping'); // }, 128); // } // // function scrambleElement(el) { // // Mevcut span'ların içeriğini rastgele değiştir — DOM yapısına dokunma // const spans = el.children; // for (let i = 0; i < spans.length; i++) { // const sp = spans[i]; // if (sp.classList.contains('isSpace')) continue; // setTextBoxWithFlip(sp, randomChar(sp.dataset.final || sp.textContent)); // } // } // // function restoreElement(el) { // const spans = el.children; // for (let i = 0; i < spans.length; i++) { // const sp = spans[i]; // if (sp.dataset.final) setTextBoxWithFlip(sp, sp.dataset.final); // } // } // // function prepareElement(el) { // // data-final'ı bir kez hazırla, tekrar yazmaya gerek yok // if (el.dataset.flipReady) return; // const spans = el.children; // for (let i = 0; i < spans.length; i++) { // const sp = spans[i]; // if (!sp.classList.contains('isSpace')) { // sp.dataset.final = sp.textContent; // } // } // el.dataset.flipReady = '1'; // } // // function flipAll(targets) { // // Hazırlık — sadece ilk kez çalışır // targets.forEach(prepareElement); // // let step = 0; // // const tick = () => { // step++; // targets.forEach(el => { // if (step >= FLIP_REVEAL_STEP) { // restoreElement(el); // } else { // scrambleElement(el); // } // }); // // if (step < FLIP_SCRAMBLE_STEPS) { // setTimeout(tick, FLIP_STEP_MS); // } else { // // Son kez garantile // setTimeout(() => targets.forEach(restoreElement), 80); // } // }; // // setTimeout(tick, FLIP_STEP_MS); // } // // // ─── DÖNGÜ & ZAMANLAMA ──────────────────────────────────────────────────────── // let kioskCyclePageIndex = 0; // let kioskPageTimeout = null; // let flightBoardPageTimer = null; // // function stopKioskTimers() { // clearTimeout(kioskPageTimeout); // clearTimeout(flightBoardPageTimer); // } // // function startKatPlaniCycle() { // stopKioskTimers(); // showKatPlaniScreen(); // // // İlk sayfa zaten görünür (isActive PHP'den geliyor), hemen flip başlat // switchToPage(0); // kioskCyclePageIndex = 0; // // scheduleNextPage(); // } // // function scheduleNextPage() { // stopKioskTimers(); // const holdDelay = kioskCyclePageIndex === 0 ? FIRST_PAGE_HOLD_MS : PAGE_HOLD_MS; // const delay = FLIP_TOTAL_MS + holdDelay; // // kioskPageTimeout = setTimeout(() => { // const next = kioskCyclePageIndex + 1; // // if (next >= PAGE_COUNT) { // playNextKioskVideo(); // return; // } // // kioskCyclePageIndex = next; // switchToPage(next); // scheduleNextPage(); // }, delay); // } // // // ─── SLIDE (ALT BANT) ───────────────────────────────────────────────────────── // let flightFeedSlideIndex = 0; // // function updateFlightFeedSlide() { // const slides = document.querySelectorAll('.flightFeedSlide'); // if (!slides.length) return; // flightFeedSlideIndex = (flightFeedSlideIndex + 1) % slides.length; // slides.forEach((s, i) => s.classList.toggle('isActive', i === flightFeedSlideIndex)); // } // // // ─── VİDEO ──────────────────────────────────────────────────────────────────── // let kioskVideoIndex = 0; // let kioskIsVideoMode = false; // let kioskPreloadedVideos = []; // let kioskVideoFailSafeTimer = null; // let kioskVideoHideTimer = null; // // function supportsVideoPlayback() { // const v = document.createElement('video'); // if (!v || typeof v.canPlayType !== 'function') return false; // const r = v.canPlayType('video/mp4; codecs="avc1.42E01E"'); // return r === 'probably' || r === 'maybe'; // } // // function preloadKioskVideos() { // if (!supportsVideoPlayback()) { kioskPreloadedVideos = []; return; } // kioskPreloadedVideos = KIOSK_VIDEOS.map(src => { // const v = document.createElement('video'); // v.preload = 'auto'; // v.muted = v.defaultMuted = true; // v.playsInline = true; // v.setAttribute('muted', ''); // v.setAttribute('playsinline', ''); // v.setAttribute('webkit-playsinline', ''); // v.src = src; // v.load(); // return v; // }); // } // // function showKatPlaniScreen() { // const overlay = document.getElementById('videoOverlay'); // const screen = document.getElementById('katPlaniScreen'); // const player = document.getElementById('kioskVideoPlayer'); // // kioskIsVideoMode = false; // clearTimeout(kioskVideoFailSafeTimer); // clearTimeout(kioskVideoHideTimer); // // if (screen) screen.classList.remove('isHidden'); // if (!overlay || !player) return; // // overlay.classList.add('isExiting'); // player.classList.add('isExiting'); // // kioskVideoHideTimer = setTimeout(() => { // player.pause(); // player.onended = player.onerror = player.onloadeddata = player.oncanplay = null; // player.classList.remove('isReady', 'isExiting'); // overlay.classList.remove('isExiting', 'active'); // }, 420); // } // // function showVideoScreen(src, onEndedCallback) { // const overlay = document.getElementById('videoOverlay'); // const screen = document.getElementById('katPlaniScreen'); // const player = document.getElementById('kioskVideoPlayer'); // // if (!overlay || !screen || !player || !supportsVideoPlayback()) { // if (typeof onEndedCallback === 'function') onEndedCallback(); // return; // } // // kioskIsVideoMode = true; // stopKioskTimers(); // clearTimeout(kioskVideoFailSafeTimer); // clearTimeout(kioskVideoHideTimer); // // screen.classList.add('isHidden'); // overlay.classList.remove('isExiting'); // player.classList.remove('isExiting'); // overlay.classList.add('active'); // // player.pause(); // player.muted = player.defaultMuted = true; // player.autoplay = player.playsInline = true; // player.setAttribute('muted', ''); // player.setAttribute('autoplay', ''); // player.setAttribute('playsinline', ''); // player.setAttribute('webkit-playsinline', ''); // player.classList.remove('isReady'); // // const match = kioskPreloadedVideos.find(v => (v.currentSrc || v.src || '').indexOf(src) !== -1); // player.src = match ? (match.currentSrc || match.src) : src; // player.currentTime = 0; // player.load(); // // const finish = () => { // clearTimeout(kioskVideoFailSafeTimer); // player.onended = player.onerror = player.onloadeddata = player.oncanplay = null; // if (typeof onEndedCallback === 'function') onEndedCallback(); // }; // // player.onended = finish; // player.onerror = finish; // // let started = false; // const tryPlay = () => { // if (started) return; // started = true; // clearTimeout(kioskVideoFailSafeTimer); // player.classList.add('isReady'); // const p = player.play(); // if (p && typeof p.catch === 'function') p.catch(finish); // }; // // player.onloadeddata = tryPlay; // player.oncanplay = tryPlay; // // kioskVideoFailSafeTimer = setTimeout(finish, 12000); // } // // function playNextKioskVideo() { // if (!KIOSK_VIDEOS.length) { startKatPlaniCycle(); return; } // const src = KIOSK_VIDEOS[kioskVideoIndex % KIOSK_VIDEOS.length]; // kioskVideoIndex = (kioskVideoIndex + 1) % KIOSK_VIDEOS.length; // showVideoScreen(src, () => { // showKatPlaniScreen(); // startKatPlaniCycle(); // }); // } // // // ─── RESTART WATCHER ────────────────────────────────────────────────────────── // let restartCheckInterval = null; // let restartInProgress = false; // // async function resetRestartFileAndReload() { // if (restartInProgress) return; // restartInProgress = true; // try { await fetch(RESTART_RESET_URL, { method: 'POST', cache: 'no-store' }); } catch (_) {} // window.location.reload(); // } // // async function checkRestartFile() { // if (restartInProgress) return; // try { // const r = await fetch(`${RESTART_FILE_URL}?t=${Date.now()}`, { cache: 'no-store' }); // if (!r.ok) return; // if ((await r.text()).trim() === '1') await resetRestartFileAndReload(); // } catch (_) {} // } // // function startRestartWatcher() { // if (restartCheckInterval) clearInterval(restartCheckInterval); // checkRestartFile(); // restartCheckInterval = setInterval(checkRestartFile, RESTART_CHECK_INTERVAL_MS); // } // // // ─── BAŞLANGIÇ ─────────────────────────────────────────────────────────────── // window.addEventListener('load', () => { // preloadKioskVideos(); // startKatPlaniCycle(); // startRestartWatcher(); // }); // // // //