TextDiff
📄
Hello World This is a test Same line here Removed line Keep this one
📄
Hello World This is a modified test Same line here Added new line Keep this one
总行数:
0
新增:
0
删除:
0
修改:
0
变化:
0%
(function(){ // rebuild translateAll to handle data-i18n-label (text-only replacement) and data-i18n (full replacement) var lt = window.langData, cl = window.currentLang; function t(k){ return lt[cl][k] || k; } document.querySelectorAll('[data-i18n-label]').forEach(function(el){ var key = el.getAttribute('data-i18n-label'); if(key && lt[cl][key] && el.firstChild && el.firstChild.nodeType===3){ el.firstChild.nodeValue = t(key); } }); document.querySelectorAll('[data-i18n]').forEach(function(el){ var key = el.getAttribute('data-i18n'); if(key && lt[cl][key]) el.innerHTML = t(key); }); document.querySelectorAll('[data-i18n-placeholder]').forEach(function(el){ var key = el.getAttribute('data-i18n-placeholder'); if(key) el.placeholder = t(key); }); document.title = 'TextDiff' + (currentLang === 'zh' ? ' · 文本对比工具 — 在线代码差异比较' : ' · Text Comparison Tool - Online Code Diff'); // language selector UI var header = document.querySelector('.header'); if(header && !header.querySelector('.lang-selector')){ var div = document.createElement('div'); div.className = 'lang-selector'; ['zh','en'].forEach(function(l){ var btn = document.createElement('button'); btn.className = 'lang-btn' + (l===currentLang?' active':''); btn.dataset.lang = l; btn.textContent = l==='zh'?'中文':'English'; btn.addEventListener('click',function(){ setLang(l); }); div.appendChild(btn); }); header.insertBefore(div, header.firstChild); } function setLang(l){ window.currentLang = l; localStorage.setItem('textdiff_lang', l); // re-run translation (simple re-run the above) document.querySelectorAll('[data-i18n-label]').forEach(function(el){ var key = el.getAttribute('data-i18n-label'); if(key && lt[cl][key] && el.firstChild && el.firstChild.nodeType===3) el.firstChild.nodeValue = t(key); }); document.querySelectorAll('[data-i18n]').forEach(function(el){ var key = el.getAttribute('data-i18n'); if(key && lt[cl][key]) el.innerHTML = t(key); }); document.querySelectorAll('[data-i18n-placeholder]').forEach(function(el){ var key = el.getAttribute('data-i18n-placeholder'); if(key) el.placeholder = t(key); }); document.title = 'TextDiff' + (l==='zh'?' · 文本对比工具 — 在线代码差异比较':' · Text Comparison Tool - Online Code Diff'); document.querySelectorAll('.lang-btn').forEach(function(b){ b.classList.toggle('active', b.dataset.lang===l); }); } window.setLang = setLang; // global error handling window.addEventListener('error', function(e){ console.error('GLOBAL ERROR:', e.error); }); window.addEventListener('unhandledrejection', function(e){ console.error('UNHANDLED REJECTION:', e.reason); }); })();