forked from rDrama/rDrama
1
0
Fork 0

revert jc change that broke sorting tables

master
Aevann1 2022-11-28 06:50:24 +02:00
parent 323061bc86
commit 2cdfb42c2f
1 changed files with 4 additions and 13 deletions

View File

@ -7,24 +7,15 @@ function sort_table(n) {
for (let i = 1; i < rows.length; i++) { for (let i = 1; i < rows.length; i++) {
const ele = rows[i]; const ele = rows[i];
let x = rows[i].getElementsByTagName("TD")[n]; let x = rows[i].getElementsByTagName("TD")[n];
if (!('sortKey' in x.dataset)) { x = x.getElementsByTagName('a')[0] || x;
x = x.getElementsByTagName('a')[0] || x; const attr = x.dataset.time ? parseInt(x.dataset.time) : parseInt(x.innerHTML.replace(/,/g, ''));
}
var attr;
if ('sortKey' in x.dataset) {
attr = x.dataset.sortKey;
} else if ('time' in x.dataset) {
attr = parseInt(x.dataset.time);
} else {
attr = parseInt(x.innerHTML.replace(/,/g, ''));
}
items.push({ ele, attr }); items.push({ ele, attr });
} }
if (sortAscending[n]) { if (sortAscending[n]) {
items.sort((a, b) => a.attr > b.attr); items.sort((a, b) => a.attr - b.attr);
sortAscending[n] = false; sortAscending[n] = false;
} else { } else {
items.sort((a, b) => a.attr < b.attr); items.sort((a, b) => b.attr - a.attr);
sortAscending[n] = true; sortAscending[n] = true;
} }