From a32700ab3d9882e7ab91b4989f39e06d65e09170 Mon Sep 17 00:00:00 2001 From: Jules Date: Tue, 5 May 2026 16:07:57 +0200 Subject: [PATCH] fix: affichage extension PJ (shortName), bouton transfert toujours visible Co-Authored-By: Claude Sonnet 4.6 --- web/index.php | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/web/index.php b/web/index.php index 0ffe376..7b979df 100644 --- a/web/index.php +++ b/web/index.php @@ -91,10 +91,14 @@ function showToast(msg, type = 'success') { function buildTransferDropdown(sourceId, currentUsername) { const others = ALL_ACCOUNTS.filter(a => a.username !== currentUsername); - if (!others.length) return ''; + if (!others.length) { + return ``; + } const items = others.map(a => `
  • - ${a.username}${a.display_name ? ' — '+a.display_name+'' : ''} + ${escHtml(a.username)}${a.display_name ? ' — '+escHtml(a.display_name)+'' : ''}
  • ` ).join(''); return `
    @@ -151,11 +155,12 @@ function renderMails(rows) { }); let filesHtml = 'Aucune pièce jointe'; if (r.files_list && r.files_list.length) { - filesHtml = r.files_list.map(f => - f.exists - ? `${escHtml(f.name.substring(0,22))}` - : `${escHtml(f.name.substring(0,22))}` - ).join(''); + filesHtml = r.files_list.map(f => { + const label = shortName(f.name); + return f.exists + ? `${escHtml(label)}` + : `⚠ ${escHtml(label)}`; + }).join(''); } const transferBtn = buildTransferDropdown(r.id, r.username); return ` @@ -181,6 +186,14 @@ function escHtml(s) { return String(s).replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"'); } +function shortName(name) { + const dot = name.lastIndexOf('.'); + const ext = dot >= 0 ? name.substring(dot) : ''; + const base = dot >= 0 ? name.substring(0, dot) : name; + if (name.length <= 24) return name; + return base.substring(0, 14) + '…' + ext; +} + function loadMails() { fetch('/api/mails.php') .then(r => r.json())