Fix. Refactored code to be to standard

This commit is contained in:
eoghan.conlon 2023-08-07 19:14:11 +01:00
parent fb52550ef2
commit 050fd480fb

View file

@ -8,14 +8,16 @@
<body> <body>
<h2>Welcome to Skynet</h2> <h2>Welcome to Skynet</h2>
<p> <p>
Skynet is a server cluster that the UL Computer Society runs. If you previously had an account and need to activate it Skynet is a server cluster that the UL Computer Society runs. If you previously had an account and need to activate
please click <a href="./modify.html">here</a> to set a contact email address for your account. IF you are a new user, it
please click <a href="./modify.html">here</a> to set a contact email address for your account. IF you are a new
user,
please fill in the form below with the email that you use on ul wolves. please fill in the form below with the email that you use on ul wolves.
</p> </p>
<form id="register"> <form id="register">
<label for="mail">Email address</label> <label for="mail">Email address</label>
<input type="email" id="mail" name="email" /> <br /> <input type="email" id="mail" name="email"/> <br/>
<input type="submit" value="Submit" /> <input type="submit" value="Submit"/>
</form> </form>
<p id="formStatus"></p> <p id="formStatus"></p>
<footer> <footer>
@ -25,7 +27,7 @@
const formEl = document.getElementById('register'); const formEl = document.getElementById('register');
formEl.addEventListener('submit', (listener) => formHandler(listener)); formEl.addEventListener('submit', (listener) => formHandler(listener));
function formHandler(listener){ function formHandler(listener) {
listener.preventDefault(); listener.preventDefault();
const formData = new FormData(formEl); const formData = new FormData(formEl);
const email = formData.get("email"); const email = formData.get("email");
@ -35,7 +37,7 @@
body: JSON.stringify(object), body: JSON.stringify(object),
mode: "cors" mode: "cors"
}).then(res => { }).then(res => {
if(res.status === 200) { if (res.status === 200) {
document.getElementById('formStatus').innerHTML = "<span style='background-color: green; color: white'>Success</span>"; document.getElementById('formStatus').innerHTML = "<span style='background-color: green; color: white'>Success</span>";
} else if (res.status === 500) { } else if (res.status === 500) {
document.getElementById('formStatus').innerHTML = "<span style='background-color: red; color: white'>Failure</span>"; document.getElementById('formStatus').innerHTML = "<span style='background-color: red; color: white'>Failure</span>";