aboutsummaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
Diffstat (limited to 'public')
-rw-r--r--public/js/Fetcher.js1
-rw-r--r--public/js/main.js9
-rw-r--r--public/js/menu.js27
3 files changed, 12 insertions, 25 deletions
diff --git a/public/js/Fetcher.js b/public/js/Fetcher.js
index 0f56628..aaf808d 100644
--- a/public/js/Fetcher.js
+++ b/public/js/Fetcher.js
@@ -44,7 +44,6 @@ class Fetcher{
44 if(this.onFailure){ 44 if(this.onFailure){
45 this.onFailure(data); 45 this.onFailure(data);
46 } 46 }
47 console.error(data.message || "Erreur serveur");
48 return { success: false, data }; 47 return { success: false, data };
49 } 48 }
50 } 49 }
diff --git a/public/js/main.js b/public/js/main.js
index 3cc144a..39a31f5 100644
--- a/public/js/main.js
+++ b/public/js/main.js
@@ -206,15 +206,12 @@ function checkSocialNetwork(id){
206 endpoint: 'index.php?head_foot_social_check=' + id, 206 endpoint: 'index.php?head_foot_social_check=' + id,
207 method: 'POST', 207 method: 'POST',
208 onSuccess: (data) => { 208 onSuccess: (data) => {
209 console.log(data);
210
211 checkbox.checked = data.checked; 209 checkbox.checked = data.checked;
212 210 document.getElementById(id + '_content').src = 'assets/' + id.split('_')[1] + (data.checked ? '': '-nb') + '.svg'; // assets/facebook.svg ou assets/facebook-nb.svg
213 /*const color = checkbox.checked ? "#ff1d04" : "grey"; 211 toastNotify('Le logo "' + id.split('_')[1] + '" ' + (data.checked ? 'sera' : 'ne sera pas') + ' affiché aux visiteurs.');
214 clicked_menu_entry.querySelector("button").style.color = color;*/
215 }, 212 },
216 onFailure: (data) => { 213 onFailure: (data) => {
217 console.log(data); 214 console.error(data.message || "Erreur serveur");
218 } 215 }
219 }) 216 })
220 .send({checked: checkbox.checked}); 217 .send({checked: checkbox.checked});
diff --git a/public/js/menu.js b/public/js/menu.js
index 5e02387..c0ec623 100644
--- a/public/js/menu.js
+++ b/public/js/menu.js
@@ -122,29 +122,20 @@ function checkMenuEntry(page_id){
122 const checkbox = clicked_menu_entry.querySelector("input"); 122 const checkbox = clicked_menu_entry.querySelector("input");
123 let color; 123 let color;
124 124
125 fetch('index.php?menu_edit=display_in_menu', { 125 new Fetcher({
126 endpoint: 'index.php?menu_edit=display_in_menu',
126 method: 'POST', 127 method: 'POST',
127 headers: { 128 onSuccess: (data) => {
128 'Content-Type': 'application/json' 129 color = checkbox.checked ? "#ff1d04" : "grey";
130 clicked_menu_entry.querySelector("button").style.color = color;
131 nav_zone.innerHTML = '';
132 nav_zone.insertAdjacentHTML('afterbegin', data.nav);
129 }, 133 },
130 body: JSON.stringify({ id: clicked_menu_entry.id, checked: checkbox.checked }) 134 onFailure: (data) => {
131 })
132 .then(response => response.json())
133 .then(data => {
134 if(data.success){
135 color = checkbox.checked ? "#ff1d04" : "grey";
136 clicked_menu_entry.querySelector("button").style.color = color;
137
138 nav_zone.innerHTML = '';
139 nav_zone.insertAdjacentHTML('afterbegin', data.nav);
140 }
141 else{
142 console.error('Échec de l\'inversion'); 135 console.error('Échec de l\'inversion');
143 } 136 }
144 }) 137 })
145 .catch(error => { 138 .send({id: clicked_menu_entry.id, checked: checkbox.checked});
146 console.error('Erreur:', error);
147 });
148} 139}
149 140
150function editUrl(page_id, selector){ 141function editUrl(page_id, selector){