// 공통 네비게이션 컴포넌트 class CommonNavigation { constructor(currentPage = '') { this.currentPage = currentPage; this.init(); } init() { this.createNavigation(); this.addEventListeners(); } createNavigation() { const nav = document.createElement('nav'); nav.className = 'glass-effect border-b border-white/10'; nav.innerHTML = this.getNavigationHTML(); // body의 첫 번째 자식으로 추가 document.body.insertBefore(nav, document.body.firstChild); } getNavigationHTML() { return `

GroupWare

`; } getMenuItemHTML(pageKey, href, text, svgPath) { const isActive = this.currentPage === pageKey; const activeClass = isActive ? 'text-white bg-white/20' : 'text-white/80 hover:text-white hover:bg-white/10'; return ` ${text} `; } getMobileMenuItemHTML(pageKey, href, text, svgPath) { const isActive = this.currentPage === pageKey; const activeClass = isActive ? 'text-white bg-white/20' : 'text-white/80 hover:text-white hover:bg-white/10'; return ` ${text} `; } addEventListeners() { // 모바일 메뉴 토글 const mobileMenuButton = document.getElementById('mobile-menu-button'); const mobileMenu = document.getElementById('mobile-menu'); if (mobileMenuButton && mobileMenu) { mobileMenuButton.addEventListener('click', function() { mobileMenu.classList.toggle('hidden'); }); } } } // 전역 함수로 내비게이션 초기화 function initNavigation(currentPage = '') { // DOM이 로드된 후에 실행 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => { new CommonNavigation(currentPage); }); } else { new CommonNavigation(currentPage); } }