From 5e41bea598ff38b3c520b69fd92ee3412e716df2 Mon Sep 17 00:00:00 2001 From: polo Date: Tue, 9 Sep 2025 15:37:50 +0200 Subject: =?UTF-8?q?fin=20de=20l'utilisation=20du=20champ=20article=5Ftimes?= =?UTF-8?q?tamp=20de=20la=20table=20node,=20r=C3=A9solue=20erreur=20lorsqu?= =?UTF-8?q?e=20deux=20news=20sont=20cr=C3=A9=C3=A9es=20dans=20la=20m=C3=AA?= =?UTF-8?q?me=20minute=20(pas=20dans=20la=20m=C3=AAme=20seconde=20par=20co?= =?UTF-8?q?ntre)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/main.js | 7 +++---- public/js/menu.js | 3 --- public/js/tinymce.js | 8 ++++---- 3 files changed, 7 insertions(+), 11 deletions(-) (limited to 'public/js') diff --git a/public/js/main.js b/public/js/main.js index 8f2b214..2936ea0 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -80,8 +80,9 @@ document.addEventListener('DOMContentLoaded', () => { // pour pouvoir attraper l // complète les fonctions dans tinymce.js function switchPositions(article_id, direction) { - const current_article = findParentByTagName(document.getElementById(article_id), 'article'); // l'id n'est pas sur la bonne balise - var other_article; + const current_article = findParentByTagName(document.getElementById(article_id), 'article'); // l'id n'est pas toujours sur la même balise + let other_article; + let other_article_id; if(direction == 'down'){ other_article = current_article.nextElementSibling; @@ -90,10 +91,8 @@ function switchPositions(article_id, direction) other_article = current_article.previousElementSibling; } - var other_article_id; try{ other_article_id = other_article.querySelector('div[id]').id; - other_article_id = 'i' + other_article_id.slice(1); // peut mieux faire } catch(error){ console.log('Inversion impossible'); diff --git a/public/js/menu.js b/public/js/menu.js index 7f48ac9..8f1f326 100644 --- a/public/js/menu.js +++ b/public/js/menu.js @@ -15,7 +15,6 @@ function moveOneLevelUp(page_id) .then(data => { if(data.success) { - console.log(data); // affichage nav_zone.innerHTML = ''; nav_zone.insertAdjacentHTML('afterbegin', data.nav); @@ -23,7 +22,6 @@ function moveOneLevelUp(page_id) menu_edit_buttons.insertAdjacentHTML('afterbegin', data.menu_buttons); } else { - console.error('Échec du déplacement'); } }) @@ -49,7 +47,6 @@ function moveOneLevelDown(page_id) .then(data => { if(data.success) { - console.log(data); // affichage nav_zone.innerHTML = ''; nav_zone.insertAdjacentHTML('afterbegin', data.nav); diff --git a/public/js/tinymce.js b/public/js/tinymce.js index 1e16f6e..d6b0bf8 100644 --- a/public/js/tinymce.js +++ b/public/js/tinymce.js @@ -55,7 +55,7 @@ function deleteArticle(id){ { // Supprimer l'article du DOM const articleElement = document.getElementById(id); - articleElement.parentElement.parentElement.remove(); //
est deux niveau au dessus + findParentByTagName(articleElement, 'article').remove(); toastNotify("L'article a été supprimé."); } else{ @@ -106,7 +106,7 @@ class Editor init(){ tinymce.init({ - selector: `#${this.id}`, // avec un # comme dans querySelector + selector: `[id="${this.id}"]`, // écrire [id="246"] au lieu de #246 parce que l'id commence par un chiffre language: 'fr_FR', // téléchargement ici: https://www.tiny.cloud/get-tiny/language-packages/ language_url: 'js/tinymce-langs/fr_FR.js', // ou installer tweeb/tinymce-i18n avec composer license_key: 'gpl', @@ -136,7 +136,7 @@ class Editor if(window.Config.page !== 'article'){ document.getElementById(`position_up-${this.id}`).classList.add('hidden'); document.getElementById(`position_down-${this.id}`).classList.add('hidden'); - document.getElementById(`delete-${('i' + this.id.slice(1))}`).classList.add('hidden'); + document.getElementById(`delete-${this.id}`).classList.add('hidden'); } } }); @@ -259,7 +259,7 @@ class Editor } close(restore_old = true){ - tinymce.remove(`#${this.id}`); // avec un # comme dans querySelector + tinymce.remove(`[id="${this.id}"]`); // comme dans tinymce.init delete editors[this.id]; // Restaurer le contenu d'origine de l'article -- cgit v1.2.3