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) {
btn.addEventListener('click', function() {
if (this.getAttribute('data-done') === '1') return;
var gi = parseInt(this.getAttribute('data-gi'));
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-btn').forEach(function(b) {
b.disabled = false;
b.removeAttribute('data-done');
b.innerHTML = '▶ Сравнить эту группу';
b.style.background = ''; b.style.color = ''; b.style.borderColor = ''; b.style.cursor = '';
document.querySelectorAll('.cmp-done').forEach(function(span) {
// Заменить span обратно на кнопку
var newBtn = document.createElement('button');
newBtn.className = 'btn btn-primary cmp-btn';
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;
@@ -529,13 +536,13 @@ window.runCompareForGroup = async function(gi, btn) {
es.close(); _activeCompareES = null;
statusEl.textContent = '✓ ' + d.total_time_s + 'с';
statusEl.style.color = 'var(--green)';
btn.innerHTML = '✓ Готово (' + d.total_time_s + 'с)';
btn.style.background = 'var(--green)';
btn.style.color = '#fff';
btn.style.borderColor = 'var(--green)';
btn.style.cursor = 'default';
btn.disabled = true;
btn.setAttribute('data-done', '1');
// Заменить кнопку на неактивный span — нельзя перезапустить
var span = document.createElement('span');
span.className = 'cmp-done';
span.setAttribute('data-gi', gi);
span.textContent = '✓ Готово (' + d.total_time_s + 'с)';
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.parentNode.replaceChild(span, btn);
stepDone('stepCompare');
}
else if (d.type === 'error') {