/** * TIS-RMS Static Web Application Logic * Interactive UI behavior for Windows and Android layouts */ let currentDevice = 'windows'; // 'windows' | 'android' let currentScreen = 'dashboard'; // ── Screen Definitions ───────────────────────────────────────── const SCREENS = [ { id: 'dashboard', label: 'Dashboard', icon: '' }, { id: 'students', label: 'Students', icon: '' }, { id: 'documents', label: 'Documents', icon: '' }, { id: 'archives', label: 'Archives', icon: '' }, { id: 'reports', label: 'Reports', icon: '' }, { id: 'users', label: 'Users', icon: '' }, { id: 'history', label: 'History', icon: '' }, { id: 'settings', label: 'Settings', icon: '' }, ]; document.addEventListener('DOMContentLoaded', () => { setupDeviceSwitcher(); setupNavigation(); startClock(); setScreen('dashboard'); }); // ── Device Switcher ──────────────────────────────────────────── function setupDeviceSwitcher() { const winBtn = document.getElementById('btn-view-windows'); const androidBtn = document.getElementById('btn-view-android'); const winWindow = document.getElementById('desktop-window'); const phoneMockup = document.getElementById('phone-frame'); winBtn.addEventListener('click', () => { currentDevice = 'windows'; winBtn.classList.add('active'); androidBtn.classList.remove('active'); winWindow.style.display = 'flex'; phoneMockup.style.display = 'none'; syncScreenView(); }); androidBtn.addEventListener('click', () => { currentDevice = 'android'; androidBtn.classList.add('active'); winBtn.classList.remove('active'); winWindow.style.display = 'none'; phoneMockup.style.display = 'flex'; syncScreenView(); }); } // ── Navigation ───────────────────────────────────────────────── function setupNavigation() { // Desktop Sidebar document.querySelectorAll('.win-nav-item').forEach(item => { item.addEventListener('click', () => { const scr = item.getAttribute('data-screen'); if (scr) setScreen(scr); }); }); // Mobile Drawer items document.querySelectorAll('.mobile-drawer-item').forEach(item => { item.addEventListener('click', () => { const scr = item.getAttribute('data-screen'); if (scr) { setScreen(scr); closeMobileDrawer(); } }); }); } function openMobileDrawer() { const drawer = document.getElementById('mobile-drawer'); const backdrop = document.getElementById('mobile-drawer-backdrop'); if (drawer) drawer.classList.add('active'); if (backdrop) backdrop.classList.add('active'); } function closeMobileDrawer() { const drawer = document.getElementById('mobile-drawer'); const backdrop = document.getElementById('mobile-drawer-backdrop'); if (drawer) drawer.classList.remove('active'); if (backdrop) backdrop.classList.remove('active'); } function setScreen(screenId) { currentScreen = screenId; syncScreenView(); } function syncScreenView() { // 1. Update active sidebar item on Windows document.querySelectorAll('.win-nav-item').forEach(el => { el.classList.toggle('active', el.getAttribute('data-screen') === currentScreen); }); // 2. Update active drawer item on Android document.querySelectorAll('.mobile-drawer-item').forEach(el => { el.classList.toggle('active', el.getAttribute('data-screen') === currentScreen); }); // 3. Update titles const desktopTitles = { dashboard: 'Dashboard Overview', students: 'Students Directory', documents: 'Document Folders', archives: 'Archived Records', reports: 'DepEd Transparency Board', users: 'User Management', history: 'System Audit Logs', settings: 'Account Settings' }; const mobileTitles = { dashboard: 'Dashboard', students: 'Students', documents: 'Documents', archives: 'Archives', reports: 'Reports', users: 'Users', history: 'History', settings: 'Settings' }; const desktopTitle = document.getElementById('stage-screen-title'); if (desktopTitle) desktopTitle.textContent = desktopTitles[currentScreen] || 'Dashboard Overview'; const mobileTitle = document.getElementById('phone-screen-title'); if (mobileTitle) mobileTitle.textContent = mobileTitles[currentScreen] || 'TIS RMS'; // 4. Update mobile header action buttons (matching screenshots) const mobileActions = document.getElementById('phone-header-actions'); if (mobileActions) { switch (currentScreen) { case 'dashboard': mobileActions.innerHTML = `
AT
`; break; case 'students': mobileActions.innerHTML = ` `; break; case 'documents': mobileActions.innerHTML = ` `; break; case 'archives': mobileActions.innerHTML = ` `; break; case 'reports': mobileActions.innerHTML = ` `; break; case 'users': mobileActions.innerHTML = ` `; break; case 'history': mobileActions.innerHTML = ` `; break; case 'settings': default: mobileActions.innerHTML = ``; break; } } // 5. Show/hide desktop screens document.querySelectorAll('.desktop-screen-content').forEach(view => { view.style.display = view.id === `win-screen-${currentScreen}` ? 'flex' : 'none'; }); // 6. Show/hide mobile screens document.querySelectorAll('.mobile-screen-content').forEach(view => { view.style.display = view.id === `phone-screen-${currentScreen}` ? 'flex' : 'none'; }); // 7. Show "+ Add Student" button on Students screen (Desktop) const addBtn = document.getElementById('btn-add-student-header'); if (addBtn) { addBtn.style.display = currentScreen === 'students' ? 'flex' : 'none'; } } // ── Collapsible Settings Sections ────────────────────────────── function toggleSettingsSection(id) { const body = document.getElementById(`settings-body-${id}`); const chevron = document.getElementById(`settings-chevron-${id}`); if (!body) return; const isHidden = body.style.display === 'none' || body.style.display === ''; body.style.display = isHidden ? 'flex' : 'none'; if (chevron) { chevron.style.transform = isHidden ? 'rotate(180deg)' : 'rotate(0deg)'; } } // ── Interactive Modals ───────────────────────────────────────── function openAddStudentModal() { const modal = document.getElementById('add-student-modal'); if (modal) modal.classList.add('active'); } function openStudentDetail(name, lrn, grade, status) { const modal = document.getElementById('student-detail-modal'); const title = document.getElementById('detail-student-name'); const lrnEl = document.getElementById('detail-student-lrn'); const gradeEl = document.getElementById('detail-student-grade'); const statusEl = document.getElementById('detail-student-status'); if (title) title.textContent = name; if (lrnEl) lrnEl.textContent = lrn; if (gradeEl) gradeEl.textContent = grade; if (statusEl) statusEl.textContent = status; if (modal) modal.classList.add('active'); } function closeModal(id) { const modal = document.getElementById(id); if (modal) modal.classList.remove('active'); } // ── Check For Updates Simulation (Real feature test) ─────────── function simulateUpdateCheck() { const btn = document.getElementById('btn-check-updates'); const banner = document.getElementById('update-result-banner'); const toast = document.getElementById('download-toast'); const toastFile = document.getElementById('toast-filename'); if (!btn) return; btn.disabled = true; btn.innerHTML = 'Checking for updates...'; banner.style.display = 'none'; setTimeout(() => { btn.disabled = false; btn.innerHTML = 'Check for Updates'; const isWin = currentDevice === 'windows'; const arch = isWin ? 'x64 (64-bit)' : 'ARM64 (64-bit)'; const file = isWin ? 'TIS_RMS_Setup_v1.0.24.exe' : 'TIS_RMS_64_v1.0.24.apk'; banner.style.display = 'block'; banner.innerHTML = `
✓ New Update Available: v1.0.24
Detected architecture: ${arch}
Matched package: ${file}
Launching download link in default browser...
`; if (toast && toastFile) { toastFile.textContent = file; toast.classList.add('active'); setTimeout(() => { toast.classList.remove('active'); }, 5000); } }, 1200); } // ── Clock for Android Status Bar ─────────────────────────────── function startClock() { function updateTime() { const el = document.getElementById('phone-clock'); if (!el) return; const now = new Date(); let hours = now.getHours(); let mins = now.getMinutes(); mins = mins < 10 ? '0' + mins : mins; el.textContent = `${hours}:${mins}`; } updateTime(); setInterval(updateTime, 30000); }