Skip to content

Commit

Permalink
drop external email service
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Dec 6, 2023
1 parent bf64a2b commit 704e6dc
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions _static/emails.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,14 @@ function getCookie(cname) {

async function emailButtonClick() {
let emailInput = document.getElementById("email-input");
let emailValue = emailInput.value;
let res = await fetch("https://premai.pythonanywhere.com/email?a=" + emailValue);
const ok = 200 <= res.status && res.status < 299;
const server_err = 500 <= res.status && res.status < 599;
if (ok || server_err) {
const valid = /^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(emailInput.value);
if (valid) {
let modal = document.getElementById('email-modal');
modal.style.display = 'none';
emailInput.value = "";
setCookie("address", emailInput.value, 365); // might fail if cookies disabled
} else {
let emailError = document.getElementsByClassName('email-error')[0];
let msg = await res.json();
emailError.innerHTML = "Error " + res.status + ": " + msg.status;
}
if (ok) {
setCookie("address", emailValue, 365); // might fail if cookies disabled
emailError.innerHTML = "Error: please enter a valid email";
}
}

Expand Down

0 comments on commit 704e6dc

Please sign in to comment.