From 5e8f23877de21871c983b2b520128ed5f758c288 Mon Sep 17 00:00:00 2001 From: Lycano Date: Fri, 3 Apr 2026 14:29:26 +0200 Subject: [PATCH] JS --- listeIngr.js | 46 ++++++++++++++++++++++++++++++-------- listeIngr.php | 2 +- listeTag.js | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ listeTag.php | 48 ++++++++++++++++++++++++++++++++++++++- main.css | 30 +++++++++++++++++++++++++ 5 files changed, 177 insertions(+), 11 deletions(-) create mode 100644 listeTag.js diff --git a/listeIngr.js b/listeIngr.js index 32aa61c..dcacfe7 100644 --- a/listeIngr.js +++ b/listeIngr.js @@ -1,12 +1,4 @@ document.addEventListener("DOMContentLoaded", function(){ - - function modifier_button_ingr(element){ - - let modif = element.parentElement.previousSibling.previousSibling; - //modif.style.color = "red"; - console.log("click") - } - let modifier_button = document.getElementsByClassName("ingr-modifier"); @@ -14,7 +6,43 @@ document.addEventListener("DOMContentLoaded", function(){ console.log(modifier_button); for (const element of modifier_button) { - element.addEventListener('click', modifier_button_ingr(element)); + element.addEventListener('click', function () { + let modif = element.parentElement.previousSibling.previousSibling; + + let data = element.getAttribute("data-id"); + + let form = document.createElement("form"); + + form.setAttribute("method", "POST"); + form.setAttribute("action", "/ingredient/edit/" + data); + form.setAttribute("class","liste-ingr-elem-text") + + let input = document.createElement("input"); + + input.setAttribute("type", "text"); + input.setAttribute("class", "form-control"); + input.setAttribute("name","modif_ingr"); + input.setAttribute("placeholder", "modificiation"); + + let hidden = document.createElement("input"); + + hidden.setAttribute("type","hidden"); + hidden.setAttribute("name","id"); + hidden.setAttribute("value", data); + + let button = document.createElement("button"); + + button.setAttribute("type", "submit"); + button.setAttribute("class", "btn btn-primary"); + button.innerText = "Submit Modification"; + + form.append(input) + form.append(hidden) + form.append(button) + + modif.replaceWith(form); + + }); }; }); \ No newline at end of file diff --git a/listeIngr.php b/listeIngr.php index c4ed815..0a99d1f 100644 --- a/listeIngr.php +++ b/listeIngr.php @@ -18,7 +18,7 @@ Un Element
- Modifier + Modifier Supprimer
diff --git a/listeTag.js b/listeTag.js new file mode 100644 index 0000000..965d874 --- /dev/null +++ b/listeTag.js @@ -0,0 +1,62 @@ +document.addEventListener("DOMContentLoaded", function(){ + + + let modifier_button = document.getElementsByClassName("tag-modifier"); + + console.log(modifier_button); + + for (const element of modifier_button) { + element.addEventListener('click', function () { + let modif = element.parentElement.previousSibling.previousSibling; + + let data = element.getAttribute("data-id"); + + let form = document.createElement("form"); + + form.setAttribute("method", "POST"); + form.setAttribute("action", "/tag/edit/" + data); + form.setAttribute("class","liste-tag-elem-text") + + let input = document.createElement("input"); + + input.setAttribute("type", "text"); + input.setAttribute("class", "form-control"); + input.setAttribute("name","modif_tag"); + input.setAttribute("placeholder", "modificiation"); + + let hidden = document.createElement("input"); + + hidden.setAttribute("type","hidden"); + hidden.setAttribute("name","id"); + hidden.setAttribute("value", data); + + let button = document.createElement("button"); + + button.setAttribute("type", "submit"); + button.setAttribute("class", "btn btn-primary"); + button.innerText = "Submit Modification"; + + form.append(input) + form.append(hidden) + form.append(button) + + modif.replaceWith(form); + + }); + }; + + let suppr = document.getElementsByClassName("tag-suppr"); + + for (const element of suppr) { + element.addEventListener('click', function () { + let confirm = window.confirm("Voulez vous supprimez ?"); + + let data = element.getAttribute("data-id"); + + if (confirm) { + window.location.href = "/tag/delete/" + data; + } + }) + } + +}); \ No newline at end of file diff --git a/listeTag.php b/listeTag.php index c833bae..e971804 100644 --- a/listeTag.php +++ b/listeTag.php @@ -12,10 +12,56 @@
- +
+
+ Un Element +
+ +
+
+ +
+ Un Element +
+
+
+ +
+ Un Element +
+
+
+ +
+ Un Element +
+
+
+ +
+ Un Element +
+
+
+ +
+ Un Element +
+
+
+ +
+ Un Element +
+
+
+ \ No newline at end of file diff --git a/main.css b/main.css index 4db2727..48e314b 100644 --- a/main.css +++ b/main.css @@ -515,6 +515,36 @@ ul { padding-right: 20px; } +.liste-tag-elem { + display: flex; + height: 40px; + padding:5px; + background-color: #c6fdefe0; + color: #000000; + border: 1px solid black; + border-radius: 10px; + box-shadow: 1px 1px 1px black; +} + +.liste-tag-elem:hover { + border:3px solid #007054; + box-shadow: 2px 2px 10px black; +} + +.liste-tag-elem-text { + width: 100%; + height: 100%; + flex:12; + padding-left: 20px; + line-height: 40px; + color: #000000; +} + +.liste-tag-elem-modif { + line-height: 40px; + padding-right: 20px; +} + .ingr-image { flex: 1; border: 1px solid black;