diff options
Diffstat (limited to 'public')
| -rw-r--r-- | public/js/form.js | 24 | ||||
| -rw-r--r-- | public/js/main.js | 2 |
2 files changed, 19 insertions, 7 deletions
diff --git a/public/js/form.js b/public/js/form.js index 5c5a164..cf138e6 100644 --- a/public/js/form.js +++ b/public/js/form.js | |||
| @@ -26,6 +26,12 @@ function changeRecipient(id){ | |||
| 26 | }); | 26 | }); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | function checkCase(){ | ||
| 30 | if(document.getElementById('email_address').value.match('[A-Z]')){ | ||
| 31 | toastNotify("Votre e-mail comporte une lettre majuscule, il s'agit probablement d'une erreur."); | ||
| 32 | } | ||
| 33 | } | ||
| 34 | |||
| 29 | function sendTestEmail(id){ | 35 | function sendTestEmail(id){ |
| 30 | const admin_form = document.querySelector('.admin_form'); | 36 | const admin_form = document.querySelector('.admin_form'); |
| 31 | const test_email_success = document.querySelector('.test_email_success'); | 37 | const test_email_success = document.querySelector('.test_email_success'); |
| @@ -61,15 +67,21 @@ function sendTestEmail(id){ | |||
| 61 | } | 67 | } |
| 62 | 68 | ||
| 63 | function sendVisitorEmail(id){ | 69 | function sendVisitorEmail(id){ |
| 64 | const send_email_success = document.querySelector('.send_email_success'); | ||
| 65 | send_email_success.innerHTML = 'Envoi en cours, veuillez patienter'; | ||
| 66 | send_email_success.style.backgroundColor = 'yellow'; | ||
| 67 | |||
| 68 | const email_name = document.getElementById('email_name').value; | 70 | const email_name = document.getElementById('email_name').value; |
| 69 | const email_address = document.getElementById('email_address').value; | 71 | const email_address = document.getElementById('email_address').value; |
| 70 | const email_message = document.getElementById('email_message').value; | 72 | const email_message = document.getElementById('email_message').value; |
| 71 | const email_captcha = document.getElementById('email_captcha').value; | 73 | const email_captcha = document.getElementById('email_captcha').value; |
| 72 | const email_hidden = document.getElementById('email_hidden').value; | 74 | const email_hidden = document.getElementById('email_hidden').value; |
| 75 | const send_email_success = document.querySelector('.send_email_success'); | ||
| 76 | |||
| 77 | if(email_name === '' || email_address === '' || email_message === '' || email_captcha === ''){ | ||
| 78 | toastNotify('Veuillez remplir tous les champs.'); | ||
| 79 | return; | ||
| 80 | } | ||
| 81 | else{ | ||
| 82 | send_email_success.innerHTML = 'Envoi en cours, veuillez patienter'; | ||
| 83 | send_email_success.style.backgroundColor = 'yellow'; | ||
| 84 | } | ||
| 73 | 85 | ||
| 74 | fetch('index.php?action=send_email', { | 86 | fetch('index.php?action=send_email', { |
| 75 | method: 'POST', | 87 | method: 'POST', |
| @@ -90,7 +102,7 @@ function sendVisitorEmail(id){ | |||
| 90 | let message; | 102 | let message; |
| 91 | let color; | 103 | let color; |
| 92 | if(data.success){ | 104 | if(data.success){ |
| 93 | message = 'Votre E-mail a été envoyé!'; | 105 | message = 'Votre e-mail a été envoyé!'; |
| 94 | color = 'lawngreen'; | 106 | color = 'lawngreen'; |
| 95 | } | 107 | } |
| 96 | else{ | 108 | else{ |
| @@ -98,8 +110,8 @@ function sendVisitorEmail(id){ | |||
| 98 | color = "orangered" | 110 | color = "orangered" |
| 99 | } | 111 | } |
| 100 | send_email_success.innerHTML = message; | 112 | send_email_success.innerHTML = message; |
| 101 | toastNotify(message); | ||
| 102 | send_email_success.style.backgroundColor = color; | 113 | send_email_success.style.backgroundColor = color; |
| 114 | toastNotify(message); | ||
| 103 | }) | 115 | }) |
| 104 | .catch(error => { | 116 | .catch(error => { |
| 105 | console.error('Erreur:', error); | 117 | console.error('Erreur:', error); |
diff --git a/public/js/main.js b/public/js/main.js index 2ffd33b..4be7843 100644 --- a/public/js/main.js +++ b/public/js/main.js | |||
| @@ -33,7 +33,7 @@ function toastNotify(message) { | |||
| 33 | var toast = document.getElementById('toast'); | 33 | var toast = document.getElementById('toast'); |
| 34 | toast.textContent = message; | 34 | toast.textContent = message; |
| 35 | toast.className = 'toast show'; | 35 | toast.className = 'toast show'; |
| 36 | setTimeout(function(){ toast.className = toast.className.replace('show', ''); }, 3000); | 36 | setTimeout(function(){ toast.className = toast.className.replace('show', ''); }, 5000); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | 39 | ||
