summaryrefslogtreecommitdiff
path: root/public/js/main.js
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2025-05-10 23:51:37 +0200
committerpolo <ordipolo@gmx.fr>2025-05-10 23:51:37 +0200
commit4efa19d4357ab204d62397f1849e4651906e0e70 (patch)
treed35c82fdf20762fd6d778eba9bc6d76c9098e9b6 /public/js/main.js
parentaa8898ae00beaa0ac7e65e45c5f28199b25a9267 (diff)
downloadcms-4efa19d4357ab204d62397f1849e4651906e0e70.zip
fichiers manquant du commit précédent
Diffstat (limited to 'public/js/main.js')
-rw-r--r--public/js/main.js81
1 files changed, 1 insertions, 80 deletions
diff --git a/public/js/main.js b/public/js/main.js
index 7dacb7a..071a1db 100644
--- a/public/js/main.js
+++ b/public/js/main.js
@@ -36,6 +36,7 @@ function toastNotify(message) {
36 setTimeout(function(){ toast.className = toast.className.replace('show', ''); }, 3000); 36 setTimeout(function(){ toast.className = toast.className.replace('show', ''); }, 3000);
37} 37}
38 38
39
39// complète les fonctions dans tinymce.js 40// complète les fonctions dans tinymce.js
40function switchPositions(article_id, direction) 41function switchPositions(article_id, direction)
41{ 42{
@@ -202,84 +203,4 @@ function findParent(element, tag_name){
202 element = element.parentElement; 203 element = element.parentElement;
203 } 204 }
204 return null; 205 return null;
205}
206
207
208/* -- mode Modification d'une page -- */
209function renamePageBloc(bloc_id){
210 const input = document.getElementById("bloc_rename_" + bloc_id);
211 const title = document.getElementById(bloc_id).querySelector("h3");
212
213 fetch('index.php?bloc_edit=rename_page_bloc', {
214 method: 'POST',
215 headers: {
216 'Content-Type': 'application/json'
217 },
218 body: JSON.stringify({bloc_title: input.value, bloc_id: bloc_id})
219 })
220 .then(response => response.json())
221 .then(data => {
222 if(data.success){
223 title.innerHTML = data.title;
224 console.log(data.title);
225 toastNotify('Le bloc a été renommé: ' + data.title);
226 }
227 else{
228 console.error('Erreur au renommage du titre.');
229 }
230 })
231 .catch(error => {
232 console.error('Erreur:', error);
233 });
234}
235
236function switchBlocsPositions(bloc_id, direction, current_page) {
237 const current_bloc = document.getElementById(bloc_id);
238 const current_bloc_edit_zone = document.getElementById("bloc_edit_" + bloc_id);
239 var other_bloc;
240
241 if(direction == 'down'){
242 other_bloc = current_bloc.nextElementSibling;
243 }
244 else if(direction == 'up'){
245 other_bloc = current_bloc.previousElementSibling;
246 }
247
248 if(other_bloc == null || other_bloc.tagName !== 'SECTION')
249 {
250 console.log('Inversion impossible');
251 return;
252 }
253 const other_bloc_edit_zone = document.getElementById("bloc_edit_" + other_bloc.id);
254
255 fetch('index.php?page=' + current_page + '&bloc_edit=switch_blocs_positions', {
256 method: 'POST',
257 headers: {
258 'Content-Type': 'application/json'
259 },
260 body: JSON.stringify({ id1: bloc_id, id2: parseInt(other_bloc.id) })
261 })
262 .then(response => response.json())
263 .then(data => {
264 if(data.success)
265 {
266 if(direction == 'down'){
267 current_bloc.parentElement.insertBefore(other_bloc, current_bloc);
268 current_bloc_edit_zone.parentElement.insertBefore(other_bloc_edit_zone, current_bloc_edit_zone);
269 console.log('Inversion réussie');
270 }
271 else if(direction == 'up'){
272 other_bloc.parentElement.insertBefore(current_bloc, other_bloc);
273 other_bloc_edit_zone.parentElement.insertBefore(current_bloc_edit_zone, other_bloc_edit_zone);
274 console.log('Inversion réussie');
275 }
276 }
277 else {
278
279 console.error('Échec de l\'inversion');
280 }
281 })
282 .catch(error => {
283 console.error('Erreur:', error);
284 });
285} \ No newline at end of file 206} \ No newline at end of file