Update readBadge JS script
This commit is contained in:
parent
8534574862
commit
e2c3392ff9
@ -21,28 +21,25 @@
|
||||
</body>
|
||||
</html>
|
||||
<script>
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', '/detectBadge', true);
|
||||
xhr.onload = function() {
|
||||
var jsonreponse = JSON.parse(xhr.response);
|
||||
if (jsonreponse.status == "OK") {
|
||||
fetch('/detectBadge')
|
||||
.then(response => response.json())
|
||||
.then(jsonresponse => {
|
||||
if (jsonresponse.status == "OK") {
|
||||
document.getElementById("info").textContent = "Tentative de copie du badge ...";
|
||||
|
||||
var xhr2 = new XMLHttpRequest();
|
||||
xhr2.open('GET', '/readBadge', true);
|
||||
xhr2.onload = function() {
|
||||
var jsonreponse = JSON.parse(xhr2.response);
|
||||
if (jsonreponse.status == "OK") {
|
||||
window.location.href = "/wait?raison=Appuyer%20sur%20le%20bouton%20pour%20commencer%20la%20copie%20des%20badges.&redirect=/writeBadge/{{nbBadge}}/" + jsonreponse.UID;
|
||||
return fetch('/readBadge');
|
||||
} else {
|
||||
window.location.href = "/?error=" + jsonreponse.message;
|
||||
throw new Error(jsonresponse.message);
|
||||
}
|
||||
};
|
||||
xhr2.send(null);
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(jsonresponse => {
|
||||
if (jsonresponse.status == "OK") {
|
||||
window.location.href = `/wait?raison=Appuyer%20sur%20le%20bouton%20pour%20commencer%20la%20copie%20des%20badges.&redirect=/writeBadge/{{nbBadge}}/${jsonresponse.UID}`;
|
||||
} else {
|
||||
window.location.href = "/?error=" + jsonreponse.message;
|
||||
throw new Error(jsonresponse.message);
|
||||
}
|
||||
};
|
||||
|
||||
xhr.send(null);
|
||||
})
|
||||
.catch(error => {
|
||||
window.location.href = `/?error=${error.message}`;
|
||||
});
|
||||
</script>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user