website/layouts/partials/searchbar.html

13 lines
386 B
HTML
Raw Normal View History

<div class="search">
<input id="searchbar" type="text" placeholder="Search" />
<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>