1
0
Fork 0
mirror of https://gitlab.com/hagrid-keyserver/hagrid.git synced 2023-02-13 20:55:02 -05:00

upload: simplify automatic POST request

This commit is contained in:
Vincent Breitmoser 2019-09-26 22:58:28 +02:00
parent 6df212f087
commit 02321777b9
No known key found for this signature in database
GPG key ID: 7BD18320DEADFA11
3 changed files with 17 additions and 44 deletions

View file

@ -1,34 +1 @@
const container = document.getElementById("container");
const postform = document.getElementById("postform");
const pleasewait = document.getElementById("pleasewait");
const failed = document.getElementById("failed");
const form = document.getElementById("postform");
const url = form.getAttribute("action");
fetch(url, { method: "POST" })
.then(result => result.text())
.then(body => {
const frag = document.createElement("div");
frag.innerHTML = body;
container.appendChild(frag);
const result = document.getElementById("verification-result");
if (result !== null) {
while (result.firstChild) {
container.appendChild(result.firstChild);
}
container.removeChild(frag);
} else {
// Leave the full content appended since it'll likely be plain text
}
// Hide the pleasewait too
pleasewait.style.display = "none";
})
.catch(err => {
// On error, hide the 'please wait' and show the 'Something went wrong'
pleasewait.style.display = "none";
failed.textContent = failed.textContent + err;
failed.style.display = "block";
});
// Hide the form and display the 'please wait' block
postform.style.display = "none";
pleasewait.style.display = "block";
document.getElementById("postform").submit();

11
dist/assets/site.css vendored
View file

@ -267,3 +267,14 @@ span.email {
.attribution a {
color: #ccc;
}
input.textbutton {
padding: 0px;
border: none;
background: none;
margin: 0px;
cursor: pointer;
color: blue;
font-family: inherit;
font-size: inherit;
}

View file

@ -1,16 +1,11 @@
{{#> layout}}
<div class="row" id="container">
<form method="POST" action="/verify/{{token}}" id="postform">
<p>
Please click here to complete the verification process:
<input type="submit" value="Validate"/>
</p>
</form>
<p style="display: none" id="pleasewait">
Please wait while your email address is verified…
</p>
<p style="display: none" id="failed">
Something went wrong:
Verifying your email address…
<form method="POST" action="/verify/{{token}}" id="postform">
If the process doesn't complete after a few seconds, <input type="submit" class="textbutton" value="click here" />.
</form>
</p>
</div>