diff --git a/monitor.php b/monitor.php index 816becc..4add473 100644 --- a/monitor.php +++ b/monitor.php @@ -2407,7 +2407,7 @@ $carMonitorSession = car_monitor_launcher_session(); let currentLang = 'ko'; const DEFAULT_USAGE_REFRESH_INTERVAL_SEC = 10; - const CAR_MONITOR_SESSION = ; + let CAR_MONITOR_SESSION = ; const CMD_MAP = { se: { label: 'cmdStatus', icon: 'fa-search', bg: 'var(--box-bg-blue)', color: 'var(--accent-blue)' }, @@ -2924,11 +2924,13 @@ $carMonitorSession = car_monitor_launcher_session(); } } - function initCalibrationSettings() { + function showCalibrationSettings() { const btn = document.getElementById('settings-btn'); if (!btn || !CAR_MONITOR_SESSION?.admin) return; btn.classList.remove('d-none'); + if (btn.dataset.ready === '1') return; + btn.dataset.ready = '1'; btn.addEventListener('click', openCalibrationModal); document.getElementById('calibration-close-btn')?.addEventListener('click', closeCalibrationModal); @@ -2940,6 +2942,25 @@ $carMonitorSession = car_monitor_launcher_session(); }); } + async function initCalibrationSettings() { + if (CAR_MONITOR_SESSION?.admin) { + showCalibrationSettings(); + return; + } + + try { + const res = await fetch('https://chaegeon.com/custom/launcher/api.php?adminSession=1', { + credentials: 'include', + cache: 'no-store', + }); + const data = await res.json(); + if (res.ok && data?.authenticated && data?.admin) { + CAR_MONITOR_SESSION = { ...CAR_MONITOR_SESSION, authenticated: true, admin: true }; + showCalibrationSettings(); + } + } catch (_) {} + } + function openCalibrationModal() { const overlay = document.getElementById('calibration-overlay'); if (!overlay) return;