// ═══════════════════════════════════════════════════════ // Diff Checker // ═══════════════════════════════════════════════════════ function computeDiff() { const a = document.getElementById('diffA').value.split('\n'); const b = document.getElementById('diffB').value.split('\n'); const max = Math.max(a.length, b.length); let html = ''; for (let i = 0; i < max; i++) { const la = a[i] !== undefined ? a[i] : null; const lb = b[i] !== undefined ? b[i] : null; const esc = s => s.replace(/[<>&]/g, c => ({'<':'<','>':'>','&':'&'}[c])); if (la === null) html += `
+ ${esc(lb)}
`; else if (lb === null) html += `
- ${esc(la)}
`; else if (la === lb) html += `
${esc(la)}
`; else { html += `
- ${esc(la)}
`; html += `
+ ${esc(lb)}
`; } } document.getElementById('diffOutput').innerHTML = html || 'Texts are identical.'; }