diff --git a/blog/articles/list_article/liste_articles.js b/blog/articles/list_article/liste_articles.js deleted file mode 100644 index 8dabe5e..0000000 --- a/blog/articles/list_article/liste_articles.js +++ /dev/null @@ -1,7 +0,0 @@ -function confirmerSuppression(titre) { - const confirmation = confirm(`Êtes-vous sûr de vouloir supprimer l'article "${titre}" ?`); - if (confirmation) { - alert(`L'article "${titre}" a été supprimé.`); - // Ici tu peux rediriger ou supprimer réellement - } -} diff --git a/blog/articles/modifier_article/modifier_article.js b/blog/articles/modifier_article/modifier_article.js deleted file mode 100644 index 1dd1c7e..0000000 --- a/blog/articles/modifier_article/modifier_article.js +++ /dev/null @@ -1,68 +0,0 @@ -const form = document.getElementById('editArticleForm'); -const imgField = document.getElementById('articleImage'); -const titleField = document.getElementById('articleTitle'); -const contentField = document.getElementById('articleContent'); -const categoryField = document.getElementById('articleCategory'); -const publishedField = document.getElementById('articlePublished'); - -const errorEmpty = document.getElementById('errorEmpty'); -const errorImage = document.getElementById('errorImage'); -const errorExists = document.getElementById('errorExists'); -const successMsg = document.getElementById('successMsg'); - -// Simulation BDD pour vérifier doublons -const titresExistants = [ - "article de test", - "nouveautés chiens", - "actualité du mois" -]; - -form.addEventListener('submit', function(e) { - e.preventDefault(); - - const titre = titleField.value.trim().toLowerCase(); - const fichierImage = imgField.files[0]; - - // Reset messages - errorEmpty.classList.add('d-none'); - errorImage.classList.add('d-none'); - errorExists.classList.add('d-none'); - successMsg.classList.add('d-none'); - - //Titre obligatoire - if (titre === "") { - errorEmpty.classList.remove('d-none'); - return; - } - - // Titre déjà existant ? - if (titresExistants.includes(titre)) { - errorExists.classList.remove('d-none'); - return; - } - - //Vérification image - if (fichierImage) { - const validFormats = ['image/jpeg', 'image/png', 'image/gif']; - if (!validFormats.includes(fichierImage.type)) { - errorImage.classList.remove('d-none'); - return; - } - } - - // Succès - successMsg.classList.remove('d-none'); - - console.log("Article modifié :", { - titre, - contenu: contentField.value, - categorie: categoryField.value, - publie: publishedField.checked, - image: fichierImage ? fichierImage.name : "Image inchangée" - }); - - - - -}); - diff --git a/blog/articles/ajouter_article/ajouter_article.html b/blog/html/ajouter_article.html similarity index 82% rename from blog/articles/ajouter_article/ajouter_article.html rename to blog/html/ajouter_article.html index 18e7bf3..75594e1 100644 --- a/blog/articles/ajouter_article/ajouter_article.html +++ b/blog/html/ajouter_article.html @@ -6,6 +6,9 @@ Ajouter un article + + + @@ -17,6 +20,9 @@ max-width: 700px; margin: 40px auto; } + .ck-editor__editable { + min-height: 350px; +} @@ -78,27 +84,39 @@
- +
- Annuler + Annuler
- + diff --git a/blog/categories/ajouter_categorie/ajouter_categorie.html b/blog/html/ajouter_categorie.html similarity index 97% rename from blog/categories/ajouter_categorie/ajouter_categorie.html rename to blog/html/ajouter_categorie.html index ca71275..b288956 100644 --- a/blog/categories/ajouter_categorie/ajouter_categorie.html +++ b/blog/html/ajouter_categorie.html @@ -50,7 +50,7 @@ - + diff --git a/blog/articles/list_article/liste_article.html b/blog/html/liste_article.html similarity index 57% rename from blog/articles/list_article/liste_article.html rename to blog/html/liste_article.html index d45d144..f48d43b 100644 --- a/blog/articles/list_article/liste_article.html +++ b/blog/html/liste_article.html @@ -33,22 +33,32 @@ - - - Mon premier article - Chien - Oui - - Voir - Modifier - - - - + + Mon premier article + Chien + Oui + + Voir + Modifier + + + + + + Mon deuxième article + Chat + Oui + + Voir + Modifier + + + + - + diff --git a/blog/categories/liste_categorie/liste_categorie.html b/blog/html/liste_categorie.html similarity index 91% rename from blog/categories/liste_categorie/liste_categorie.html rename to blog/html/liste_categorie.html index 402532f..85ed338 100644 --- a/blog/categories/liste_categorie/liste_categorie.html +++ b/blog/html/liste_categorie.html @@ -28,7 +28,7 @@
- + Ajouter une catégorie
@@ -48,7 +48,7 @@ - + diff --git a/blog/articles/modifier_article/modifier_article.html b/blog/html/modifier_article.html similarity index 85% rename from blog/articles/modifier_article/modifier_article.html rename to blog/html/modifier_article.html index b4ebdf5..92305c2 100644 --- a/blog/articles/modifier_article/modifier_article.html +++ b/blog/html/modifier_article.html @@ -6,6 +6,7 @@ Modifier un article + @@ -99,7 +103,7 @@
- Annuler + Annuler
@@ -109,37 +113,22 @@ - + - - - - - - - - - - - - - - - - - - - - diff --git a/blog/categories/modifier_categorie/modifier_categorie.html b/blog/html/modifier_categorie.html similarity index 97% rename from blog/categories/modifier_categorie/modifier_categorie.html rename to blog/html/modifier_categorie.html index d27d7d9..bcb8eaa 100644 --- a/blog/categories/modifier_categorie/modifier_categorie.html +++ b/blog/html/modifier_categorie.html @@ -49,6 +49,7 @@ + diff --git a/blog/articles/ajouter_article/ajouter_article.js b/blog/js/ajouter_article.js similarity index 82% rename from blog/articles/ajouter_article/ajouter_article.js rename to blog/js/ajouter_article.js index 8941a8d..181b008 100644 --- a/blog/articles/ajouter_article/ajouter_article.js +++ b/blog/js/ajouter_article.js @@ -1,4 +1,4 @@ -const form = document.getElementById('addArticleForm'); +const form = document.getElementById('ajouterArticleForm'); const imgField = document.getElementById('articleImage'); const titleField = document.getElementById('articleTitle'); const contentField = document.getElementById('articleContent'); @@ -16,7 +16,7 @@ const titreExistants = ['décoration noel', 'coupe de chien']; form.addEventListener('submit', function(e) { e.preventDefault(); - const titre = titleField.value.trim() .toLowerCase(); + const titre = titleField.value.trim().toLowerCase(); const fichierImage = imgField.files[0]; // Reset messages @@ -49,4 +49,11 @@ form.addEventListener('submit', function(e) { // Simuler enregistrement titreExistants.push(titre); + // Succès + successMsg.classList.remove('d-none'); + + // Redirection après 1 seconde + setTimeout(() => { + window.location.href = "../html/liste_article.html"; + }, 1000); }); diff --git a/blog/categories/ajouter_categorie/ajouter_categorie.js b/blog/js/ajouter_categorie.js similarity index 80% rename from blog/categories/ajouter_categorie/ajouter_categorie.js rename to blog/js/ajouter_categorie.js index 3eedbf4..c904fdc 100644 --- a/blog/categories/ajouter_categorie/ajouter_categorie.js +++ b/blog/js/ajouter_categorie.js @@ -32,12 +32,16 @@ form.addEventListener("submit", function (e) { return; } - //Succès - successMessage.classList.remove("d-none"); + // Succès +successMessage.classList.remove("d-none"); +// Ajout d'une nouvelle catégorie +existingCategories.push(nom); - //Ajout d'une nouvelle catégorie en BDD - existingCategories.push(nom); +// Redirection après 1 seconde +setTimeout(() => { + window.location.href = "../html/liste_categorie.html"; +}, 1000); }); \ No newline at end of file diff --git a/blog/js/liste_articles.js b/blog/js/liste_articles.js new file mode 100644 index 0000000..f562797 --- /dev/null +++ b/blog/js/liste_articles.js @@ -0,0 +1,14 @@ + +document.addEventListener("click", function (e) { + const btn = e.target.closest(".delete-btn"); + if (!btn) return; // on a cliqué ailleurs + + // On récupère la ligne de l'article + const row = btn.closest("tr"); + const titre = row.querySelector("td").textContent.trim(); + + if (confirm(`Voulez-vous vraiment supprimer l'article : "${titre}" ?`)) { + row.remove(); // supprime la ligne + alert("Article supprimé !"); + } +}); \ No newline at end of file diff --git a/blog/categories/liste_categorie/liste_categorie.js b/blog/js/liste_categorie.js similarity index 92% rename from blog/categories/liste_categorie/liste_categorie.js rename to blog/js/liste_categorie.js index 3a4d2f8..4f8ef98 100644 --- a/blog/categories/liste_categorie/liste_categorie.js +++ b/blog/js/liste_categorie.js @@ -20,7 +20,7 @@ function afficherCategories() { ${cat.description || "-"} - + Modifier diff --git a/blog/js/modifier_article.js b/blog/js/modifier_article.js new file mode 100644 index 0000000..e87ce17 --- /dev/null +++ b/blog/js/modifier_article.js @@ -0,0 +1,60 @@ +const form = document.getElementById("editArticleForm"); +const imgField = document.getElementById("articleImage"); +const titleField = document.getElementById("articleTitle"); +const contentField = document.getElementById("articleContent"); +const categoryField = document.getElementById("articleCategory"); +const publishedField = document.getElementById("articlePublished"); + +const errorEmpty = document.getElementById("errorEmpty"); +const errorImage = document.getElementById("errorImage"); +const errorExists = document.getElementById("errorExists"); +const successMsg = document.getElementById("successMsg"); + +// Simulation BDD pour vérifier doublons +const titresExistants = [ + "article de test", + "nouveautés chiens", + "actualité du mois", +]; + +form.addEventListener("submit", function (e) { + e.preventDefault(); + + const titre = titleField.value.trim().toLowerCase(); + const fichierImage = imgField.files[0]; + + // Reset messages + errorEmpty.classList.add("d-none"); + errorImage.classList.add("d-none"); + errorExists.classList.add("d-none"); + successMsg.classList.add("d-none"); + + //Titre obligatoire + if (titre === "") { + errorEmpty.classList.remove("d-none"); + return; + } + + // Titre déjà existant ? + if (titresExistants.includes(titre)) { + errorExists.classList.remove("d-none"); + return; + } + + //Vérification image + if (fichierImage) { + const validFormats = ["image/jpeg", "image/png", "image/gif"]; + if (!validFormats.includes(fichierImage.type)) { + errorImage.classList.remove("d-none"); + return; + } + } + + // Succès + successMsg.classList.remove("d-none"); + + // Redirection après succès + setTimeout(() => { + window.location.href = "../html/liste_article.html"; + }, 1500); +}); diff --git a/blog/categories/modifier_categorie/modifier_categorie.js b/blog/js/modifier_categorie.js similarity index 88% rename from blog/categories/modifier_categorie/modifier_categorie.js rename to blog/js/modifier_categorie.js index cd6df7b..7642c4d 100644 --- a/blog/categories/modifier_categorie/modifier_categorie.js +++ b/blog/js/modifier_categorie.js @@ -21,6 +21,6 @@ form.addEventListener("submit", function (e) { // Redirection après succès setTimeout(() => { - window.location.href = "../../../blog/categories/liste_categorie/liste_categorie.html"; + window.location.href = "../html/liste_categorie.html"; }, 1500); }); diff --git a/connexion/mot_de_passe_oublie/mot_de_passe_oublie.html b/connexion/html/mot_de_passe_oublie.html similarity index 83% rename from connexion/mot_de_passe_oublie/mot_de_passe_oublie.html rename to connexion/html/mot_de_passe_oublie.html index 7375a1b..d17c54f 100644 --- a/connexion/mot_de_passe_oublie/mot_de_passe_oublie.html +++ b/connexion/html/mot_de_passe_oublie.html @@ -11,7 +11,7 @@