BadgeCloner/templates/writeBadge.html

48 lines
1.6 KiB
HTML

<!DOCTYPE html>
<html lang="fr">
<head>
<title>Badge Cloner</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="author" content="j4rj4r">
<link rel="stylesheet" href="/res/css/bulma/bulma.min.css">
</head>
<body>
<div class="container is-fluid">
<section class="hero"><div class="hero-body">
<div class="container has-text-centered">
<h1 class="title is-spaced">Vos badges</h1>
<h2 class="subtitle">En attente du badge numéro {{nbBadge}}</h2>
{% if error is defined %}
<p class="has-text-danger"> {{ error }}</p>
{% endif %}
<a href="/" class="button is-link">Annuler</a>
</div>
</div>
</section>
</div>
</body>
</html>
<script>
if ({{nbBadge}} >= 1) {
fetch(`/copyBadge/{{uid}}`)
.then(response => response.json())
.then(jsonresponse => {
if (jsonresponse.status == "OK") {
if ({{nbBadge-1}} == 0) {
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 {
throw new Error(jsonresponse.message);
}
})
.catch(error => {
window.location.href = `/writeBadge/{{nbBadge}}/{{uid}}?error=${error.message}`;
});
} else {
window.location.href = "/";
}
</script>