// 공통 헤더 생성 및 관리 class CommonHeader { static create(currentPage = '') { return `

작업보고서

`; } static getNavButton(href, id, iconClass, text, isActive = false) { const activeClass = isActive ? ' active' : ''; return ` ${text} `; } static getNavButtonInternal(section, id, iconClass, text, isActive = false) { const activeClass = isActive ? ' active' : ''; if (section === 'list' || section === 'summary') { return ``; } return ``; } static init(currentPage = '') { // 헤더 HTML 삽입 const headerContainer = document.getElementById('header-container'); if (headerContainer) { headerContainer.innerHTML = this.create(); } // 현재 페이지 활성화 this.setActivePage(currentPage); } static setActivePage(currentPage) { // 모든 nav-link에서 active 클래스 제거 document.querySelectorAll('.nav-link').forEach(link => { link.classList.remove('active'); }); // 현재 페이지에 active 클래스 추가 const activeElement = document.getElementById(currentPage); if (activeElement) { activeElement.classList.add('active'); } } } // 관리자 버튼 클릭 처리 (전역 함수) function handleAdminClick() { if (window.currentUser && window.currentUser.role === 'admin') { window.location.href = 'admin.html'; } else { // 비밀번호 변경 모달 표시 if (typeof showPasswordChangeModal === 'function') { showPasswordChangeModal(); } } } // 섹션 전환 (메인 페이지용) function showSection(sectionName) { if (typeof window.showSection === 'function') { window.showSection(sectionName); } } // 관리자 메뉴 토글 function toggleAdminMenu() { const menu = document.getElementById('adminMenu'); if (menu) { menu.classList.toggle('hidden'); } } // 메뉴 외부 클릭 시 닫기 document.addEventListener('click', function(event) { const adminBtn = document.getElementById('adminBtn'); const adminMenu = document.getElementById('adminMenu'); if (adminBtn && adminMenu && !adminBtn.contains(event.target) && !adminMenu.contains(event.target)) { adminMenu.classList.add('hidden'); } });