From b80bb11831dee07df4c78bebc4c41d4e7ed1868e Mon Sep 17 00:00:00 2001 From: Kavalar Date: Thu, 19 Nov 2026 13:20:08 +0300 Subject: [PATCH] =?UTF-8?q?Standalone=20index.html:=20=D0=B8=D1=81=D0=BF?= =?UTF-8?q?=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=20=D0=BF=D0=BE=D0=BA=D0=B0?= =?UTF-8?q?=D0=B7=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B8=20=D0=A1=D0=BA?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20(?= =?UTF-8?q?=D1=80=D0=B0=D0=BD=D0=BD=D0=B8=D0=B9=20=D0=B4=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D1=83=D0=BF=20=D0=BA=20=D0=B7=D0=B0=D0=BA=D0=BE=D0=BC=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=BD?= =?UTF-8?q?=D0=BE=D0=BC=D1=83=20=D0=B1=D0=BB=D0=BE=D0=BA=D1=83=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B8);=20=D1=83=D0=B1?= =?UTF-8?q?=D1=80=D0=B0=D0=BD=D0=B0=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=B2=D0=B8=D0=B4=D0=B5=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/index.html | 90 ++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/templates/index.html b/templates/index.html index 3c8e710..2aa809e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -495,39 +495,45 @@ let selectedFile = null; - uploadArea.addEventListener('click', () => fileInput.click()); - uploadArea.addEventListener('dragover', (e) => { - e.preventDefault(); - uploadArea.classList.add('dragover'); - }); - uploadArea.addEventListener('dragleave', () => uploadArea.classList.remove('dragover')); - uploadArea.addEventListener('drop', (e) => { - e.preventDefault(); - uploadArea.classList.remove('dragover'); - if (e.dataTransfer.files.length > 0) { - handleFile(e.dataTransfer.files[0]); - } - }); - fileInput.addEventListener('change', (e) => { - if (e.target.files.length > 0) handleFile(e.target.files[0]); - }); + // Блок загрузки может быть закомментирован (осталось только сканирование с камеры), + // поэтому не обращаемся к его элементам, если их нет. + const hasUpload = !!(uploadArea && fileInput && analyzeBtn); - function handleFile(file) { - selectedFile = file; - uploadArea.querySelector('p strong').textContent = `📁 ${file.name} (${(file.size/1024/1024).toFixed(1)} МБ)`; - uploadArea.querySelector('.hint').textContent = 'Готово к анализу'; - analyzeBtn.disabled = false; + if (hasUpload) { + uploadArea.addEventListener('click', () => fileInput.click()); + uploadArea.addEventListener('dragover', (e) => { + e.preventDefault(); + uploadArea.classList.add('dragover'); + }); + uploadArea.addEventListener('dragleave', () => uploadArea.classList.remove('dragover')); + uploadArea.addEventListener('drop', (e) => { + e.preventDefault(); + uploadArea.classList.remove('dragover'); + if (e.dataTransfer.files.length > 0) { + handleFile(e.dataTransfer.files[0]); + } + }); + fileInput.addEventListener('change', (e) => { + if (e.target.files.length > 0) handleFile(e.target.files[0]); + }); + + function handleFile(file) { + selectedFile = file; + uploadArea.querySelector('p strong').textContent = `📁 ${file.name} (${(file.size/1024/1024).toFixed(1)} МБ)`; + uploadArea.querySelector('.hint').textContent = 'Готово к анализу'; + analyzeBtn.disabled = false; + } + + analyzeBtn.addEventListener('click', () => { + if (!selectedFile) return; + sendVideo(selectedFile, selectedFile.name); + }); } - analyzeBtn.addEventListener('click', () => { - if (!selectedFile) return; - sendVideo(selectedFile, selectedFile.name); - }); - async function sendVideo(blob, filename) { - analyzeBtn.disabled = true; - progressContainer.style.display = 'block'; - resultCard.style.display = 'none'; + if (analyzeBtn) analyzeBtn.disabled = true; + if (progressContainer) progressContainer.style.display = 'block'; + if (resultCard) resultCard.style.display = 'none'; setProgress(5, 'Загрузка видео...'); // Безопасный разбор ответа: если сервер вернул не JSON (например, @@ -571,7 +577,7 @@ setProgress(100, 'Готово!'); document.getElementById('scanLoader').classList.remove('open'); setTimeout(() => { - progressContainer.style.display = 'none'; + if (progressContainer) progressContainer.style.display = 'none'; renderResult(data); }, 300); return; @@ -593,27 +599,22 @@ } function setProgress(pct, text) { - progressFill.style.width = pct + '%'; - progressText.textContent = text; + if (progressFill) progressFill.style.width = pct + '%'; + if (progressText) progressText.textContent = text; } function showError(msg, videoUrl) { document.getElementById('scanLoader').classList.remove('open'); - progressContainer.style.display = 'none'; - resultCard.style.display = 'block'; + if (progressContainer) progressContainer.style.display = 'none'; + if (resultCard) resultCard.style.display = 'block'; let html = `
Ошибка: ${msg}
`; - if (videoUrl) { - html += `
- 🎬 Скачать записанное видео -
`; - } - resultContent.innerHTML = html; - analyzeBtn.disabled = false; + if (resultContent) resultContent.innerHTML = html; + if (analyzeBtn) analyzeBtn.disabled = false; } function renderResult(data) { document.getElementById('scanLoader').classList.remove('open'); - resultCard.style.display = 'block'; + if (resultCard) resultCard.style.display = 'block'; let html = ''; @@ -623,7 +624,6 @@
📄 Скачать PDF 📝 Скачать DOCX - ${data.video_url ? `🎬 Скачать видео` : ''} 🏥 Запись на диспанцеризацию
`; } @@ -673,8 +673,8 @@ `; } - resultContent.innerHTML = html; - resultCard.scrollIntoView({ behavior: 'smooth' }); + if (resultContent) resultContent.innerHTML = html; + if (resultCard) resultCard.scrollIntoView({ behavior: 'smooth' }); } function shareResult(url, btn) {