if done then strike out text
- User
if done then strike out text
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
if done then strike out text
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Here’s a clean, working solution to strike out text when a task is marked as "Done", with both initial rendering and dynamic updates:
Add this to your stylesheet:
.done-task {
text-decoration: line-through;
opacity: 0.6; /* Optional: faint the text */
color: #888; /* Optional: change color for better contrast */
}
renderTables() FunctionEnsure the checkbox toggles the .done-task class on the task cell:
function renderTables() {
tablesContainer.innerHTML = '';
tables.forEach(table => {
const tableContainer = document.createElement('div');
tableContainer.className = 'table-container';
// Header
const tableHeader = document.createElement('div');
tableHeader.className = 'table-header';
const tableTitle = document.createElement('h2');
tableTitle.textContent = table.title;
const copyBtn = document.createElement('button');
copyBtn.className = 'copy-btn';
copyBtn.textContent = 'Copy as Markdown';
copyBtn.addEventListener('click', () => copyTableAsMarkdown(table));
tableHeader.appendChild(tableTitle);
tableHeader.appendChild(copyBtn);
tableContainer.appendChild(tableHeader);
// Table
const tableElement = document.createElement('table');
// Table header
const thead = document.createElement('thead');
const headerRow = document.createElement('tr');
table.headers.forEach(header => {
const th = document.createElement('th');
th.textContent = header;
if (header.toLowerCase() === 'done') th.style.width = '60px'; // Compact checkbox column
headerRow.appendChild(th);
});
thead.appendChild(headerRow);
tableElement.appendChild(thead);
// Table body
const tbody = document.createElement('tbody');
table.rows.forEach(row => {
const tr = document.createElement('tr');
const taskCell = document.createElement('td'); // Store reference to task cell
row.forEach((cell, index) => {
const td = document.createElement('td');
if (index === 0) {
// Task column: Apply multiline support
td.style.whiteSpace = 'pre-wrap';
td.style.wordBreak = 'break-word';
td.style.maxWidth = '400px';
td.textContent = cell;
taskCell.appendChild(td); // Store task cell
} else if (index === 1 && (cell === '[x]' || cell === '[ ]')) {
// Done column: Checkbox
const checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.className = 'checkbox';
checkbox.checked = cell === '[x]';
checkbox.style.margin = '0 auto';
checkbox.style.display = 'block';
// Apply strikethrough if already done
if (checkbox.checked) {
taskCell.classList.add('done-task');
}
// Toggle strikethrough on checkbox change
checkbox.addEventListener('change', (e) => {
row[index] = e.target.checked ? '[x]' : '[ ]';
taskCell.classList.toggle('done-task', e.target.checked);
updateTables(); // Save changes
});
td.appendChild(checkbox);
td.style.textAlign = 'center';
} else {
td.textContent = cell;
}
tr.appendChild(td);
});
tbody.appendChild(tr);
});
tableElement.appendChild(tbody);
tableContainer.appendChild(tableElement);
// Add row form
const addRowForm = document.createElement('div');
addRowForm.className = 'add-row';
const taskInput = document.createElement('input');
taskInput.type = 'text';
taskInput.placeholder = 'New task name…';
const addBtn = document.createElement('button');
addBtn.textContent = '+ ADD';
addBtn.addEventListener('click', () => {
const val = taskInput.value.trim();
if (val) {
addRow(table.title, val);
taskInput.value = '';
}
});
addRowForm.appendChild(taskInput);
addRowForm.appendChild(addBtn);
tableContainer.appendChild(addRowForm);
tablesContainer.appendChild(tableContainer);
});
}
Initial Render:
If a task is marked [x], the .done-task class is added to the task cell immediately.
Dynamic Updates:
When the checkbox is toggled, the .done-task class is added/removed from the task cell.
Styling:
The .done-task class applies a strikethrough and optional opacity/color changes for visual feedback.
localStorage or a backend to persist checkbox states.Let me know if you need help integrating this with your existing data structure! 🚀