mirror of
https://github.com/starshardstudio/peafowl.git
synced 2024-11-21 20:44:19 +00:00
Fix sorting
This commit is contained in:
parent
512389b954
commit
332b56651b
1 changed files with 38 additions and 3 deletions
|
@ -131,7 +131,7 @@ function readHasContent(a) {
|
|||
/**
|
||||
* @param a {HTMLTableRowElement}
|
||||
*/
|
||||
function readProgress(a) {
|
||||
function readGameProgress(a) {
|
||||
for(const cell of a.cells) {
|
||||
if(cell.classList.contains("game-progress")) {
|
||||
/**
|
||||
|
@ -160,6 +160,35 @@ function readProgress(a) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param a {HTMLTableRowElement}
|
||||
*/
|
||||
function readAnimeProgress(a) {
|
||||
for(const cell of a.cells) {
|
||||
if(cell.classList.contains("anime-progress")) {
|
||||
/**
|
||||
* @type {HTMLDataElement}
|
||||
*/
|
||||
const data = cell.firstElementChild
|
||||
switch (data.value) {
|
||||
case undefined:
|
||||
return undefined;
|
||||
case "unset":
|
||||
return undefined;
|
||||
case "new":
|
||||
return 10;
|
||||
case "started":
|
||||
return 20;
|
||||
case "completed":
|
||||
return 35;
|
||||
case "mastered":
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tableId {string}
|
||||
*/
|
||||
|
@ -229,7 +258,13 @@ function installSort(tableId) {
|
|||
}
|
||||
else if(cell.classList.contains("game-progress")) {
|
||||
cell.onclick = function() {
|
||||
sortTable(tableId, readProgress, (a, b) => b - a)
|
||||
sortTable(tableId, readGameProgress, (a, b) => b - a)
|
||||
}
|
||||
cell.classList.add("sortable")
|
||||
}
|
||||
else if(cell.classList.contains("anime-progress")) {
|
||||
cell.onclick = function() {
|
||||
sortTable(tableId, readAnimeProgress, (a, b) => b - a)
|
||||
}
|
||||
cell.classList.add("sortable")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue