MCPcopy Create free account
hub / github.com/TheJoWo/Clean-Clode / updateHistoryDisplay

Function updateHistoryDisplay

script.js:362–427  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

360 }
361
362 function updateHistoryDisplay() {
363 const history = getHistory();
364
365 if (history.length === 0) {
366 historyList.innerHTML = '<p class="tui-text tui-color-green">[No history yet - start cleaning some text!]</p>';
367 return;
368 }
369
370 historyList.innerHTML = '';
371
372 history.forEach(item => {
373 const historyItem = document.createElement('div');
374 historyItem.className = 'history-item';
375
376 const header = document.createElement('div');
377 header.className = 'history-item-header';
378
379 const date = document.createElement('span');
380 date.className = 'history-date tui-text';
381 date.textContent = formatDate(item.timestamp);
382
383 const controls = document.createElement('div');
384 controls.className = 'history-item-controls';
385
386 const deleteBtn = createHistoryDeleteButton(item.id);
387 const copyBtn = createHistoryCopyButton(item.cleaned);
388 controls.appendChild(deleteBtn);
389 controls.appendChild(copyBtn);
390
391 header.appendChild(date);
392 header.appendChild(controls);
393
394 const contentContainer = document.createElement('div');
395 contentContainer.className = 'history-item-content-container';
396
397 const lines = item.cleaned.split('\n');
398 const isLong = lines.length > 5;
399 const previewText = isLong
400 ? lines.slice(0, 5).join('\n') + '...'
401 : item.cleaned;
402
403 const previewDiv = document.createElement('div');
404 previewDiv.className = 'history-item-content history-item-preview';
405 previewDiv.textContent = previewText;
406
407 const fullContentDiv = document.createElement('div');
408 fullContentDiv.className = 'history-item-content history-item-full';
409 fullContentDiv.textContent = item.cleaned;
410 fullContentDiv.style.display = isLong ? 'none' : 'block';
411
412 if (isLong) {
413 previewDiv.style.display = 'block';
414
415 makePreviewClickable(previewDiv, fullContentDiv);
416 } else {
417 previewDiv.style.display = 'none';
418 }
419

Callers 5

toggleHistoryFunction · 0.85
saveToHistoryFunction · 0.85
deleteHistoryItemFunction · 0.85
clearHistoryFunction · 0.85
script.jsFile · 0.85

Calls 5

getHistoryFunction · 0.85
formatDateFunction · 0.85
createHistoryCopyButtonFunction · 0.85
makePreviewClickableFunction · 0.85

Tested by

no test coverage detected