diff --git a/public/dashboard/js/dashboard.js b/public/dashboard/js/dashboard.js index e4d863a..67135cc 100644 --- a/public/dashboard/js/dashboard.js +++ b/public/dashboard/js/dashboard.js @@ -707,17 +707,7 @@ function setupFilters() { }); } - // Setup video toggle button - const toggleBtn = document.getElementById('video-toggle'); - if (toggleBtn) { - toggleBtn.addEventListener('click', () => { - if (isVideoPlaying) { - stopVideo(); - } else { - startVideo(); - } - }); - } + // Video toggle button akan di-setup di DOMContentLoaded setelah load camera data } function initCharts() { @@ -782,6 +772,18 @@ document.addEventListener('DOMContentLoaded', async () => { await loadLocationsForCamera(); await loadGatesForCamera(); + // Setup video toggle button SETELAH load camera data + const toggleBtn = document.getElementById('video-toggle'); + if (toggleBtn) { + toggleBtn.addEventListener('click', () => { + if (isVideoPlaying) { + stopVideo(); + } else { + startVideo(); + } + }); + } + // Cek lokasi awal untuk show/hide video showVideoPanel(state.locationCode);