diff options
author | polo <ordipolo@gmx.fr> | 2025-07-04 00:43:35 +0200 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2025-07-04 00:43:35 +0200 |
commit | 2d7bacce891eab0adb0263d598bfe44418788f42 (patch) | |
tree | 4353250f80cc556a278640f22c194a0033d05829 /public | |
parent | ea3eaf84c6de3f96d6bb73e817147f8571fd6c1f (diff) | |
download | cms-2d7bacce891eab0adb0263d598bfe44418788f42.zip |
formulaire de contact 3
Diffstat (limited to 'public')
-rw-r--r-- | public/css/form.css | 8 | ||||
-rw-r--r-- | public/js/form.js | 87 |
2 files changed, 88 insertions, 7 deletions
diff --git a/public/css/form.css b/public/css/form.css index 473252c..d317360 100644 --- a/public/css/form.css +++ b/public/css/form.css | |||
@@ -1,4 +1,4 @@ | |||
1 | .form form{ | 1 | .form_inputs{ |
2 | background-color: white; | 2 | background-color: white; |
3 | margin: auto; | 3 | margin: auto; |
4 | padding: 10px; | 4 | padding: 10px; |
@@ -14,7 +14,7 @@ | |||
14 | .form .full_width_column{ | 14 | .form .full_width_column{ |
15 | grid-column: 1 / span 2; | 15 | grid-column: 1 / span 2; |
16 | } | 16 | } |
17 | .form form input[type=submit] | 17 | .form_inputs input[type=submit] |
18 | { | 18 | { |
19 | color: #ff1d04; | 19 | color: #ff1d04; |
20 | font-size: medium; | 20 | font-size: medium; |
@@ -22,7 +22,7 @@ | |||
22 | background-color: white; | 22 | background-color: white; |
23 | border: lightgrey 2px outset; | 23 | border: lightgrey 2px outset; |
24 | } | 24 | } |
25 | .form form input[type=submit]:hover | 25 | .form_inputs input[type=submit]:hover |
26 | { | 26 | { |
27 | background-color: #ffff00; | 27 | background-color: #ffff00; |
28 | border-radius: 4px; | 28 | border-radius: 4px; |
@@ -42,7 +42,7 @@ | |||
42 | } | 42 | } |
43 | 43 | ||
44 | @media screen and (max-width: 600px){ | 44 | @media screen and (max-width: 600px){ |
45 | .form form{ | 45 | .form_inputs{ |
46 | grid-template-columns: 1fr; | 46 | grid-template-columns: 1fr; |
47 | } | 47 | } |
48 | .form label{ | 48 | .form label{ |
diff --git a/public/js/form.js b/public/js/form.js index 1752f55..0be2313 100644 --- a/public/js/form.js +++ b/public/js/form.js | |||
@@ -1,7 +1,9 @@ | |||
1 | //function sendMessage(){} | 1 | //function sendMessage(){} |
2 | 2 | ||
3 | function changeRecipient(id){ | 3 | // modif des paramètre d'envoi d'e-mail depuis l'espace admin |
4 | /*function changeRecipient(id){ | ||
4 | const email = document.getElementById('recipient').value; | 5 | const email = document.getElementById('recipient').value; |
6 | const hidden = document.getElementById('recipient_hidden').value; | ||
5 | const warning = document.querySelector('.no_recipient_warning'); | 7 | const warning = document.querySelector('.no_recipient_warning'); |
6 | 8 | ||
7 | fetch('index.php?action=recipient_email', { | 9 | fetch('index.php?action=recipient_email', { |
@@ -9,7 +11,7 @@ function changeRecipient(id){ | |||
9 | headers: { | 11 | headers: { |
10 | 'Content-Type': 'application/json' | 12 | 'Content-Type': 'application/json' |
11 | }, | 13 | }, |
12 | body: JSON.stringify({ id: id, email: email }) | 14 | body: JSON.stringify({ id: id, email: email, hidden: hidden }) |
13 | }) | 15 | }) |
14 | .then(response => response.json()) | 16 | .then(response => response.json()) |
15 | .then(data => { | 17 | .then(data => { |
@@ -18,10 +20,89 @@ function changeRecipient(id){ | |||
18 | toastNotify('Adresse e-mail de destination modifiée'); | 20 | toastNotify('Adresse e-mail de destination modifiée'); |
19 | } | 21 | } |
20 | else{ | 22 | else{ |
21 | console.error('Erreur: echec de la modification de l\'adresse e-mail de destination'); | 23 | toastNotify('E-mail non valide'); |
22 | } | 24 | } |
23 | }) | 25 | }) |
24 | .catch(error => { | 26 | .catch(error => { |
25 | console.error('Erreur:', error); | 27 | console.error('Erreur:', error); |
26 | }); | 28 | }); |
29 | }*/ | ||
30 | |||
31 | function sendTestEmail(){ | ||
32 | const admin_form = document.querySelector('.admin_form'); | ||
33 | const test_email_success = document.querySelector('.test_email_success'); | ||
34 | test_email_success.innerHTML = 'Envoi en cours, veuillez patienter'; | ||
35 | test_email_success.style.backgroundColor = '#f0f0f0'; | ||
36 | |||
37 | fetch('index.php?action=test_email', { | ||
38 | method: 'POST', | ||
39 | headers: { | ||
40 | 'Content-Type': 'application/json' | ||
41 | }, | ||
42 | body: JSON.stringify({}) | ||
43 | }) | ||
44 | .then(response => response.json()) | ||
45 | .then(data => { | ||
46 | let message; | ||
47 | let color; | ||
48 | if(data.success){ | ||
49 | message = 'E-mail de test envoyé avec succès'; | ||
50 | color = 'lawngreen'; | ||
51 | } | ||
52 | else{ | ||
53 | message = "Erreur à l'envoi de l'e-mail"; | ||
54 | color = "orangered" | ||
55 | } | ||
56 | test_email_success.innerHTML = message; | ||
57 | toastNotify(message); | ||
58 | test_email_success.style.backgroundColor = color; | ||
59 | }) | ||
60 | .catch(error => { | ||
61 | console.error('Erreur:', error); | ||
62 | }); | ||
63 | } | ||
64 | |||
65 | function sendVisitorEmail(){ | ||
66 | const send_email_success = document.querySelector('.send_email_success'); | ||
67 | send_email_success.innerHTML = 'Envoi en cours, veuillez patienter'; | ||
68 | send_email_success.style.backgroundColor = 'initial'; | ||
69 | |||
70 | const email_name = document.getElementById('email_name').value; | ||
71 | const email_address = document.getElementById('email_address').value; | ||
72 | const email_message = document.getElementById('email_message').value; | ||
73 | const email_captcha = document.getElementById('email_captcha').value; | ||
74 | const email_hidden = document.getElementById('email_hidden').value; | ||
75 | |||
76 | fetch('index.php?action=send_email', { | ||
77 | method: 'POST', | ||
78 | headers: { | ||
79 | 'Content-Type': 'application/json' | ||
80 | }, | ||
81 | body: JSON.stringify({ | ||
82 | name: email_name, | ||
83 | email: email_address, | ||
84 | message: email_message, | ||
85 | captcha: email_captcha, | ||
86 | hidden: email_hidden | ||
87 | }) | ||
88 | }) | ||
89 | .then(response => response.json()) | ||
90 | .then(data => { | ||
91 | let message; | ||
92 | let color; | ||
93 | if(data.success){ | ||
94 | message = 'Votre E-mail a été envoyé!'; | ||
95 | color = 'lawngreen'; | ||
96 | } | ||
97 | else{ | ||
98 | message = "Votre message n'a pas pu être envoyé, votre e-mail ou le captcha ne sont peut-être pas corrects"; | ||
99 | color = "orangered" | ||
100 | } | ||
101 | send_email_success.innerHTML = message; | ||
102 | toastNotify(message); | ||
103 | send_email_success.style.backgroundColor = color; | ||
104 | }) | ||
105 | .catch(error => { | ||
106 | console.error('Erreur:', error); | ||
107 | }); | ||
27 | } \ No newline at end of file | 108 | } \ No newline at end of file |