From f9a9bf1ae4fac9317fd71f0bcb207544b000e6f1 Mon Sep 17 00:00:00 2001 From: polo Date: Thu, 23 Oct 2025 14:15:01 +0200 Subject: =?UTF-8?q?t=C3=A9l=C3=A9chargement=20d'assets=20dans=20head,=20he?= =?UTF-8?q?ader=20et=20footer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/InputText.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'public/js/InputText.js') diff --git a/public/js/InputText.js b/public/js/InputText.js index ba7e8e4..33dcf8d 100644 --- a/public/js/InputText.js +++ b/public/js/InputText.js @@ -1,27 +1,28 @@ // s'en servir dans menu et chemin +// étendre un classe parente avec InputText? class InputText{ constructor(name){ this.name = name; this.parent = document.getElementById(name); } - openTextInput(){ + open(){ this.parent.querySelector('#' + this.name + '_span').classList.add('hidden'); this.parent.querySelector('#' + this.name + '_input').classList.remove('hidden'); this.parent.querySelector('#' + this.name + '_open').classList.add('hidden'); this.parent.querySelector('#' + this.name + '_submit').classList.remove('hidden'); this.parent.querySelector('#' + this.name + '_cancel').classList.remove('hidden'); } - closeTextInput(){ + close(){ this.parent.querySelector('#' + this.name + '_span').classList.remove('hidden'); this.parent.querySelector('#' + this.name + '_input').classList.add('hidden'); this.parent.querySelector('#' + this.name + '_open').classList.remove('hidden'); this.parent.querySelector('#' + this.name + '_submit').classList.add('hidden'); this.parent.querySelector('#' + this.name + '_cancel').classList.add('hidden'); } - submitTextInput(){ + submit(){ const new_text = this.parent.querySelector('#' + this.name + '_input').value; - fetch('index.php?entire_site_edit=' + this.name, { + fetch('index.php?head_foot_text=' + this.name, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({new_text: new_text}) @@ -30,7 +31,7 @@ class InputText{ .then(data => { if(data.success){ this.parent.querySelector('#' + this.name + '_span').innerHTML = new_text; - this.closeTextInput(this.name); + this.close(this.name); } else{ console.error("Erreur: le serveur n'a pas enregistré le nouveau texte."); @@ -40,8 +41,8 @@ class InputText{ console.error('Erreur:', error); }); } - cancelTextInput(){ + cancel(){ this.parent.querySelector('#' + this.name + '_input').value = this.parent.querySelector('#' + this.name + '_span').innerHTML; - this.closeTextInput(this.name); + this.close(this.name); } } \ No newline at end of file -- cgit v1.2.3