v1.0.177: Готово → span, не кнопка — нельзя перезапустить сравнение

This commit is contained in:
2026-06-24 19:47:34 +04:00
parent a58df099b6
commit 7f6d912010
+20 -13
View File
@@ -423,7 +423,6 @@ async function loadGroups() {
// Один обработчик на все кнопки сравнения // Один обработчик на все кнопки сравнения
diffBody.querySelectorAll('.cmp-btn').forEach(function(btn) { diffBody.querySelectorAll('.cmp-btn').forEach(function(btn) {
btn.addEventListener('click', function() { btn.addEventListener('click', function() {
if (this.getAttribute('data-done') === '1') return;
var gi = parseInt(this.getAttribute('data-gi')); var gi = parseInt(this.getAttribute('data-gi'));
runCompareForGroup(gi, this); runCompareForGroup(gi, this);
}); });
@@ -445,11 +444,19 @@ window.runCompareForGroup = async function(gi, btn) {
// Свернуть все раскрытые сравнения // Свернуть все раскрытые сравнения
document.querySelectorAll('.cmp-body').forEach(function(el) { el.style.display = 'none'; }); document.querySelectorAll('.cmp-body').forEach(function(el) { el.style.display = 'none'; });
document.querySelectorAll('.cmp-btn').forEach(function(b) { document.querySelectorAll('.cmp-done').forEach(function(span) {
b.disabled = false; // Заменить span обратно на кнопку
b.removeAttribute('data-done'); var newBtn = document.createElement('button');
b.innerHTML = '▶ Сравнить эту группу'; newBtn.className = 'btn btn-primary cmp-btn';
b.style.background = ''; b.style.color = ''; b.style.borderColor = ''; b.style.cursor = ''; newBtn.setAttribute('data-gi', span.getAttribute('data-gi'));
newBtn.textContent = '▶ Сравнить эту группу';
newBtn.style.cssText = 'margin-top:6px;font-size:12px;height:28px;';
newBtn.addEventListener('click', function() {
if (this.getAttribute('data-done') === '1') return;
var gi = parseInt(this.getAttribute('data-gi'));
runCompareForGroup(gi, this);
});
span.parentNode.replaceChild(newBtn, span);
}); });
btn.disabled = true; btn.disabled = true;
@@ -529,13 +536,13 @@ window.runCompareForGroup = async function(gi, btn) {
es.close(); _activeCompareES = null; es.close(); _activeCompareES = null;
statusEl.textContent = '✓ ' + d.total_time_s + 'с'; statusEl.textContent = '✓ ' + d.total_time_s + 'с';
statusEl.style.color = 'var(--green)'; statusEl.style.color = 'var(--green)';
btn.innerHTML = '✓ Готово (' + d.total_time_s + 'с)'; // Заменить кнопку на неактивный span — нельзя перезапустить
btn.style.background = 'var(--green)'; var span = document.createElement('span');
btn.style.color = '#fff'; span.className = 'cmp-done';
btn.style.borderColor = 'var(--green)'; span.setAttribute('data-gi', gi);
btn.style.cursor = 'default'; span.textContent = '✓ Готово (' + d.total_time_s + 'с)';
btn.disabled = true; span.style.cssText = 'display:inline-block;margin-top:6px;font-size:12px;height:28px;line-height:28px;padding:0 12px;background:var(--green);color:#fff;border-radius:6px;';
btn.setAttribute('data-done', '1'); btn.parentNode.replaceChild(span, btn);
stepDone('stepCompare'); stepDone('stepCompare');
} }
else if (d.type === 'error') { else if (d.type === 'error') {