starshard/peafowl
Template
1
Fork 0
mirror of https://github.com/starshardstudio/peafowl.git synced 2024-11-21 12:34:20 +00:00

Fix sorting

This commit is contained in:
Steffo 2024-11-05 17:50:43 +01:00
parent 512389b954
commit 332b56651b
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0

View file

@ -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,9 +258,15 @@ 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")
}
}
}
}