const historyContainer = document.getElementById('history-container');
let history = [];
function renderHistory() {
if (!historyContainer) return;
if (history.length === 0) {
historyContainer.innerHTML = '';
return;
}
historyContainer.innerHTML =
'
' +
'
History
' +
'
' +
history
.map(function (row) {
const preview =
row.sourceText.length > 80 ? row.sourceText.slice(0, 80) + '\u2026' : row.sourceText;
return (
'- ' +
'' + preview + '' +
'' + row.language + ': ' + row.translation + '' +
'
'
);
})
.join('') +
'
';
}
async function loadHistory() {
try {
const res = await fetch('/api/history');
if (res.ok) {
history = await res.json();
renderHistory();
}
} catch (e) {}
}