-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
javascript:(function() {
const sortFunctions = {
// ... (rest of the sort functions remain the same)
};
function prepareTable(table) {
// ... (rest of the prepareTable function remains the same)
// Add ordinal order column
const ordinalHeader = document.createElement('th');
ordinalHeader.textContent = '#';
ordinalHeader.style.cursor = 'pointer';
table.querySelector('thead tr').prepend(ordinalHeader);
const rows = table.querySelectorAll('tbody tr');
rows.forEach((row, index) => {
const ordinalCell = document.createElement('td');
ordinalCell.textContent = index + 1;
row.prepend(ordinalCell);
});
}
function makeSortable(table) {
prepareTable(table);
const headers = table.querySelectorAll('th');
headers.forEach((header, index) => {
header.addEventListener('click', () => sortTable(table, index));
});
}
function sortTable(table, column) {
// ... (rest of the sortTable function remains the same)
const sortFunction = (() => {
switch(column) {
case 0: return (a, b) => sortFunctions.numeric(a, b, 'td:nth-child(1)'); // Sort by ordinal order
case 1: return sortFunctions.star;
// ... (rest of the case statements need to be adjusted for the new column)
}
})();
// ... (rest of the sortTable function remains the same)
}
// ... (rest of the code remains the same)
})();Metadata
Metadata
Assignees
Labels
No labels