I dont like how rendered // Render all tables function renderTables() {…
- User
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
I dont like how rendered // Render all tables function renderTables() { tablesContainer.innerHTML = '';
tables.forEach(table => {
const tableContainer = document.createElement('div');
tableContainer.className = 'table-container';
// Table header with title and copy button
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);
// Create table element
const tableElement = document.createElement('table');
// Create table header
const thead = document.createElement('thead');
const headerRow = document.createElement('tr');
table.headers.forEach(header => {
const th = document.createElement('th');
th.textContent = header;
headerRow.appendChild(th);
});
thead.appendChild(headerRow);
tableElement.appendChild(thead);
// Create table body
const tbody = document.createElement('tbody');
table.rows.forEach(row => {
const tr = document.createElement('tr');
row.forEach((cell, index) => {
const td = document.createElement('td');
if (index === 1 && (cell === '[x]' || cell === '[ ]')) {
// Create checkbox for "Done" column
const checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.className = 'checkbox';
checkbox.checked = cell === '[x]';
checkbox.addEventListener('change', (e) => {
row[index] = e.target.checked ? '[x]' : '[ ]';
updateTables();
});
td.appendChild(checkbox);
} 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', () => {
if (taskInput.value.trim()) {
addRow(table.title, taskInput.value.trim());
taskInput.value = '';
}
});
addRowForm.appendChild(taskInput);
addRowForm.appendChild(addBtn);
tableContainer.appendChild(addRowForm);
tablesContainer.appendChild(tableContainer);
});
}
think how to improve? too big space for done column, text in task column is not multiline
Here's an improved version of your renderTables function with better spacing, multiline text support, and a more compact design:
function renderTables() {
tablesContainer.innerHTML = '';
tables.forEach(table => {
const tableContainer = document.createElement('div');
tableContainer.className = 'table-container';
// Table header with title and copy button
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);
// Create table element
const tableElement = document.createElement('table');
// Create table header
const thead = document.createElement('thead');
const headerRow = document.createElement('tr');
table.headers.forEach((header, index) => {
const th = document.createElement('th');
th.textContent = header;
// Make the "Done" column header narrower
if (header.toLowerCase() === 'done') {
th.style.width = '60px'; // Fixed width for checkbox column
}
headerRow.appendChild(th);
});
thead.appendChild(headerRow);
tableElement.appendChild(thead);
// Create table body
const tbody = document.createElement('tbody');
table.rows.forEach(row => {
const tr = document.createElement('tr');
row.forEach((cell, index) => {
const td = document.createElement('td');
// Style for multiline text in task column
if (index === 0) { // Assuming first column is task
td.style.whiteSpace = 'pre-wrap'; // Allow text wrapping
td.style.wordBreak = 'break-word'; // Break long words
td.style.maxWidth = '400px'; // Limit width for better readability
}
if (index === 1 && (cell === '[x]' || cell === '[ ]')) {
// Compact checkbox for "Done" column
const checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.className = 'checkbox';
checkbox.style.margin = '0 auto'; // Center the checkbox
checkbox.style.display = 'block'; // Make it block for centering
checkbox.checked = cell === '[x]';
checkbox.addEventListener('change', (e) => {
row[index] = e.target.checked ? '[x]' : '[ ]';
updateTables();
});
td.appendChild(checkbox);
td.style.padding = '8px'; // Reduce padding for checkbox column
td.style.textAlign = 'center'; // Center checkbox
} else {
td.textContent = cell;
}
tr.appendChild(td);
});
tbody.appendChild(tr);
});
tableElement.appendChild(tbody);
tableContainer.appendChild(tableElement);
// Add row form - improved layout
const addRowForm = document.createElement('div');
addRowForm.className = 'add-row';
const taskInput = document.createElement('input');
taskInput.type = 'text';
taskInput.placeholder = 'New task name...';
taskInput.style.flex = '1';
taskInput.style.minWidth = '0'; // Allow input to shrink
const addBtn = document.createElement('button');
addBtn.textContent = 'Add Task';
addBtn.style.marginLeft = '8px';
addBtn.style.flexShrink = '0'; // Prevent button from shrinking
addBtn.addEventListener('click', () => {
if (taskInput.value.trim()) {
addRow(table.title, taskInput.value.trim());
taskInput.value = '';
}
});
addRowForm.appendChild(taskInput);
addRowForm.appendChild(addBtn);
tableContainer.appendChild(addRowForm);
tablesContainer.appendChild(tableContainer);
});
}
Key improvements:
Compact "Done" Column:
Multiline Text Support:
whiteSpace: 'pre-wrap' and wordBreak: 'break-word' to task cellsBetter Table Layout:
Enhanced Add Row Form:
General Improvements:
You might also want to add these CSS rules to complement the JavaScript changes:
/* Add to your existing CSS */
table {
table-layout: fixed; /* For consistent column widths */
}
td {
vertical-align: top; /* Align content to top for multiline text */
padding: 8px 12px;
}
th {
padding: 12px;
}
/* For the checkbox column */
td:has(.checkbox) {
width: 60px;
padding: 8px;
text-align: center;
}
/* For the task column */
td:first-child {
white-space: pre-wrap;
word-break: break-word;
max-width: 400px;
}
These changes will create a more polished, functional table layout with proper text handling and compact checkboxes.