mirror of
https://github.com/Damillora/Yuika
synced 2024-12-26 14:13:46 +00:00
fix: remove search delay
This commit is contained in:
parent
8d79c44830
commit
bba5343206
@ -18,16 +18,14 @@ async function searchPosts(query) {
|
|||||||
document.getElementById("search-results").innerHTML = result;
|
document.getElementById("search-results").innerHTML = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
let searchTimeout;
|
|
||||||
|
|
||||||
if (window.yurikoSearchEndpoint != undefined) {
|
if (window.yurikoSearchEndpoint != undefined) {
|
||||||
var el = document.getElementById("search-query");
|
var el = document.getElementById("search-query");
|
||||||
el.addEventListener("input", function (e) {
|
el.addEventListener("input", function (e) {
|
||||||
if (searchTimeout) window.clearTimeout(searchTimeout);
|
|
||||||
var val = el.value;
|
var val = el.value;
|
||||||
if (val !== "") {
|
if (val !== "") {
|
||||||
document.getElementById("nav-menu").classList.add("menu__item--hidden")
|
document.getElementById("nav-menu").classList.add("menu__item--hidden")
|
||||||
searchTimeout = window.setTimeout(() => searchPosts(val), 2000);
|
searchPosts(val);
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("nav-menu").classList.remove("menu__item--hidden")
|
document.getElementById("nav-menu").classList.remove("menu__item--hidden")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user