Update writeBadge JS script
This commit is contained in:
parent
e2c3392ff9
commit
e6ca31fbec
@ -25,28 +25,23 @@
|
|||||||
</html>
|
</html>
|
||||||
<script>
|
<script>
|
||||||
if ({{nbBadge}} >= 1) {
|
if ({{nbBadge}} >= 1) {
|
||||||
var xhr = new XMLHttpRequest();
|
fetch(`/copyBadge/{{uid}}`)
|
||||||
xhr.open('GET', '/copyBadge/{{uid}}', true);
|
.then(response => response.json())
|
||||||
|
.then(jsonresponse => {
|
||||||
xhr.onload = function() {
|
if (jsonresponse.status == "OK") {
|
||||||
var jsonreponse = JSON.parse(xhr.response);
|
if ({{nbBadge-1}} == 0) {
|
||||||
if (jsonreponse.status == "OK") {
|
window.location.href = "/wait?raison=Tous%20les%20badges%20sont%20copi%C3%A9s%20%21&redirect=/";
|
||||||
//console.log("Badge cloné")
|
} else {
|
||||||
if ({{nbBadge-1}} == 0 ){
|
window.location.href = `/wait?raison=Badge%20clon%C3%A9%20%21%20Appuyer%20sur%20le%20bouton%20pour%20passer%20au%20badge%20suivant.&redirect=/writeBadge/{{nbBadge-1}}/{{uid}}`;
|
||||||
window.location.href = "/wait?raison=Tous%20les%20badges%20sont%20copi%C3%A9s%20%21&redirect=/";
|
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
window.location.href = "/wait?raison=Badge%20clon%C3%A9%20%21%20Appuyer%20sur%20le%20bouton%20pour%20passer%20au%20badge%20suivant.&redirect=/writeBadge/{{nbBadge-1}}/{{uid}}";
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
window.location.href = "/writeBadge/{{nbBadge}}/{{uid}}" + "?error=" + jsonreponse.message;
|
throw new Error(jsonresponse.message);
|
||||||
}
|
}
|
||||||
|
})
|
||||||
};
|
.catch(error => {
|
||||||
|
window.location.href = `/writeBadge/{{nbBadge}}/{{uid}}?error=${error.message}`;
|
||||||
xhr.send(null);
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
window.location.href = "/"
|
window.location.href = "/";
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user