diff --git a/_static/scripting/sort.js b/_static/scripting/sort.js index 2ee9ec0..7ee5902 100644 --- a/_static/scripting/sort.js +++ b/_static/scripting/sort.js @@ -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") } } -} \ No newline at end of file +}