Files
nahakubuilde 3e4355d20d Fix issue with picture upload and rendering based on 4 modes how Obsidian can store images.
Add there option to view other files and uplod/download files from main view
2025-06-28 12:41:34 +01:00

59 lines
2.4 KiB
HTML

<!-- Search Modal -->
<div class="modal fade" id="searchModal" tabindex="-1" aria-labelledby="searchModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content bg-dark text-light">
<div class="modal-header border-0 pb-1">
<h5 class="modal-title" id="searchModalLabel">Search Notes</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body pt-1">
<input type="text" id="modal-search-input" class="form-control mb-3" placeholder="Search all notes...">
<div id="modal-search-results" style="max-height: 300px; overflow-y: auto;"></div>
</div>
</div>
</div>
</div>
<!-- Search Modal JavaScript -->
<script>
document.addEventListener('DOMContentLoaded', function() {
var searchModal = document.getElementById('searchModal');
var openSearchBtn = document.getElementById('open-search-modal');
var modalInput = document.getElementById('modal-search-input');
var modalResults = document.getElementById('modal-search-results');
if (openSearchBtn && searchModal && modalInput && modalResults) {
var bsModal = new bootstrap.Modal(searchModal);
openSearchBtn.addEventListener('click', function() {
bsModal.show();
});
// Handle modal shown event to ensure proper focus timing
searchModal.addEventListener('shown.bs.modal', function() {
modalInput.focus();
modalInput.select();
});
modalInput.addEventListener('input', function() {
var q = modalInput.value.trim();
if (!q) { modalResults.innerHTML = ''; return; }
// AJAX search
fetch(`/search?q=${encodeURIComponent(q)}`)
.then(r => r.json())
.then(results => {
if (!results.length) { modalResults.innerHTML = '<div class=" small">No results found.</div>'; return; }
modalResults.innerHTML = results.map(r =>
`<div class="mb-2">
<a href="${r.url}" class="fw-bold text-primary">${r.title}</a><br>
<span class="small text-light">...${r.snippet}...</span>
</div>`
).join('');
});
});
// Clear results/input on close
searchModal.addEventListener('hidden.bs.modal', function() {
modalInput.value = '';
modalResults.innerHTML = '';
});
}
});
</script>