aboutsummaryrefslogtreecommitdiff
path: root/parts
diff options
context:
space:
mode:
authorSan Jacobs2025-06-06 02:58:02 +0200
committerSan Jacobs2025-06-06 02:58:02 +0200
commite50cee75f11f0a9b1b4006daec2381bb497e02f6 (patch)
treeabca0062650ada9e0eb0e35e6f91f20d40d05057 /parts
parentf93340dd2c416ff60be64dfea261d8db9ef1aabb (diff)
downloadbetter-report-e50cee75f11f0a9b1b4006daec2381bb497e02f6.tar.gz
better-report-e50cee75f11f0a9b1b4006daec2381bb497e02f6.tar.bz2
better-report-e50cee75f11f0a9b1b4006daec2381bb497e02f6.zip
Rewrote EVERYTHING! WAY better now, but only works with ZOOM reports atm
Diffstat (limited to 'parts')
-rwxr-xr-xparts/end.html43
-rwxr-xr-xparts/start2.html6
2 files changed, 31 insertions, 18 deletions
diff --git a/parts/end.html b/parts/end.html
index f964978..cc51027 100755
--- a/parts/end.html
+++ b/parts/end.html
@@ -1,33 +1,46 @@
- </tbody>
- </table>
- </div>
+ </tbody>
+ </table>
</div>
-
</body>
<script type="text/javascript">
const getCellValue = (tr, idx) => tr.children[idx].innerText || tr.children[idx].textContent;
-
+ prevColumnSorted = document.getElementsByClassName("current-sort")[0];
+
const comparer = (idx, asc) => (a, b) => ((v1, v2) =>
v1 !== '' && v2 !== '' && !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.toString().localeCompare(v2)
)(getCellValue(asc ? a : b, idx), getCellValue(asc ? b : a, idx));
-
+
function doSort(th) {
- console.log("Doing sort to: ", th.textContent, th)
+ console.log("Doing sort to: ", th.textContent, th);
+
const table = th.closest('table');
- Array.from(table.querySelector('tbody').querySelectorAll('tr:nth-child(n)'))
- .sort(comparer(Array.from(th.parentNode.children).indexOf(th), this.asc = !this.asc))
- .forEach(tr => table.querySelector('tbody').appendChild(tr) );
+ const tbody = table.querySelector('tbody');
+ const columnIndex = Array.from(th.parentNode.children).indexOf(th);
+
+ // Toggle sort direction
+ if (prevColumnSorted == th) {
+ this.asc = !this.asc;
+ } else {
+ this.asc = true;
+ }
+
+ // Get all rows, sort them, then reappend to tbody
+ const rows = Array.from(tbody.querySelectorAll('tr'));
+ const sortedRows = rows.sort(comparer(columnIndex, this.asc));
+
+ sortedRows.forEach(row => tbody.appendChild(row));
+ prevColumnSorted = th;
}
- // do the work...
- document.querySelectorAll('th').forEach(th => th.addEventListener('click', (() => {
+
+ // Event listeners and initial sort
+ document.querySelectorAll('th').forEach(th => th.addEventListener('click', () => {
document.getElementsByClassName("current-sort")[0].classList.remove("current-sort");
th.classList.add("current-sort");
doSort(th);
- })));
-
+ }));
+
doSort(document.getElementsByClassName("current-sort")[0]);
-
</script>
</html>
diff --git a/parts/start2.html b/parts/start2.html
index bd0021e..bd43709 100755
--- a/parts/start2.html
+++ b/parts/start2.html
@@ -98,6 +98,6 @@
</svg>
</a>
<h1 style="width:max-content;margin:auto;">Lydrapport</h1>
- <h6 style="width:max-content;margin:auto;">Version 0.2</h6>
- </div>
- <div class="info-section"> \ No newline at end of file
+ <h6 style="width:max-content;margin:auto;">Version 0.5</h6>
+ </div>
+ <div class="info-section">