From d997bad179973d46cc6274e0da44760fe0199011 Mon Sep 17 00:00:00 2001 From: treamz Date: Fri, 24 Jul 2026 17:05:57 +0300 Subject: [PATCH] =?UTF-8?q?compress:=20=D1=80=D0=B0=D0=B7=D0=B4=D0=B5?= =?UTF-8?q?=D0=BB=D1=8C=D0=BD=D0=B0=D1=8F=20=D0=B4=D0=B8=D0=B0=D0=B3=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D0=B8=D0=BA=D0=B0=20=D0=BE=D1=82=D1=81=D0=B5?= =?UTF-8?q?=D0=B2=D0=B0=20(=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82=20vs=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B7=D0=BC=D0=B5=D1=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/compress.html | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/public/compress.html b/public/compress.html index 7ec1616..3c58759 100644 --- a/public/compress.html +++ b/public/compress.html @@ -309,18 +309,29 @@ let isAdmin = false; } }).catch(function(){}); })(); +function isValidFormat(f) { + return VALID_TYPES.includes(f.type) || /\.(jpe?g|png|webp|avif|tiff?|gif|bmp|svg|heic|heif)$/i.test(f.name); +} + function handleFiles(files) { const arr = Array.from(files); - const valid = arr.filter(f => (VALID_TYPES.includes(f.type) || /\.(jpe?g|png|webp|avif|tiff?|gif|bmp|svg|heic|heif)$/i.test(f.name)) && f.size <= MAX_SIZE); - const invalid = arr.length - valid.length; + const valid = [], badFormat = [], tooBig = []; + arr.forEach(f => { + if (!isValidFormat(f)) badFormat.push(f); + else if (f.size > MAX_SIZE) tooBig.push(f); + else valid.push(f); + }); + + // Раздельная диагностика: точно видно, что именно отсеяно + const parts = []; + if (badFormat.length) parts.push(badFormat.length + ' — неподдерживаемый формат'); + if (tooBig.length) parts.push(tooBig.length + ' — больше ' + (MAX_SIZE / 1024 / 1024).toFixed(0) + ' МБ'); + if (parts.length) showError('Пропущено: ' + parts.join(', ')); if (!valid.length) { - showError('Нет подходящих файлов. Допустимы JPEG, PNG, WebP, AVIF, TIFF, GIF, BMP, HEIC до 20 МБ.'); + if (!parts.length) showError('Нет файлов. Допустимы JPEG, PNG, WebP, AVIF, TIFF, GIF, BMP, SVG, HEIC.'); return; } - if (invalid > 0) { - showError(invalid + ' файл(ов) пропущено (неверный формат или размер > 20 МБ)'); - } valid.forEach(f => addFileEntry(f)); drainQueue();