Auto-on live preview when recount starts (all recounting templates)

This commit is contained in:
proitlab committed 2026-08-10 09:53:55 +07:00
1 parent 6043197d72
commit 6be017c4f0
5 files changed
+82 -20

No files matched your search

+20 -5
View File
@@ -782,6 +782,7 @@ async function startRecount() {
document.getElementById('video-status').innerHTML =
'<span style="width:6px;height:6px;border-radius:50%;background:var(--accent4);box-shadow:0 0 6px var(--accent4);animation:blink 1.5s ease-in-out infinite;"></span> streaming ' + data.file;
document.getElementById('video-status').className = 'video-status connected';
enablePreview();
} catch (err) {
alert('Error: ' + err.message);
btnStart.disabled = false;
@@ -845,11 +846,7 @@ function togglePreview() {
btn.textContent = 'STREAM OFF';
btn.classList.remove('active');
} else {
img.src = streamUrl + '?' + Date.now();
img.style.display = 'block';
if (placeholder) placeholder.style.display = 'none';
btn.textContent = 'STREAM ON';
btn.classList.add('active');
enablePreview();
}
}
@@ -864,6 +861,23 @@ function resetVideoToggle() {
btn.classList.remove('active');
}
function enablePreview() {
var btn = document.getElementById('videoToggle');
var img = document.getElementById('stream-img');
var placeholder = document.getElementById('video-placeholder');
if (!streamUrl) return;
img.onerror = function() {
if (streaming && streamUrl) {
img.src = streamUrl + '?' + Date.now();
}
};
img.src = streamUrl + '?' + Date.now();
img.style.display = 'block';
if (placeholder) placeholder.style.display = 'none';
btn.textContent = 'STREAM ON';
btn.classList.add('active');
}
async function syncState() {
try {
var res = await fetch('/api/state');
@@ -888,6 +902,7 @@ function applyState(data) {
document.getElementById('video-status').innerHTML =
'<span style="width:6px;height:6px;border-radius:50%;background:var(--accent4);box-shadow:0 0 6px var(--accent4);animation:blink 1.5s ease-in-out infinite;"></span> streaming ' + (data.file_name || '');
document.getElementById('video-status').className = 'video-status connected';
enablePreview();
loadBatchResult(data.file);
} else if (data.file && selectedFile === data.file) {