Standalone index.html: исправлен показ кнопки Сканировать (ранний доступ к закомментированному блоку загрузки); убрана кнопка видео
This commit is contained in:
1 parent
13809d20a5
commit
b80bb11831
1 file changed
+45
-45
+45
-45
@@ -495,39 +495,45 @@
|
|||||||
|
|
||||||
let selectedFile = null;
|
let selectedFile = null;
|
||||||
|
|
||||||
uploadArea.addEventListener('click', () => fileInput.click());
|
// Блок загрузки может быть закомментирован (осталось только сканирование с камеры),
|
||||||
uploadArea.addEventListener('dragover', (e) => {
|
// поэтому не обращаемся к его элементам, если их нет.
|
||||||
e.preventDefault();
|
const hasUpload = !!(uploadArea && fileInput && analyzeBtn);
|
||||||
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) {
|
if (hasUpload) {
|
||||||
selectedFile = file;
|
uploadArea.addEventListener('click', () => fileInput.click());
|
||||||
uploadArea.querySelector('p strong').textContent = `📁 ${file.name} (${(file.size/1024/1024).toFixed(1)} МБ)`;
|
uploadArea.addEventListener('dragover', (e) => {
|
||||||
uploadArea.querySelector('.hint').textContent = 'Готово к анализу';
|
e.preventDefault();
|
||||||
analyzeBtn.disabled = false;
|
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) {
|
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) {
|
||||||
|
|||||||
Reference in new issue
Block a user