From 959527bb712fcd05351d8b4b52ff17786baad454 Mon Sep 17 00:00:00 2001 From: polo Date: Sun, 26 Oct 2025 22:48:49 +0100 Subject: =?UTF-8?q?modification=20du=20nom=20et=20plus=20seulement=20de=20?= =?UTF-8?q?l'URL=20des=20entr=C3=A9es=20"URL"=20du=20menu,=20header/footer?= =?UTF-8?q?:=20renommage=20de=20classes=20et=20input=20absents=20du=20HTML?= =?UTF-8?q?=20sans=20=C3=AAtre=20admin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/InputFile.js | 62 -------------------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 public/js/InputFile.js (limited to 'public/js/InputFile.js') diff --git a/public/js/InputFile.js b/public/js/InputFile.js deleted file mode 100644 index e676037..0000000 --- a/public/js/InputFile.js +++ /dev/null @@ -1,62 +0,0 @@ -// étendre une classe parente avec InputFile? -class InputFile{ - constructor(name){ - this.name = name; - this.parent = document.getElementById(name); - } - open(){ - this.parent.querySelector('#' + this.name + '_img').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'); - } - close(){ - this.parent.querySelector('#' + this.name + '_img').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'); - } - submit(){ - const file = this.parent.querySelector('#' + this.name + '_input').files[0]; - if(!file){ - console.error("Erreur: aucun fichier sélectionné."); - return; - } - const form_data = new FormData(); - form_data.append('file', file); - - fetch('index.php?head_foot_image=' + this.name, { - method: 'POST', // apparemment il faudrait utiliser PUT - body: form_data - }) - .then(response => response.json()) - .then(data => { - if(data.success){ - this.parent.querySelector('#' + this.name + '_img').src = data.location; - - // cas particulier - if(this.name === 'head_favicon'){ - const link = document.querySelector('link[rel="icon"]'); - link.type = data.mime_type; - link.href = data.location; - } - else if(this.name === 'header_background'){ - document.querySelector('header').style.backgroundImage = "url('" + data.location + "')"; - } - - this.close(); - } - else{ - console.error("Erreur: le serveur n'a pas enregistré l'image'."); - } - }) - .catch(error => { - console.error('Erreur:', error); - }); - } - cancel(){ - this.close(); - } -} \ No newline at end of file -- cgit v1.2.3