refactor: 시스템 전반 코드 리팩토링 및 문의사항 UI 개선
This commit is contained in:
77
js/common.js
77
js/common.js
@@ -1,25 +1,78 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
// --- 전역 이벤트: 모든 모달창 ESC 키로 닫기 ---
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Escape') {
|
||||
// 대시보드 모달
|
||||
if (typeof closeAuthModal === 'function') closeAuthModal();
|
||||
if (typeof closeActivityModal === 'function') closeActivityModal();
|
||||
|
||||
// 메일 시스템 모달
|
||||
if (typeof closeModal === 'function') closeModal();
|
||||
if (typeof closeAddressBook === 'function') closeAddressBook();
|
||||
// --- 통합 모달 관리자 ---
|
||||
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.");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user