aboutsummaryrefslogtreecommitdiff
path: root/public/js
diff options
context:
space:
mode:
Diffstat (limited to 'public/js')
-rw-r--r--public/js/form.js101
1 files changed, 97 insertions, 4 deletions
diff --git a/public/js/form.js b/public/js/form.js
index 4be83c6..7cee970 100644
--- a/public/js/form.js
+++ b/public/js/form.js
@@ -1,5 +1,3 @@
1//function sendMessage(){}
2
3// modif des paramètres d'e-mail: e-mail source/dest, mot de passe, serveur smtp & chiffrement tls/ssl 1// modif des paramètres d'e-mail: e-mail source/dest, mot de passe, serveur smtp & chiffrement tls/ssl
4function setEmailParam(what_param, id){ 2function setEmailParam(what_param, id){
5 const value = document.getElementById(what_param + '_' + id).value; 3 const value = document.getElementById(what_param + '_' + id).value;
@@ -28,8 +26,41 @@ function setEmailParam(what_param, id){
28 }); 26 });
29} 27}
30 28
31function checkCase(){ 29function keepEmails(block_id){
32 if(document.getElementById('email_address').value.match('[A-Z]')){ 30 const form = document.getElementById('keep_emails_' + block_id);
31 const warning = document.getElementById('form_warning_' + block_id);
32 if(!form || !warning){
33 return;
34 }
35
36 fetch('index.php?action=keep_emails', {
37 method: 'POST',
38 headers: {
39 'Content-Type': 'application/json'
40 },
41 body: JSON.stringify({
42 id: block_id,
43 checked: form.checked
44 })
45 })
46 .then(response => response.json())
47 .then(data => {
48 if(data.success){
49 form.checked = data.checked;
50 data.checked ? warning.classList.remove('hidden') : warning.classList.add('hidden');
51 toastNotify(data.checked ? "Les e-mails seront conservés. Pensez au RGPD." : "Les nouveaux e-mails ne seront pas conservés.");
52 }
53 else{
54 toastNotify("Erreur, le réglage n'a pas été enregistré par le serveur.");
55 }
56 })
57 .catch(error => {
58 console.error('Erreur:', error);
59 });
60}
61
62function checkCase(id){
63 if(document.getElementById('email_address_' + id).value.match('[A-Z]')){
33 toastNotify("Votre e-mail comporte une lettre majuscule, il s'agit probablement d'une erreur."); 64 toastNotify("Votre e-mail comporte une lettre majuscule, il s'agit probablement d'une erreur.");
34 } 65 }
35} 66}
@@ -118,4 +149,66 @@ function sendVisitorEmail(id){
118 .catch(error => { 149 .catch(error => {
119 console.error('Erreur:', error); 150 console.error('Erreur:', error);
120 }); 151 });
152}
153
154function deleteEmail(id){
155 const table_row = document.getElementById(id);
156 if(!table_row){
157 return;
158 }
159
160 if(confirm('Voulez-vous supprimer cet e-mail ?')){
161 fetch('index.php?action=delete_email', {
162 method: 'POST',
163 headers: {
164 'Content-Type': 'application/json'
165 },
166 body: JSON.stringify({
167 id: id
168 })
169 })
170 .then(response => response.json())
171 .then(data => {
172 if(data.success){
173 table_row.remove();
174 toastNotify("E-mail supprimé");
175 }
176 else{}
177 })
178 .catch(error => {
179 console.error('Erreur:', error);
180 });
181 }
182}
183
184function toggleSensitiveEmail(id){
185 const table_row = document.getElementById(id);
186 const checkbox = table_row.querySelector("input[class='make_checkbox_sensitive']");
187 const deletion_date = table_row.querySelector(".deletion_date");
188 if(!table_row || !checkbox || !deletion_date){
189 return;
190 }
191
192 fetch('index.php?action=toggle_sensitive_email', {
193 method: 'POST',
194 headers: {
195 'Content-Type': 'application/json'
196 },
197 body: JSON.stringify({
198 id: id,
199 checked: checkbox.checked
200 })
201 })
202 .then(response => response.json())
203 .then(data => {
204 if(data.success){
205 checkbox.checked = data.checked;
206 deletion_date.innerHTML = data.deletion_date;
207 console.log(data.checked ? "Cet e-mail est maintenant considéré comme sensible." : "Cet e-mail n'est plus sensible.");
208 }
209 else{}
210 })
211 .catch(error => {
212 console.error('Erreur:', error);
213 });
121} \ No newline at end of file 214} \ No newline at end of file