aboutsummaryrefslogtreecommitdiff
path: root/public/js/form.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/js/form.js')
-rw-r--r--public/js/form.js34
1 files changed, 18 insertions, 16 deletions
diff --git a/public/js/form.js b/public/js/form.js
index cf138e6..4be83c6 100644
--- a/public/js/form.js
+++ b/public/js/form.js
@@ -1,28 +1,30 @@
1//function sendMessage(){} 1//function sendMessage(){}
2 2
3// modif des paramètre d'envoi d'e-mail depuis l'espace admin 3// modif des paramètres d'e-mail: e-mail source/dest, mot de passe, serveur smtp & chiffrement tls/ssl
4function changeRecipient(id){ 4function setEmailParam(what_param, id){
5 const email = document.getElementById('recipient').value; 5 const value = document.getElementById(what_param + '_' + id).value;
6 const hidden = document.getElementById('recipient_hidden').value; 6 const hidden = document.getElementById(what_param + '_hidden_' + id).value;
7 7
8 fetch('index.php?action=recipient_email', { 8 fetch('index.php?action=set_email_param', {
9 method: 'POST', 9 method: 'POST',
10 headers: { 10 headers: {
11 'Content-Type': 'application/json' 11 'Content-Type': 'application/json'
12 }, 12 },
13 body: JSON.stringify({ id: id, email: email, hidden: hidden }) 13 body: JSON.stringify({ id: id, what_param: what_param, value: value, hidden: hidden })
14 }) 14 })
15 .then(response => response.json()) 15 .then(response => response.json())
16 .then(data => { 16 .then(data => {
17 if(data.success){ 17 if(data.success){
18 toastNotify('Adresse e-mail de destination modifiée'); 18 toastNotify(what_param + ' a été modifié(e)');
19 } 19 }
20 else{ 20 else{
21 toastNotify('E-mail non valide'); 21 console.error("Erreur rencontrée à l'enregistrement de cette donnée en base de données");
22 toastNotify("Erreur rencontrée à l'enregistrement de cette donnée en base de données");
22 } 23 }
23 }) 24 })
24 .catch(error => { 25 .catch(error => {
25 console.error('Erreur:', error); 26 console.error('Erreur:', error);
27 toastNotify('Erreur:', error);
26 }); 28 });
27} 29}
28 30
@@ -33,8 +35,8 @@ function checkCase(){
33} 35}
34 36
35function sendTestEmail(id){ 37function sendTestEmail(id){
36 const admin_form = document.querySelector('.admin_form'); 38 //const admin_form = document.querySelector('.admin_form');
37 const test_email_success = document.querySelector('.test_email_success'); 39 const test_email_success = document.querySelector('.test_email_success_' + id);
38 test_email_success.innerHTML = 'Envoi en cours, veuillez patienter'; 40 test_email_success.innerHTML = 'Envoi en cours, veuillez patienter';
39 test_email_success.style.backgroundColor = 'yellow'; 41 test_email_success.style.backgroundColor = 'yellow';
40 42
@@ -67,12 +69,12 @@ function sendTestEmail(id){
67} 69}
68 70
69function sendVisitorEmail(id){ 71function sendVisitorEmail(id){
70 const email_name = document.getElementById('email_name').value; 72 const email_name = document.getElementById('email_name_' + id).value;
71 const email_address = document.getElementById('email_address').value; 73 const email_address = document.getElementById('email_address_' + id).value;
72 const email_message = document.getElementById('email_message').value; 74 const email_message = document.getElementById('email_message_' + id).value;
73 const email_captcha = document.getElementById('email_captcha').value; 75 const email_captcha = document.getElementById('email_captcha_' + id).value;
74 const email_hidden = document.getElementById('email_hidden').value; 76 const email_hidden = document.getElementById('email_hidden_' + id).value;
75 const send_email_success = document.querySelector('.send_email_success'); 77 const send_email_success = document.querySelector('.send_email_success_' + id);
76 78
77 if(email_name === '' || email_address === '' || email_message === '' || email_captcha === ''){ 79 if(email_name === '' || email_address === '' || email_message === '' || email_captcha === ''){
78 toastNotify('Veuillez remplir tous les champs.'); 80 toastNotify('Veuillez remplir tous les champs.');