2017-07-17 14:25:35 +02:00
|
|
|
function checkAvailability() {
|
2019-02-23 05:33:52 +01:00
|
|
|
let name = document.getElementById('name').value;
|
|
|
|
if (name === '') {
|
|
|
|
document.getElementById('avail').innerHTML = '';
|
2019-02-23 05:37:28 +01:00
|
|
|
return;
|
2017-08-20 00:45:25 +02:00
|
|
|
}
|
2019-02-23 05:33:52 +01:00
|
|
|
document.getElementById('avail').innerHTML = 'Checking availability...';
|
|
|
|
fetch('/api/check_availability?name=' + encodeURIComponent(name), {
|
|
|
|
method: 'GET',
|
|
|
|
mode: 'cors'
|
|
|
|
}).then(g => g.text()).then(g => {
|
|
|
|
if (g === 'y') {
|
|
|
|
document.getElementById('avail').innerHTML = 'Available!';
|
|
|
|
} else {
|
|
|
|
document.getElementById('avail').innerHTML = 'Not available';
|
|
|
|
}
|
|
|
|
}).catch((e) => {
|
2019-02-23 05:37:28 +01:00
|
|
|
document.getElementById('avail').innerHTML = 'Server error';
|
2019-02-23 05:33:52 +01:00
|
|
|
});
|
|
|
|
}
|