summaryrefslogtreecommitdiff
path: root/public/js/form.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/js/form.js')
-rw-r--r--public/js/form.js23
1 files changed, 11 insertions, 12 deletions
diff --git a/public/js/form.js b/public/js/form.js
index 0be2313..5c5a164 100644
--- a/public/js/form.js
+++ b/public/js/form.js
@@ -1,10 +1,9 @@
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ètre d'envoi d'e-mail depuis l'espace admin
4/*function changeRecipient(id){ 4function changeRecipient(id){
5 const email = document.getElementById('recipient').value; 5 const email = document.getElementById('recipient').value;
6 const hidden = document.getElementById('recipient_hidden').value; 6 const hidden = document.getElementById('recipient_hidden').value;
7 const warning = document.querySelector('.no_recipient_warning');
8 7
9 fetch('index.php?action=recipient_email', { 8 fetch('index.php?action=recipient_email', {
10 method: 'POST', 9 method: 'POST',
@@ -16,7 +15,6 @@
16 .then(response => response.json()) 15 .then(response => response.json())
17 .then(data => { 16 .then(data => {
18 if(data.success){ 17 if(data.success){
19 warning.classList.add('hidden');
20 toastNotify('Adresse e-mail de destination modifiée'); 18 toastNotify('Adresse e-mail de destination modifiée');
21 } 19 }
22 else{ 20 else{
@@ -26,20 +24,20 @@
26 .catch(error => { 24 .catch(error => {
27 console.error('Erreur:', error); 25 console.error('Erreur:', error);
28 }); 26 });
29}*/ 27}
30 28
31function sendTestEmail(){ 29function sendTestEmail(id){
32 const admin_form = document.querySelector('.admin_form'); 30 const admin_form = document.querySelector('.admin_form');
33 const test_email_success = document.querySelector('.test_email_success'); 31 const test_email_success = document.querySelector('.test_email_success');
34 test_email_success.innerHTML = 'Envoi en cours, veuillez patienter'; 32 test_email_success.innerHTML = 'Envoi en cours, veuillez patienter';
35 test_email_success.style.backgroundColor = '#f0f0f0'; 33 test_email_success.style.backgroundColor = 'yellow';
36 34
37 fetch('index.php?action=test_email', { 35 fetch('index.php?action=test_email', {
38 method: 'POST', 36 method: 'POST',
39 headers: { 37 headers: {
40 'Content-Type': 'application/json' 38 'Content-Type': 'application/json'
41 }, 39 },
42 body: JSON.stringify({}) 40 body: JSON.stringify({ id: id})
43 }) 41 })
44 .then(response => response.json()) 42 .then(response => response.json())
45 .then(data => { 43 .then(data => {
@@ -47,10 +45,10 @@ function sendTestEmail(){
47 let color; 45 let color;
48 if(data.success){ 46 if(data.success){
49 message = 'E-mail de test envoyé avec succès'; 47 message = 'E-mail de test envoyé avec succès';
50 color = 'lawngreen'; 48 color = 'chartreuse';
51 } 49 }
52 else{ 50 else{
53 message = "Erreur à l'envoi de l'e-mail"; 51 message = "Erreur à l'envoi de l'e-mail, vérifiez la configuration du serveur";
54 color = "orangered" 52 color = "orangered"
55 } 53 }
56 test_email_success.innerHTML = message; 54 test_email_success.innerHTML = message;
@@ -62,10 +60,10 @@ function sendTestEmail(){
62 }); 60 });
63} 61}
64 62
65function sendVisitorEmail(){ 63function sendVisitorEmail(id){
66 const send_email_success = document.querySelector('.send_email_success'); 64 const send_email_success = document.querySelector('.send_email_success');
67 send_email_success.innerHTML = 'Envoi en cours, veuillez patienter'; 65 send_email_success.innerHTML = 'Envoi en cours, veuillez patienter';
68 send_email_success.style.backgroundColor = 'initial'; 66 send_email_success.style.backgroundColor = 'yellow';
69 67
70 const email_name = document.getElementById('email_name').value; 68 const email_name = document.getElementById('email_name').value;
71 const email_address = document.getElementById('email_address').value; 69 const email_address = document.getElementById('email_address').value;
@@ -83,7 +81,8 @@ function sendVisitorEmail(){
83 email: email_address, 81 email: email_address,
84 message: email_message, 82 message: email_message,
85 captcha: email_captcha, 83 captcha: email_captcha,
86 hidden: email_hidden 84 hidden: email_hidden,
85 id: id
87 }) 86 })
88 }) 87 })
89 .then(response => response.json()) 88 .then(response => response.json())