/** * Airhub App - Main JavaScript * Premium IoT Device Control Center */ // ======================================== // App State // ======================================== const AppState = { currentPage: 'home', isConnecting: false, connectedDevice: null, }; // ======================================== // Page Navigation // ======================================== function navigateTo(pageId) { const pages = document.querySelectorAll('.page'); pages.forEach(page => page.classList.remove('active')); const targetPage = document.getElementById(`page-${pageId}`); if (targetPage) { targetPage.classList.add('active'); AppState.currentPage = pageId; } } // ======================================== // Connect Button Handler // ======================================== function handleConnect() { if (AppState.isConnecting) return; AppState.isConnecting = true; const btn = document.getElementById('connect-btn'); const btnText = btn.querySelector('.btn-text'); // Add brief feedback before navigating btn.style.pointerEvents = 'none'; btnText.textContent = '正在搜索...'; // Navigate to Bluetooth search page setTimeout(() => { window.location.href = 'bluetooth.html'; }, 300); } // ======================================== // Initialization // ======================================== document.addEventListener('DOMContentLoaded', () => { console.log('Airhub App initialized'); // Add touch feedback for mobile const buttons = document.querySelectorAll('button'); buttons.forEach(btn => { btn.addEventListener('touchstart', () => { btn.style.transform = 'scale(0.98)'; }); btn.addEventListener('touchend', () => { btn.style.transform = ''; }); }); });