mirror of
https://github.com/krateng/maloja.git
synced 2025-06-05 14:45:00 -04:00
Add debounce timer to search, GH-370
This commit is contained in:
parent
1462883ab5
commit
26f26f36cb
@ -1,17 +1,23 @@
|
|||||||
var searches = []
|
var searches = []
|
||||||
|
var debounceTimer;
|
||||||
|
|
||||||
function search(searchfield) {
|
function search(searchfield) {
|
||||||
txt = searchfield.value;
|
clearTimeout(debounceTimer);
|
||||||
if (txt == "") {
|
debounceTimer = setTimeout(() => {
|
||||||
reallyclear()
|
const txt = searchfield.value;
|
||||||
}
|
if (txt == "") {
|
||||||
else {
|
reallyclear();
|
||||||
xhttp = new XMLHttpRequest();
|
}
|
||||||
searches.push(xhttp)
|
else {
|
||||||
xhttp.onreadystatechange = searchresult
|
const xhttp = new XMLHttpRequest();
|
||||||
xhttp.open("GET","/api/search?max=5&query=" + encodeURIComponent(txt), true);
|
searches.push(xhttp);
|
||||||
xhttp.send();
|
xhttp.onreadystatechange = searchresult
|
||||||
}
|
xhttp.open("GET","/api/search?max=5&query=" + encodeURIComponent(txt), true);
|
||||||
|
xhttp.send();
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user