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:
parent
8d79c44830
commit
bba5343206
@ -18,20 +18,18 @@ 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")
|
||||
|
||||
document.getElementById("search-results").innerHTML = ``;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user