improve merging by year, support query url

This commit is contained in:
2025-05-25 01:35:47 +02:00
parent 36e52afc93
commit 224446313a
3 changed files with 46 additions and 14 deletions

View File

@ -82,6 +82,7 @@
async function search() {
const query = document.getElementById('q').value.trim();
if (!query) return;
window.history.replaceState({}, '', '?q=' + encodeURIComponent(query));
const filmsDiv = document.getElementById('films');
filmsDiv.innerHTML = '<p class="loader">Searching...</p>';
@ -189,6 +190,14 @@
filmsDiv.innerHTML = `<p class="no-results">Search failed. Check the console.</p>`;
}
}
window.addEventListener('DOMContentLoaded', () => {
const params = new URLSearchParams(window.location.search);
const q = params.get('q');
if (q) {
document.getElementById('q').value = q;
search();
}
});
document.getElementById('q').addEventListener('keydown', e => { if (e.key === 'Enter') search(); });
</script>
</body>