const vscode = acquireVsCodeApi(); function send(type, line, ruleId, source) { vscode.postMessage({ type, line, ruleId, source }); } function switchTab(tabId) { document.querySelectorAll('.tab').forEach(function(t) { t.classList.remove('active'); }); document.querySelectorAll('.tab-content').forEach(function(tc) { tc.classList.remove('active'); }); document.querySelector('.tab[data-tab="' + tabId + '"]').classList.add('active'); document.getElementById('tab-' + tabId).classList.add('active'); } function toggleItem(el) { if (event.target.closest('button')) { return; } if (event.target.closest('.item-line')) { return; } el.classList.toggle('expanded'); } window.addEventListener('message', function(e) { const msg = e.data; if (!msg || typeof msg.type !== 'string') { return; } if (msg.type === 'pending') { const key = msg.key; document.querySelectorAll('[data-fix-key="' + key + '"]').forEach(function(btn) { const isConfirm = btn.classList.contains('btn-apply') || btn.classList.contains('btn-cancel'); btn.style.display = msg.on ? (isConfirm ? '' : 'none') : (isConfirm ? 'none' : ''); if (!msg.on && !isConfirm) { btn.disabled = false; if (btn.dataset.label) { btn.textContent = btn.dataset.label; } } }); } else if (msg.type === 'batchPending') { document.querySelectorAll('[data-fix-all-btn]').forEach(function(btn) { const isConfirm = btn.classList.contains('btn-apply-all') || btn.classList.contains('btn-cancel-all'); btn.style.display = msg.on ? (isConfirm ? '' : 'none') : (isConfirm ? 'none' : ''); }); } });