improve merging by year, support query url
This commit is contained in:
@ -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>
|
||||
|
Reference in New Issue
Block a user