2017-07-17 14:25:35 +02:00
|
|
|
function updateAvailability() {
|
2017-08-20 00:45:25 +02:00
|
|
|
if (this.responseText === "y") {
|
|
|
|
document.getElementById("avail").innerHTML = "Available!";
|
|
|
|
} else {
|
|
|
|
document.getElementById("avail").innerHTML = "Not available";
|
|
|
|
}
|
2017-07-17 14:25:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function checkAvailability() {
|
2017-08-20 00:45:25 +02:00
|
|
|
var name = document.getElementById("name").value;
|
2017-07-17 14:25:35 +02:00
|
|
|
|
2017-08-20 00:45:25 +02:00
|
|
|
if (name === "") {
|
|
|
|
document.getElementById("avail").innerHTML = "";
|
|
|
|
return
|
|
|
|
}
|
2017-07-17 14:25:35 +02:00
|
|
|
|
2017-08-20 00:45:25 +02:00
|
|
|
document.getElementById("avail").innerHTML = "Checking availability...";
|
2017-07-17 14:25:35 +02:00
|
|
|
|
2017-08-20 00:45:25 +02:00
|
|
|
var req = new XMLHttpRequest();
|
|
|
|
req.addEventListener("load", updateAvailability);
|
|
|
|
req.open("GET", "/api/check_availability?name="+encodeURIComponent(name));
|
|
|
|
req.send();
|
2017-07-17 14:25:35 +02:00
|
|
|
}
|