diff options
Diffstat (limited to 'public')
| -rw-r--r-- | public/css/form.css | 4 | ||||
| -rw-r--r-- | public/css/show_emails.css | 24 | ||||
| -rw-r--r-- | public/js/form.js | 101 |
3 files changed, 124 insertions, 5 deletions
diff --git a/public/css/form.css b/public/css/form.css index c17662d..30673c9 100644 --- a/public/css/form.css +++ b/public/css/form.css | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | background-color: white; | 2 | background-color: white; |
| 3 | margin: auto; | 3 | margin: auto; |
| 4 | padding: 10px; | 4 | padding: 10px; |
| 5 | max-width: 800px; | ||
| 6 | display: grid; | 5 | display: grid; |
| 7 | grid-template-columns: auto 1fr; | 6 | grid-template-columns: auto 1fr; |
| 8 | gap: 10px; | 7 | gap: 10px; |
| @@ -35,6 +34,9 @@ | |||
| 35 | .form .admin_form i{ | 34 | .form .admin_form i{ |
| 36 | font-size: smaller; | 35 | font-size: smaller; |
| 37 | } | 36 | } |
| 37 | .form_warning{ | ||
| 38 | font-size: smaller; | ||
| 39 | } | ||
| 38 | 40 | ||
| 39 | @media screen and (max-width: 600px){ | 41 | @media screen and (max-width: 600px){ |
| 40 | .form_inputs{ | 42 | .form_inputs{ |
diff --git a/public/css/show_emails.css b/public/css/show_emails.css new file mode 100644 index 0000000..4fb9f3b --- /dev/null +++ b/public/css/show_emails.css | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | .show_emails p{ | ||
| 2 | font-size: smaller; | ||
| 3 | } | ||
| 4 | .show_emails table{ | ||
| 5 | |||
| 6 | padding: 10px; | ||
| 7 | border-collapse: collapse; | ||
| 8 | font-size: smaller; | ||
| 9 | } | ||
| 10 | .show_emails table th, .show_emails table td{ | ||
| 11 | background-color: white; | ||
| 12 | border: 1px black solid; | ||
| 13 | } | ||
| 14 | .show_emails table td{ | ||
| 15 | vertical-align: top; | ||
| 16 | text-align: center; | ||
| 17 | } | ||
| 18 | .show_emails table .email_delete_button{ | ||
| 19 | /*background-color: initial;*/ | ||
| 20 | /*border: none;*/ | ||
| 21 | } | ||
| 22 | .show_emails .action_icon{ | ||
| 23 | width: 20px; | ||
| 24 | } \ No newline at end of file | ||
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 |
| 4 | function setEmailParam(what_param, id){ | 2 | function 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 | ||
| 31 | function checkCase(){ | 29 | function 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 | |||
| 62 | function 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 | |||
| 154 | function 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 | |||
| 184 | function 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 |
