2021-07-29 10:55:44 +02:00
|
|
|
var last_id = 0;
|
2021-07-26 16:54:51 +02:00
|
|
|
|
2021-07-21 21:19:36 +02:00
|
|
|
function searchDirectory() {
|
|
|
|
var input = document.getElementById("search").value;
|
2021-07-21 21:22:29 +02:00
|
|
|
if(input){
|
2021-08-16 16:27:20 +02:00
|
|
|
last_id++;
|
|
|
|
var request_id = last_id;
|
2021-07-21 21:19:36 +02:00
|
|
|
|
2021-08-16 16:27:20 +02:00
|
|
|
var data = new FormData();
|
|
|
|
data.append("query", input);
|
2021-07-26 23:01:48 +02:00
|
|
|
|
2021-08-16 16:27:20 +02:00
|
|
|
var xhttp = new XMLHttpRequest();
|
|
|
|
xhttp.onreadystatechange = function() {
|
|
|
|
if (request_id != last_id) return;
|
2021-07-21 21:19:36 +02:00
|
|
|
|
2021-08-16 16:27:20 +02:00
|
|
|
if (this.readyState == 4 && this.status == 200) {
|
|
|
|
var result_div = document.getElementById("search-results");
|
|
|
|
result_div.innerHTML = xhttp.responseText;
|
2021-07-21 21:19:36 +02:00
|
|
|
}
|
2021-07-21 21:22:29 +02:00
|
|
|
};
|
2021-08-16 16:27:20 +02:00
|
|
|
xhttp.open("POST", "/directory/search", true);
|
|
|
|
xhttp.send(data);
|
2021-07-21 21:22:29 +02:00
|
|
|
}
|
2021-08-16 16:27:20 +02:00
|
|
|
}
|