#12 Reset quick search after usage

This commit is contained in:
Serraniel 2020-07-29 13:58:06 +02:00
parent c311c996e6
commit 76bc6ae965
Signed by: Serraniel
GPG key ID: 3690B4E7364525D3

View file

@ -37,13 +37,19 @@ function initSearch() {
function handleQuickSearch(event) {
if (event.key === 'Enter') {
let quickSearchElement = document.getElementById(quickSearchID);
let linkElement = document.getElementById(quickSearchLink);
let url = new URL(window.location.origin)
url.pathname = '/search';
url.searchParams.append('q', document.getElementById(quickSearchID).value);
url.searchParams.append('q', quickSearchElement.value);
let linkElement = document.getElementById(quickSearchLink);
linkElement.href = `${url.pathname}${url.search}`;
linkElement.click();
// clean up afterwards
linkElement.href = '';
quickSearchElement.value = '';
}
}