aboutsummaryrefslogtreecommitdiff
path: root/public/js/InputText.js
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2025-10-26 22:48:49 +0100
committerpolo <ordipolo@gmx.fr>2025-10-26 22:48:49 +0100
commit959527bb712fcd05351d8b4b52ff17786baad454 (patch)
tree459f66a07e443a971930e5aa3bce257c33079f20 /public/js/InputText.js
parente73ea91a5999dc2cbadc00dfda18c839ef1a158b (diff)
downloadcms-959527bb712fcd05351d8b4b52ff17786baad454.tar.gz
cms-959527bb712fcd05351d8b4b52ff17786baad454.tar.bz2
cms-959527bb712fcd05351d8b4b52ff17786baad454.zip
modification du nom et plus seulement de l'URL des entrées "URL" du menu, header/footer: renommage de classes et input absents du HTML sans être admin
Diffstat (limited to 'public/js/InputText.js')
-rw-r--r--public/js/InputText.js48
1 files changed, 0 insertions, 48 deletions
diff --git a/public/js/InputText.js b/public/js/InputText.js
deleted file mode 100644
index 79f0398..0000000
--- a/public/js/InputText.js
+++ /dev/null
@@ -1,48 +0,0 @@
1// s'en servir dans menu et chemin
2// étendre un classe parente avec InputText?
3class InputText{
4 constructor(name){
5 this.name = name;
6 this.parent = document.getElementById(name);
7 }
8 open(){
9 this.parent.querySelector('#' + this.name + '_span').classList.add('hidden');
10 this.parent.querySelector('#' + this.name + '_input').classList.remove('hidden');
11 this.parent.querySelector('#' + this.name + '_open').classList.add('hidden');
12 this.parent.querySelector('#' + this.name + '_submit').classList.remove('hidden');
13 this.parent.querySelector('#' + this.name + '_cancel').classList.remove('hidden');
14 }
15 close(){
16 this.parent.querySelector('#' + this.name + '_span').classList.remove('hidden');
17 this.parent.querySelector('#' + this.name + '_input').classList.add('hidden');
18 this.parent.querySelector('#' + this.name + '_open').classList.remove('hidden');
19 this.parent.querySelector('#' + this.name + '_submit').classList.add('hidden');
20 this.parent.querySelector('#' + this.name + '_cancel').classList.add('hidden');
21 }
22 submit(){
23 const new_text = this.parent.querySelector('#' + this.name + '_input').value;
24
25 fetch('index.php?head_foot_text=' + this.name, {
26 method: 'POST',
27 headers: { 'Content-Type': 'application/json' },
28 body: JSON.stringify({new_text: new_text})
29 })
30 .then(response => response.json())
31 .then(data => {
32 if(data.success){
33 this.parent.querySelector('#' + this.name + '_span').innerHTML = new_text;
34 this.close();
35 }
36 else{
37 console.error("Erreur: le serveur n'a pas enregistré le nouveau texte.");
38 }
39 })
40 .catch(error => {
41 console.error('Erreur:', error);
42 });
43 }
44 cancel(){
45 this.parent.querySelector('#' + this.name + '_input').value = this.parent.querySelector('#' + this.name + '_span').innerHTML;
46 this.close();
47 }
48} \ No newline at end of file