/** * Project Master Overseas Common JS * 공통 네비게이션, 통합 모달 관리, 유틸리티 */ // --- 공통 상수 --- const API = { INQUIRIES: '/api/inquiries', PROJECT_DATA: '/project-data', PROJECT_ACTIVITY: '/project-activity', AVAILABLE_DATES: '/available-dates', SYNC: '/sync', STOP_SYNC: '/stop-sync', AUTH_CRAWL: '/auth/crawl', ANALYZE_FILE: '/analyze-file', ATTACHMENTS: '/attachments' }; // --- 네비게이션 --- function navigateTo(path) { location.href = path; } // --- 통합 모달 관리자 --- const ModalManager = { open(modalId) { const modal = document.getElementById(modalId); if (modal) { modal.style.display = 'flex'; // 포커스 자동 이동 (ID 입력란이 있으면) const firstInput = modal.querySelector('input'); if (firstInput) firstInput.focus(); } }, close(modalId) { const modal = document.getElementById(modalId); if (modal) modal.style.display = 'none'; }, closeAll() { document.querySelectorAll('.modal-overlay').forEach(m => m.style.display = 'none'); } }; // --- 유틸리티 함수 --- const Utils = { formatDate(dateStr) { if (!dateStr) return '-'; return dateStr.replace(/-/g, '.'); }, // 상태별 CSS 클래스 매핑 getStatusClass(status) { const map = { '완료': 'status-complete', '작업 중': 'status-working', '확인 중': 'status-checking', '정상': 'active', '주의': 'warning', '방치': 'stale', '데이터 없음': 'unknown' }; return map[status] || 'status-pending'; }, // 한글 파일명 인코딩 안전 처리 getSafeFileUrl(filename) { return `/sample_files/${encodeURIComponent(filename)}`; } }; // --- 전역 이벤트 --- document.addEventListener('keydown', (e) => { if (e.key === 'Escape') ModalManager.closeAll(); }); document.addEventListener('DOMContentLoaded', () => { console.log("Common module initialized."); });