added league stats
This commit is contained in:
@@ -705,6 +705,9 @@
|
||||
.justify-end {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.gap-0\.5 {
|
||||
gap: calc(var(--spacing) * 0.5);
|
||||
}
|
||||
.gap-1 {
|
||||
gap: calc(var(--spacing) * 1);
|
||||
}
|
||||
@@ -768,6 +771,13 @@
|
||||
margin-block-end: calc(calc(var(--spacing) * 6) * calc(1 - var(--tw-space-y-reverse)));
|
||||
}
|
||||
}
|
||||
.space-y-8 {
|
||||
:where(& > :not(:last-child)) {
|
||||
--tw-space-y-reverse: 0;
|
||||
margin-block-start: calc(calc(var(--spacing) * 8) * var(--tw-space-y-reverse));
|
||||
margin-block-end: calc(calc(var(--spacing) * 8) * calc(1 - var(--tw-space-y-reverse)));
|
||||
}
|
||||
}
|
||||
.gap-x-2 {
|
||||
column-gap: calc(var(--spacing) * 2);
|
||||
}
|
||||
|
||||
36
internal/embedfs/web/js/sortable-table.js
Normal file
36
internal/embedfs/web/js/sortable-table.js
Normal file
@@ -0,0 +1,36 @@
|
||||
function sortableTable(initField, initDir) {
|
||||
return {
|
||||
sortField: initField || "score",
|
||||
sortDir: initDir || "desc",
|
||||
|
||||
sort(field) {
|
||||
if (this.sortField === field) {
|
||||
this.sortDir = this.sortDir === "asc" ? "desc" : "asc";
|
||||
} else {
|
||||
this.sortField = field;
|
||||
this.sortDir = "desc";
|
||||
}
|
||||
this.reorder();
|
||||
},
|
||||
|
||||
reorder() {
|
||||
const tbody = this.$refs.tbody;
|
||||
if (!tbody) return;
|
||||
const rows = Array.from(tbody.querySelectorAll("tr"));
|
||||
const field = this.sortField;
|
||||
const dir = this.sortDir === "asc" ? 1 : -1;
|
||||
|
||||
rows.sort((a, b) => {
|
||||
const aVal = parseFloat(a.dataset[field]) || 0;
|
||||
const bVal = parseFloat(b.dataset[field]) || 0;
|
||||
if (aVal !== bVal) return (aVal - bVal) * dir;
|
||||
// Tiebreak: alphabetical by player name
|
||||
const aName = (a.dataset.name || "").toLowerCase();
|
||||
const bName = (b.dataset.name || "").toLowerCase();
|
||||
return aName < bName ? -1 : aName > bName ? 1 : 0;
|
||||
});
|
||||
|
||||
rows.forEach((row) => tbody.appendChild(row));
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user