60 lines
2.3 KiB
JavaScript
60 lines
2.3 KiB
JavaScript
// 문서 검색 기능
|
|
function searchDocuments() {
|
|
const searchTerm = document.getElementById('searchInput').value.toLowerCase();
|
|
if (searchTerm.trim() === '') {
|
|
alert('검색어를 입력해주세요.');
|
|
return;
|
|
}
|
|
|
|
// 간단한 검색 구현 (실제로는 서버 검색 또는 더 복잡한 로직 필요)
|
|
window.location.href = `search.html?q=${encodeURIComponent(searchTerm)}`;
|
|
}
|
|
|
|
// 문서 필터링 기능 (문서 목록 페이지용)
|
|
function filterDocuments(searchTerm) {
|
|
const documents = document.querySelectorAll('.document-item');
|
|
const term = searchTerm.toLowerCase();
|
|
|
|
documents.forEach(doc => {
|
|
const keywords = doc.getAttribute('data-keywords').toLowerCase();
|
|
const title = doc.querySelector('h3').textContent.toLowerCase();
|
|
const description = doc.querySelector('p').textContent.toLowerCase();
|
|
|
|
if (keywords.includes(term) || title.includes(term) || description.includes(term)) {
|
|
doc.style.display = 'flex';
|
|
} else {
|
|
doc.style.display = 'none';
|
|
}
|
|
});
|
|
}
|
|
|
|
// QR 코드 생성 (선택사항)
|
|
function generateQR() {
|
|
const url = 'http://192.168.0.3:10080';
|
|
const qrAPI = `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(url)}`;
|
|
|
|
const qrModal = document.createElement('div');
|
|
qrModal.innerHTML = `
|
|
<div style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); display: flex; justify-content: center; align-items: center; z-index: 1000;">
|
|
<div style="background: white; padding: 30px; border-radius: 15px; text-align: center;">
|
|
<h3>QR 코드로 접속</h3>
|
|
<img src="${qrAPI}" alt="QR Code" style="margin: 20px 0;">
|
|
<p>${url}</p>
|
|
<button onclick="this.parentElement.parentElement.remove()">닫기</button>
|
|
</div>
|
|
</div>
|
|
`;
|
|
document.body.appendChild(qrModal);
|
|
}
|
|
|
|
// Enter 키 검색
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const searchInput = document.getElementById('searchInput');
|
|
if (searchInput) {
|
|
searchInput.addEventListener('keypress', function(e) {
|
|
if (e.key === 'Enter') {
|
|
searchDocuments();
|
|
}
|
|
});
|
|
}
|
|
}); |