Standalone index.html: исправлен показ кнопки Сканировать (ранний доступ к закомментированному блоку загрузки); убрана кнопка видео

This commit is contained in:
apuc committed 2026-11-19 13:20:08 +03:00
1 parent 13809d20a5
commit b80bb11831
1 file changed
+19 -19
+19 -19
View File
@@ -495,6 +495,11 @@
let selectedFile = null; let selectedFile = null;
// Блок загрузки может быть закомментирован (осталось только сканирование с камеры),
// поэтому не обращаемся к его элементам, если их нет.
const hasUpload = !!(uploadArea && fileInput && analyzeBtn);
if (hasUpload) {
uploadArea.addEventListener('click', () => fileInput.click()); uploadArea.addEventListener('click', () => fileInput.click());
uploadArea.addEventListener('dragover', (e) => { uploadArea.addEventListener('dragover', (e) => {
e.preventDefault(); e.preventDefault();
@@ -523,11 +528,12 @@
if (!selectedFile) return; if (!selectedFile) return;
sendVideo(selectedFile, selectedFile.name); sendVideo(selectedFile, selectedFile.name);
}); });
}
async function sendVideo(blob, filename) { async function sendVideo(blob, filename) {
analyzeBtn.disabled = true; if (analyzeBtn) analyzeBtn.disabled = true;
progressContainer.style.display = 'block'; if (progressContainer) progressContainer.style.display = 'block';
resultCard.style.display = 'none'; if (resultCard) resultCard.style.display = 'none';
setProgress(5, 'Загрузка видео...'); setProgress(5, 'Загрузка видео...');
// Безопасный разбор ответа: если сервер вернул не JSON (например, // Безопасный разбор ответа: если сервер вернул не JSON (например,
@@ -571,7 +577,7 @@
setProgress(100, 'Готово!'); setProgress(100, 'Готово!');
document.getElementById('scanLoader').classList.remove('open'); document.getElementById('scanLoader').classList.remove('open');
setTimeout(() => { setTimeout(() => {
progressContainer.style.display = 'none'; if (progressContainer) progressContainer.style.display = 'none';
renderResult(data); renderResult(data);
}, 300); }, 300);
return; return;
@@ -593,27 +599,22 @@
} }
function setProgress(pct, text) { function setProgress(pct, text) {
progressFill.style.width = pct + '%'; if (progressFill) progressFill.style.width = pct + '%';
progressText.textContent = text; if (progressText) progressText.textContent = text;
} }
function showError(msg, videoUrl) { function showError(msg, videoUrl) {
document.getElementById('scanLoader').classList.remove('open'); document.getElementById('scanLoader').classList.remove('open');
progressContainer.style.display = 'none'; if (progressContainer) progressContainer.style.display = 'none';
resultCard.style.display = 'block'; if (resultCard) resultCard.style.display = 'block';
let html = `<div class="error-box"><strong>Ошибка:</strong> ${msg}</div>`; let html = `<div class="error-box"><strong>Ошибка:</strong> ${msg}</div>`;
if (videoUrl) { if (resultContent) resultContent.innerHTML = html;
html += `<div style="text-align:center; margin-top:15px"> if (analyzeBtn) analyzeBtn.disabled = false;
<a class="btn-download" href="${videoUrl}">🎬 Скачать записанное видео</a>
</div>`;
}
resultContent.innerHTML = html;
analyzeBtn.disabled = false;
} }
function renderResult(data) { function renderResult(data) {
document.getElementById('scanLoader').classList.remove('open'); document.getElementById('scanLoader').classList.remove('open');
resultCard.style.display = 'block'; if (resultCard) resultCard.style.display = 'block';
let html = ''; let html = '';
@@ -623,7 +624,6 @@
<div class="download-buttons"> <div class="download-buttons">
<a class="btn-download" href="/download/${data.share_id}/pdf">📄 Скачать PDF</a> <a class="btn-download" href="/download/${data.share_id}/pdf">📄 Скачать PDF</a>
<a class="btn-download" href="/download/${data.share_id}/docx">📝 Скачать DOCX</a> <a class="btn-download" href="/download/${data.share_id}/docx">📝 Скачать DOCX</a>
${data.video_url ? `<a class="btn-download" href="${data.video_url}">🎬 Скачать видео</a>` : ''}
<a class="btn-download" href="https://max.ru/miac_dnr_bot" target="_blank" rel="noopener">🏥 Запись на диспанцеризацию</a> <a class="btn-download" href="https://max.ru/miac_dnr_bot" target="_blank" rel="noopener">🏥 Запись на диспанцеризацию</a>
</div>`; </div>`;
} }
@@ -673,8 +673,8 @@
</div>`; </div>`;
} }
resultContent.innerHTML = html; if (resultContent) resultContent.innerHTML = html;
resultCard.scrollIntoView({ behavior: 'smooth' }); if (resultCard) resultCard.scrollIntoView({ behavior: 'smooth' });
} }
function shareResult(url, btn) { function shareResult(url, btn) {