Update readBadge JS script
This commit is contained in:
parent
8534574862
commit
e2c3392ff9
@ -21,28 +21,25 @@
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
<script>
|
<script>
|
||||||
var xhr = new XMLHttpRequest();
|
fetch('/detectBadge')
|
||||||
xhr.open('GET', '/detectBadge', true);
|
.then(response => response.json())
|
||||||
xhr.onload = function() {
|
.then(jsonresponse => {
|
||||||
var jsonreponse = JSON.parse(xhr.response);
|
if (jsonresponse.status == "OK") {
|
||||||
if (jsonreponse.status == "OK") {
|
|
||||||
document.getElementById("info").textContent = "Tentative de copie du badge ...";
|
document.getElementById("info").textContent = "Tentative de copie du badge ...";
|
||||||
|
return fetch('/readBadge');
|
||||||
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;
|
|
||||||
} else {
|
} 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 {
|
} else {
|
||||||
window.location.href = "/?error=" + jsonreponse.message;
|
throw new Error(jsonresponse.message);
|
||||||
}
|
}
|
||||||
};
|
})
|
||||||
|
.catch(error => {
|
||||||
xhr.send(null);
|
window.location.href = `/?error=${error.message}`;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user