|
|
@ -237,13 +237,13 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
|
|
|
|
|
|
|
|
|
|
function onSort(ctx, ix, event) {
|
|
|
|
function onSort(ctx, ix, event) {
|
|
|
|
const tbl = ctx.tbl
|
|
|
|
const tbl = ctx.tbl
|
|
|
|
|
|
|
|
|
|
|
|
const sortDir = event.target.getAttribute('data-sort') || 'asc'
|
|
|
|
const sortDir = event.target.getAttribute('data-sort') || 'asc'
|
|
|
|
const sortMod = sortDir === 'asc' ? -1 : 1;
|
|
|
|
const sortMod = sortDir === 'asc' ? -1 : 1;
|
|
|
|
|
|
|
|
|
|
|
|
const rows = tblRows(tbl)
|
|
|
|
const rows = tblRows(tbl)
|
|
|
|
const newTbody = document.createElement('tbody')
|
|
|
|
const newTbody = document.createElement('tbody')
|
|
|
|
|
|
|
|
|
|
|
|
rows.sort((row1, row2) => {
|
|
|
|
rows.sort((row1, row2) => {
|
|
|
|
const val1 = row1.cells[ix].textContent
|
|
|
|
const val1 = row1.cells[ix].textContent
|
|
|
|
const val2 = row2.cells[ix].textContent
|
|
|
|
const val2 = row2.cells[ix].textContent
|
|
|
@ -251,10 +251,10 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
|
|
: val2 > val1 ? -1
|
|
|
|
: val2 > val1 ? -1
|
|
|
|
: 0);
|
|
|
|
: 0);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
rows.forEach(row => newTbody.appendChild(row))
|
|
|
|
rows.forEach(row => newTbody.appendChild(row))
|
|
|
|
tbl.replaceChild(newTbody, tbl.tBodies[0])
|
|
|
|
tbl.replaceChild(newTbody, tbl.tBodies[0])
|
|
|
|
|
|
|
|
|
|
|
|
clearSortAttributes(tbl)
|
|
|
|
clearSortAttributes(tbl)
|
|
|
|
event.target.setAttribute('data-sort', flipSortDir(sortDir))
|
|
|
|
event.target.setAttribute('data-sort', flipSortDir(sortDir))
|
|
|
|
changePage(ctx, 0)
|
|
|
|
changePage(ctx, 0)
|
|
|
|