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