135 lines
5.4 KiB
JavaScript
135 lines
5.4 KiB
JavaScript
// ===== modals.js 맨 첫줄에 추가 =====
|
|
function updateDomainSectionVisibility() {
|
|
const section = document.getElementById('domainSection');
|
|
if (!section) return;
|
|
const hasFolder = typeof folderPath !== 'undefined' && folderPath && folderPath.trim() !== '';
|
|
const hasLinks = typeof referenceLinks !== 'undefined' && referenceLinks && referenceLinks.length > 0;
|
|
section.style.display = (hasFolder || hasLinks) ? 'block' : 'none';
|
|
}
|
|
// ===== 폴더 모달 =====
|
|
function openFolderModal() {
|
|
document.getElementById('folderModal').classList.add('active');
|
|
document.getElementById('folderPath').focus();
|
|
}
|
|
|
|
function closeFolderModal() {
|
|
document.getElementById('folderModal').classList.remove('active');
|
|
}
|
|
|
|
function submitFolder() {
|
|
const path = document.getElementById('folderPath').value.trim();
|
|
if (!path) {
|
|
alert('폴더 경로를 입력해주세요.');
|
|
return;
|
|
}
|
|
|
|
folderPath = document.getElementById('folderPath').value;
|
|
closeFolderModal();
|
|
updateInputStatus();
|
|
setStatus('폴더 경로 설정됨', true);
|
|
|
|
// 서버에 폴더 검토 요청
|
|
fetch('/api/check-folder', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ folder_path: folderPath })
|
|
})
|
|
.then(r => r.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
document.getElementById('totalCount').textContent = data.total + '개';
|
|
document.getElementById('okCount').textContent = data.ok + '개 ✓';
|
|
document.getElementById('unknownCount').textContent = data.unknown + '개';
|
|
|
|
// 미확인 파일 목록
|
|
const listEl = document.getElementById('unknownFilesList');
|
|
if (listEl && data.unknown_list) {
|
|
listEl.innerHTML = data.unknown_list
|
|
.map(name => `<div style="font-size:11px; color:var(--ui-dim); padding:2px 0;">${name}</div>`)
|
|
.join('');
|
|
}
|
|
} else {
|
|
document.getElementById('totalCount').textContent = '오류';
|
|
alert('폴더 검토 실패: ' + (data.error || ''));
|
|
}
|
|
})
|
|
.catch(err => {
|
|
document.getElementById('totalCount').textContent = '오류';
|
|
console.error('[Folder]', err);
|
|
});
|
|
updateDomainSectionVisibility();
|
|
if (typeof onFolderSetComplete === 'function') {
|
|
onFolderSetComplete();
|
|
}
|
|
}
|
|
|
|
function toggleUnknownFiles() {
|
|
document.getElementById('unknownFilesBox').classList.toggle('show');
|
|
}
|
|
|
|
function openFolder() {
|
|
alert('폴더 열기는 Engine이 실행 중일 때만 가능합니다.');
|
|
}
|
|
|
|
// ===== 링크 모달 =====
|
|
function openLinkModal() {
|
|
document.getElementById('linkModal').classList.add('active');
|
|
}
|
|
|
|
function closeLinkModal() {
|
|
document.getElementById('linkModal').classList.remove('active');
|
|
}
|
|
|
|
function addLinkInput() {
|
|
const container = document.getElementById('linkInputList');
|
|
const input = document.createElement('input');
|
|
input.type = 'text';
|
|
input.className = 'link-input';
|
|
input.placeholder = 'https://...';
|
|
input.style = 'width:100%; padding:10px; border-radius:6px; border:1px solid var(--ui-border); background:var(--ui-bg); color:var(--ui-text); font-size:12px; margin-bottom:8px;';
|
|
container.appendChild(input);
|
|
}
|
|
|
|
function submitLinks() {
|
|
const inputs = document.querySelectorAll('#linkInputList .link-input');
|
|
referenceLinks = [];
|
|
inputs.forEach(input => {
|
|
const val = input.value.trim();
|
|
if (val) referenceLinks.push(val);
|
|
});
|
|
|
|
closeLinkModal();
|
|
updateInputStatus();
|
|
|
|
if (referenceLinks.length > 0) {
|
|
setStatus(`참고 링크 ${referenceLinks.length}개 설정됨`, true);
|
|
}
|
|
updateDomainSectionVisibility();
|
|
if (typeof onFolderSetComplete === 'function') {
|
|
onFolderSetComplete();
|
|
}
|
|
}
|
|
|
|
// ===== HTML 모달 =====
|
|
function openHtmlModal() {
|
|
document.getElementById('htmlModal').classList.add('active');
|
|
document.getElementById('htmlContent').focus();
|
|
}
|
|
|
|
function closeHtmlModal() {
|
|
document.getElementById('htmlModal').classList.remove('active');
|
|
}
|
|
|
|
function submitHtml() {
|
|
const html = document.getElementById('htmlContent').value.trim();
|
|
if (!html) {
|
|
alert('HTML을 입력해주세요.');
|
|
return;
|
|
}
|
|
|
|
inputContent = html;
|
|
closeHtmlModal();
|
|
updateInputStatus();
|
|
setStatus('HTML 입력 완료', true);
|
|
updateDomainSectionVisibility();
|
|
} |