/** * NodeCast TV Application Entry Point */ class App { constructor() { this.currentPage = 'home'; this.pages = {}; // Initialize components this.player = new VideoPlayer(); this.channelList = new ChannelList(); this.sourceManager = new SourceManager(); this.epgGuide = new EpgGuide(); // Initialize page controllers this.pages.home = new HomePage(this); this.pages.guide = new GuidePage(this); this.pages.movies = new MoviesPage(this); this.pages.series = new SeriesPage(this); this.pages.settings = new SettingsPage(this); this.init(); } async init() { // Navigation handling document.querySelectorAll('.nav-link').forEach(link => { link.addEventListener('click', (e) => { e.preventDefault(); this.navigateTo(link.dataset.page); }); }); // Toggle groups button document.getElementById('toggle-groups').addEventListener('click', () => { this.channelList.toggleAllGroups(); }); // Initialize home page await this.pages.home.init(); this.navigateTo('home'); console.log('NodeCast TV initialized'); } navigateTo(pageName) { // Update nav document.querySelectorAll('.nav-link').forEach(link => { link.classList.toggle('active', link.dataset.page === pageName); }); // Update pages document.querySelectorAll('.page').forEach(page => { page.classList.toggle('active', page.id === `page-${pageName}`); }); // Notify page controllers if (this.pages[this.currentPage]?.hide) { this.pages[this.currentPage].hide(); } this.currentPage = pageName; if (this.pages[pageName]?.show) { this.pages[pageName].show(); } } } // Start app when DOM is ready document.addEventListener('DOMContentLoaded', () => { window.app = new App(); });