diff options
| author | polo <ordipolo@gmx.fr> | 2025-09-10 01:02:36 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2025-09-10 01:02:36 +0200 |
| commit | efd79d15adef2a27347c25ebb19754e9937f9715 (patch) | |
| tree | 6114ec988ef4dfd7cdf2e2ca07cc9762f8fec4c3 /public | |
| parent | 5e41bea598ff38b3c520b69fd92ee3412e716df2 (diff) | |
| download | cms-efd79d15adef2a27347c25ebb19754e9937f9715.tar.gz cms-efd79d15adef2a27347c25ebb19754e9937f9715.tar.bz2 cms-efd79d15adef2a27347c25ebb19754e9937f9715.zip | |
modification d'une URL page Menu et chemin, htmlspecialchars sur les URL du menu à l'affichage
Diffstat (limited to 'public')
| -rw-r--r-- | public/assets/save-nb.svg | 1 | ||||
| -rw-r--r-- | public/assets/save.svg | 37 | ||||
| -rw-r--r-- | public/css/menu.css | 11 | ||||
| -rw-r--r-- | public/js/menu.js | 94 |
4 files changed, 132 insertions, 11 deletions
diff --git a/public/assets/save-nb.svg b/public/assets/save-nb.svg new file mode 100644 index 0000000..f7fe755 --- /dev/null +++ b/public/assets/save-nb.svg | |||
| @@ -0,0 +1 @@ | |||
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M7 19V13H17V19H19V7.82843L16.1716 5H5V19H7ZM4 3H17L21 7V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM9 15V19H15V15H9Z"></path></svg> \ No newline at end of file | |||
diff --git a/public/assets/save.svg b/public/assets/save.svg new file mode 100644 index 0000000..f2405a5 --- /dev/null +++ b/public/assets/save.svg | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
| 2 | <svg | ||
| 3 | viewBox="0 0 24 24" | ||
| 4 | fill="currentColor" | ||
| 5 | version="1.1" | ||
| 6 | id="svg1" | ||
| 7 | sodipodi:docname="save.svg" | ||
| 8 | inkscape:version="1.4.2 (ebf0e940d0, 2025-05-08)" | ||
| 9 | xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" | ||
| 10 | xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" | ||
| 11 | xmlns="http://www.w3.org/2000/svg" | ||
| 12 | xmlns:svg="http://www.w3.org/2000/svg"> | ||
| 13 | <defs | ||
| 14 | id="defs1" /> | ||
| 15 | <sodipodi:namedview | ||
| 16 | id="namedview1" | ||
| 17 | pagecolor="#ffffff" | ||
| 18 | bordercolor="#000000" | ||
| 19 | borderopacity="0.25" | ||
| 20 | inkscape:showpageshadow="2" | ||
| 21 | inkscape:pageopacity="0.0" | ||
| 22 | inkscape:pagecheckerboard="0" | ||
| 23 | inkscape:deskcolor="#d1d1d1" | ||
| 24 | inkscape:zoom="5.5" | ||
| 25 | inkscape:cx="16.090909" | ||
| 26 | inkscape:cy="19.545455" | ||
| 27 | inkscape:window-width="1330" | ||
| 28 | inkscape:window-height="1032" | ||
| 29 | inkscape:window-x="586" | ||
| 30 | inkscape:window-y="0" | ||
| 31 | inkscape:window-maximized="1" | ||
| 32 | inkscape:current-layer="svg1" /> | ||
| 33 | <path | ||
| 34 | style="fill:#dd3333;stroke:#dd3333;stroke-width:0.687187" | ||
| 35 | d="M 3.7700827,20.814384 C 3.5436283,20.721841 3.2752699,20.427615 3.1737307,20.160547 3.0560503,19.851024 3.007568,16.786203 3.0400116,11.70747 3.0870587,4.3427109 3.1154561,3.7154214 3.415392,3.4154406 3.712924,3.1178639 4.2867777,3.0867003 10.324483,3.0402361 l 6.584608,-0.050673 2.052117,2.0601995 2.052117,2.0601994 -0.05212,6.575086 c -0.04777,6.027435 -0.07915,6.602112 -0.37665,6.899564 -0.300533,0.300481 -0.91908,0.327199 -8.363636,0.361255 C 7.6163,20.966927 4.0059136,20.910757 3.7700807,20.814384 Z M 7,16 v -3 h 5 5 v 3 3 h 1 1 V 13.322457 7.6449149 L 17.686369,6.3224575 16.372737,5 H 10.686369 5 v 7 7 h 1 1 z m 8,1 V 15 H 12 9 v 2 2 h 3 3 z" | ||
| 36 | id="path2" /> | ||
| 37 | </svg> | ||
diff --git a/public/css/menu.css b/public/css/menu.css index 62e6623..57d842a 100644 --- a/public/css/menu.css +++ b/public/css/menu.css | |||
| @@ -70,7 +70,7 @@ | |||
| 70 | vertical-align: middle; | 70 | vertical-align: middle; |
| 71 | border: 2px transparent solid; | 71 | border: 2px transparent solid; |
| 72 | } | 72 | } |
| 73 | .menu #location:hover, .menu input[type=submit]:hover, .move_entry_icon:hover | 73 | .menu #location:hover, .menu input[type=submit]:hover, .menu .move_entry_icon:hover |
| 74 | { | 74 | { |
| 75 | background-color: yellow; | 75 | background-color: yellow; |
| 76 | border-radius: 4px; | 76 | border-radius: 4px; |
| @@ -106,8 +106,17 @@ | |||
| 106 | { | 106 | { |
| 107 | margin: 5px; | 107 | margin: 5px; |
| 108 | display: flex; | 108 | display: flex; |
| 109 | flex-wrap: wrap; | ||
| 109 | align-items: center; | 110 | align-items: center; |
| 110 | } | 111 | } |
| 112 | .menu .url | ||
| 113 | { | ||
| 114 | text-wrap: nowrap; | ||
| 115 | } | ||
| 116 | .menu .url input[type=url] | ||
| 117 | { | ||
| 118 | width: 50%; | ||
| 119 | } | ||
| 111 | 120 | ||
| 112 | @media screen and (min-width: 80rem) { | 121 | @media screen and (min-width: 80rem) { |
| 113 | i{} | 122 | i{} |
diff --git a/public/js/menu.js b/public/js/menu.js index 8f1f326..ef58c42 100644 --- a/public/js/menu.js +++ b/public/js/menu.js | |||
| @@ -122,7 +122,7 @@ 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=displayInMenu', { | 125 | fetch('index.php?menu_edit=display_in_menu', { |
| 126 | method: 'POST', | 126 | method: 'POST', |
| 127 | headers: { | 127 | headers: { |
| 128 | 'Content-Type': 'application/json' | 128 | 'Content-Type': 'application/json' |
| @@ -131,16 +131,14 @@ function checkMenuEntry(page_id){ | |||
| 131 | }) | 131 | }) |
| 132 | .then(response => response.json()) | 132 | .then(response => response.json()) |
| 133 | .then(data => { | 133 | .then(data => { |
| 134 | if(data.success) | 134 | if(data.success){ |
| 135 | { | ||
| 136 | color = checkbox.checked ? "#ff1d04" : "grey"; | 135 | color = checkbox.checked ? "#ff1d04" : "grey"; |
| 137 | clicked_menu_entry.querySelector("button").style.color = color; | 136 | clicked_menu_entry.querySelector("button").style.color = color; |
| 138 | 137 | ||
| 139 | nav_zone.innerHTML = ''; | 138 | nav_zone.innerHTML = ''; |
| 140 | nav_zone.insertAdjacentHTML('afterbegin', data.nav); | 139 | nav_zone.insertAdjacentHTML('afterbegin', data.nav); |
| 141 | } | 140 | } |
| 142 | else { | 141 | else{ |
| 143 | |||
| 144 | console.error('Échec de l\'inversion'); | 142 | console.error('Échec de l\'inversion'); |
| 145 | } | 143 | } |
| 146 | }) | 144 | }) |
| @@ -149,13 +147,89 @@ function checkMenuEntry(page_id){ | |||
| 149 | }); | 147 | }); |
| 150 | } | 148 | } |
| 151 | 149 | ||
| 152 | 150 | // seul la modification des URL est possible pour l'instant, les noms des entrées de menu attendront | |
| 153 | function editUrlEntry(page_id){ | 151 | function editUrlEntry(page_id){ |
| 154 | const selected_div = document.getElementById(page_id); | 152 | const parent_div = document.getElementById(page_id); |
| 155 | console.log(selected_div.id); | 153 | const url_input = parent_div.querySelector('.url').querySelector('input').value; |
| 154 | |||
| 155 | fetch('index.php?menu_edit=edit_url_entry', { | ||
| 156 | method: 'POST', | ||
| 157 | headers: { | ||
| 158 | 'Content-Type': 'application/json' | ||
| 159 | }, | ||
| 160 | body: JSON.stringify({ id: page_id, url_input: url_input }) | ||
| 161 | }) | ||
| 162 | .then(response => response.json()) | ||
| 163 | .then(data => { | ||
| 164 | if(data.success){ | ||
| 165 | findParentByTagName(document.getElementById('m_' + page_id), 'a').href = data.url_input; // MAJ menu | ||
| 166 | toastNotify("Nouvelle adresse enregistrée avec succès") | ||
| 167 | } | ||
| 168 | else{ | ||
| 169 | toastNotify("Erreur rencontrée par le serveur, changements non pris en compte"); | ||
| 170 | console.error("Erreur rencontrée par le serveur, changements non pris en compte"); | ||
| 171 | } | ||
| 172 | }) | ||
| 173 | .catch(error => { | ||
| 174 | console.error('Erreur:', error); | ||
| 175 | }); | ||
| 156 | } | 176 | } |
| 157 | 177 | ||
| 158 | function deleteUrlEntry(page_id){ | 178 | |
| 179 | |||
| 180 | // code à recycler pour pouvoir modifier le nom de l'entrée de menu correspondant aux liens | ||
| 181 | /*function editUrlEntry(page_id){ | ||
| 182 | const parent_div = document.getElementById(page_id); | ||
| 183 | parent_div.querySelector('i').classList.add('hidden'); | ||
| 184 | parent_div.querySelector('.url').querySelector('input').classList.remove('hidden'); | ||
| 185 | parent_div.querySelector('#edit-i' + page_id).classList.add('hidden'); | ||
| 186 | parent_div.querySelector('#delete-i' + page_id).querySelector('input[type=image]').classList.add('hidden'); | ||
| 187 | parent_div.querySelector('#cancel-i' + page_id).querySelector('button').classList.remove('hidden'); | ||
| 188 | parent_div.querySelector('#submit-i' + page_id).querySelector('input[type=submit]').classList.remove('hidden'); | ||
| 189 | } | ||
| 190 | function cancelUrlEntry(page_id){ | ||
| 191 | const parent_div = document.getElementById(page_id); | ||
| 192 | parent_div.querySelector('.url').querySelector('input').value = parent_div.querySelector('i').textContent; // textContent (contrairement à innerHTML) ne transforme pas les & en entités HTML | ||
| 193 | closeUrlEntry(page_id, parent_div); | ||
| 194 | } | ||
| 195 | function submitUrlEntry(page_id){ | ||
| 196 | const parent_div = document.getElementById(page_id); | ||
| 197 | const url_input = parent_div.querySelector('.url').querySelector('input').value; | ||
| 198 | |||
| 199 | fetch('index.php?menu_edit=edit_url_entry', { | ||
| 200 | method: 'POST', | ||
| 201 | headers: { | ||
| 202 | 'Content-Type': 'application/json' | ||
| 203 | }, | ||
| 204 | body: JSON.stringify({ id: page_id, url_input: url_input }) | ||
| 205 | }) | ||
| 206 | .then(response => response.json()) | ||
| 207 | .then(data => { | ||
| 208 | if(data.success){ | ||
| 209 | parent_div.querySelector('i').innerHTML = data.url_input; // MAJ <i> | ||
| 210 | findParentByTagName(document.getElementById('m_' + page_id), 'a').href = data.url_input; // MAJ menu | ||
| 211 | closeUrlEntry(page_id, parent_div); | ||
| 212 | } | ||
| 213 | else{ | ||
| 214 | toastNotify("Erreur rencontrée par le serveur, changements non pris en compte"); | ||
| 215 | console.error("Erreur rencontrée par le serveur, changements non pris en compte"); | ||
| 216 | } | ||
| 217 | }) | ||
| 218 | .catch(error => { | ||
| 219 | console.error('Erreur:', error); | ||
| 220 | }); | ||
| 221 | } | ||
| 222 | function closeUrlEntry(page_id, parent_div){ | ||
| 223 | parent_div.querySelector('i').classList.remove('hidden'); | ||
| 224 | parent_div.querySelector('.url').querySelector('input').classList.add('hidden'); | ||
| 225 | parent_div.querySelector('#edit-i' + page_id).classList.remove('hidden'); | ||
| 226 | parent_div.querySelector('#delete-i' + page_id).querySelector('input[type=image]').classList.remove('hidden'); | ||
| 227 | parent_div.querySelector('#cancel-i' + page_id).querySelector('button').classList.add('hidden'); | ||
| 228 | parent_div.querySelector('#submit-i' + page_id).querySelector('input[type=submit]').classList.add('hidden'); | ||
| 229 | }*/ | ||
| 230 | |||
| 231 | /*function deleteUrlEntry(page_id){ | ||
| 159 | const selected_div = document.getElementById(page_id); | 232 | const selected_div = document.getElementById(page_id); |
| 160 | console.log(selected_div.id); | 233 | console.log(selected_div.id); |
| 161 | } \ No newline at end of file | 234 | }*/ |
| 235 | |||
