You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.8 KiB

{{define "body"}}
<form id="frm-register" method="post" action="/login">
<label for="inp-email">E-Mail:</label>
<input id="inp-email" name="email" type="email" value=""/>
<label for="inp-secret">Registration-Key:</label>
<input id="inp-secret" name="secret" type="password" value=""/>
<button id="btn-submit">Request User</button>
</form>
<div class="hidden" id="general-info"></div>
{{end}}
{{define "scripts"}}
<script>
let frm = document.getElementById("frm-register");
let infoBox = document.getElementById("general-info");
let sbtn = document.getElementById("btn-submit");
frm.addEventListener("submit", e => {
e.preventDefault();
let fd = new FormData(frm);
toggleDisabled(sbtn, "on");
setInfo(infoBox, "Processing Request...", "purple", "grey1");
toggleHidden(infoBox, "off");
fetch("/register", {
method: "POST",
body: new URLSearchParams({
email: fd.get("email"),
secret: fd.get("secret")
}),
headers: {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
}
}).then(res => {
if (res.status == 200) {
setInfo(infoBox, "Success", "green", "grey1");
setTimeout(() => {
toggleHidden(infoBox, "on");
}, 2000);
} else {
setInfo(infoBox, "Failure", "red", "grey1");
toggleHidden(infoBox, "off");
setTimeout(() => {
toggleHidden(infoBox, "on");
}, 2000);
}
toggleDisabled(sbtn, "off");
})
})
</script>
<script src="/static/js/helper.js"></script>
{{end}}