2020-01-21 23:26:49 +03:00
|
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
|
|
const searchBar = document.getElementById("search-bar");
|
|
|
|
const searchBtn = document.getElementById("search-submit");
|
|
|
|
|
2020-01-22 04:07:08 +03:00
|
|
|
// Automatically focus on search field
|
|
|
|
searchBar.focus();
|
|
|
|
searchBar.select();
|
|
|
|
|
2020-01-21 23:26:49 +03:00
|
|
|
searchBar.addEventListener("keyup", function(event) {
|
|
|
|
if (event.keyCode === 13) {
|
|
|
|
event.preventDefault();
|
|
|
|
searchBtn.click();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
searchBtn.onclick = function() {
|
|
|
|
window.location.href = '/search?q=' + encodeURI(searchBar.value);
|
|
|
|
}
|
|
|
|
});
|