1
0
mirror of https://github.com/Damillora/Yuika synced 2024-12-26 06:03:45 +00:00

fix: remove search delay

This commit is contained in:
Damillora 2021-05-08 12:43:27 +07:00
parent 8d79c44830
commit bba5343206

View File

@ -18,16 +18,14 @@ async function searchPosts(query) {
document.getElementById("search-results").innerHTML = result;
}
let searchTimeout;
if (window.yurikoSearchEndpoint != undefined) {
var el = document.getElementById("search-query");
el.addEventListener("input", function (e) {
if (searchTimeout) window.clearTimeout(searchTimeout);
var val = el.value;
if (val !== "") {
document.getElementById("nav-menu").classList.add("menu__item--hidden")
searchTimeout = window.setTimeout(() => searchPosts(val), 2000);
searchPosts(val);
} else {
document.getElementById("nav-menu").classList.remove("menu__item--hidden")