implement basic functionality of contact via form->smtp

This commit is contained in:
Yannik Schmidt
2020-09-01 17:14:52 +02:00
parent 0a753093e0
commit aad780bd43
7 changed files with 103 additions and 14 deletions

35
static/contact.js Normal file
View File

@@ -0,0 +1,35 @@
function submitForm(){
/* show the waiting dialog */
dialog = document.getElementById("waiting-dialog")
dialog.style.disply = "block"
setMainBackgroundOpacity(0.5)
/* submit the form */
xhr = new XMLHttpRequest();
xhr.open("POST", "/your/url/name.php");
xhr.onload =
formData = new FormData(document.getElementById("contact-form"));
xhr.send(formData);
mainContainer = document.getElementById("main-container")
mainContainer.style.opacity = 0.5
window.location.href = "/thanks"
// after x seconds forward to thx
}
function formSubmitFinished(event){
if(event.target.status != 200){
showErrorMessage(); // blocking
setMainBackgroundOpacity(0.5)
}else{
window.location.href = "/thanks"
}
}
function setMainBackgroundOpacity(opacity){
mainContainer = document.getElementById("main-container")
mainContainer.style.opacity = opacity
}