update host fix

This commit is contained in:
2021-09-26 22:49:52 +02:00
parent b499bb1be0
commit 8be07a291c
4 changed files with 44 additions and 27 deletions

View File

@ -5,19 +5,28 @@ function showCard(card, button) {
}
function updateHost(input) {
input.parentElement.classList.remove("ok")
input.parentElement.classList.remove("nok")
input.parentElement.classList.add("pending")
fetch(new Request("updateHost.php", {
method:"POST",
body:new FormData(input.form),
mode:"cors"
})).then(response => {
input.parentElement.classList.remove("pending")
if (response.ok) {
input.parentElement.classList.add("ok")
} else {
input.parentElement.classList.add("nok")
}
})
if (input.form.checkValidity()) {
var td = input.parentElement
var tr = td.parentElement
tr.classList.remove("ok")
tr.classList.remove("nok")
tr.classList.add("pending")
fetch(new Request("updateHost.php", {
method:"POST",
body:new FormData(input.form),
mode:"cors"
})).then(response => {
tr.classList.remove("pending")
if (response.ok) {
tr.classList.add("ok")
var linkInput = tr.getElementsByTagName('input')[7]
var linkA = tr.getElementsByTagName('a')[0]
linkA.href = linkInput.value
} else {
tr.classList.add("nok")
}
})
} else {
input.form.reportValidity()
}
}