website/layouts/partials/searchbar.html

13 lines
405 B
HTML

<div class="search">
<input id="searchbar" type="text" placeholder='{{ i18n "searchbarTxt" }}' />
<a class="nerdlink" onclick="newSearch();">&#xf002;</a>
</div>
<script>
function newSearch() {
let term = searchbar.value.trim();
if (!term) return;
location.href = `/search?q=${term}`;
}
searchbar.onkeyup = (ev) => {if (ev.keyCode == 13) newSearch()};
</script>