Add usimp.chooseDomainServer
This commit is contained in:
@ -37,26 +37,34 @@ function createLoginWindow() {
|
||||
form.removeChild(d);
|
||||
}
|
||||
|
||||
function formError(msg) {
|
||||
let div = document.createElement("div");
|
||||
div.classList.add("error");
|
||||
div.innerText = msg;
|
||||
form.appendChild(div);
|
||||
}
|
||||
|
||||
usimp.lookup(form.domain.value)
|
||||
.then(res => {
|
||||
if (res.ok) {
|
||||
res.json()
|
||||
.then(data => console.log(data))
|
||||
.catch(reason => console.error(reason))
|
||||
.then(data => {
|
||||
console.log(data["domain"]);
|
||||
let domainServer = usimp.chooseDomainServer(data["domain_servers"]);
|
||||
console.log(domainServer);
|
||||
})
|
||||
.catch(reason => {
|
||||
console.error(reason);
|
||||
formError("Could not communicate with USIMP domain");
|
||||
})
|
||||
} else {
|
||||
document.getElementsByName("domain")[0].setAttribute("invalid", "invalid");
|
||||
let div = document.createElement("div");
|
||||
div.classList.add("error");
|
||||
div.innerText = "Invalid USIMP domain";
|
||||
form.appendChild(div);
|
||||
formError("Invalid USIMP domain");
|
||||
}
|
||||
})
|
||||
.catch(reason => {
|
||||
document.getElementsByName("domain")[0].setAttribute("invalid", "invalid");
|
||||
let div = document.createElement("div");
|
||||
div.classList.add("error");
|
||||
div.innerText = "Invalid USIMP domain";
|
||||
form.appendChild(div);
|
||||
formError("Invalid USIMP domain");
|
||||
})
|
||||
.finally(() => {
|
||||
for (let e of form) e.disabled = false;
|
||||
|
Reference in New Issue
Block a user