|
@@ -36,7 +36,7 @@ app.clearFilter = function() {
|
|
|
filter.value = "";
|
|
|
app.filterTable("");
|
|
|
|
|
|
- document.querySelectorAll('th').forEach(th => {
|
|
|
+ document.querySelectorAll("th").forEach(th => {
|
|
|
th.textContent = th.textContent.replace(app.sorted, "");
|
|
|
});
|
|
|
};
|
|
@@ -44,14 +44,14 @@ app.clearFilter = function() {
|
|
|
app.getCellValue = (tr, idx) => tr.children[idx].innerText || tr.children[idx].textContent;
|
|
|
|
|
|
app.comparer = (idx, asc) => (a, b) => ((v1, v2) =>
|
|
|
- v1 !== '' && v2 !== '' && !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.toString().localeCompare(v2)
|
|
|
+ v1 !== "" && v2 !== "" && !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.toString().localeCompare(v2)
|
|
|
)(app.getCellValue(asc ? a : b, idx), app.getCellValue(asc ? b : a, idx));
|
|
|
|
|
|
app.sortTable = function() {
|
|
|
// borrowed from https://stackoverflow.com/a/49041392/7342859
|
|
|
- document.querySelectorAll('th').forEach(th => th.addEventListener('click', () => {
|
|
|
+ document.querySelectorAll("th").forEach(th => th.addEventListener("click", () => {
|
|
|
const table = document.getElementById("dataRows");
|
|
|
- Array.from(table.querySelectorAll('tr'))
|
|
|
+ Array.from(table.querySelectorAll("tr"))
|
|
|
.sort(app.comparer(Array.from(th.parentNode.children).indexOf(th), this.asc = !this.asc))
|
|
|
.forEach(tr => table.appendChild(tr));
|
|
|
|