Prettified Code!

This commit is contained in:
Mashintime 2023-05-14 13:11:10 +00:00 committed by GitHub Action
parent 41d29ec176
commit 6ea0b2fbf7
2 changed files with 79 additions and 82 deletions

View file

@ -1603,39 +1603,29 @@ window.addEventListener("DOMContentLoaded", () => {
}); });
document.getElementById("thTime").addEventListener("click", () => { document.getElementById("thTime").addEventListener("click", () => {
if (hslLastSort==0 && hslLastSortDir=="asc") if (hslLastSort == 0 && hslLastSortDir == "asc") hslLastSortDir = "desc";
hslLastSortDir="desc" else hslLastSortDir = "asc";
else sorthslTable(0);
hslLastSortDir="asc"
sorthslTable(0)
}); });
document.getElementById("thFreq").addEventListener("click", () => { document.getElementById("thFreq").addEventListener("click", () => {
if (hslLastSort==1 && hslLastSortDir=="asc") if (hslLastSort == 1 && hslLastSortDir == "asc") hslLastSortDir = "desc";
hslLastSortDir="desc" else hslLastSortDir = "asc";
else sorthslTable(1);
hslLastSortDir="asc"
sorthslTable(1)
}); });
document.getElementById("thDxcall").addEventListener("click", () => { document.getElementById("thDxcall").addEventListener("click", () => {
if (hslLastSort==3 && hslLastSortDir=="asc") if (hslLastSort == 3 && hslLastSortDir == "asc") hslLastSortDir = "desc";
hslLastSortDir="desc" else hslLastSortDir = "asc";
else sorthslTable(3);
hslLastSortDir="asc"
sorthslTable(3)
}); });
document.getElementById("thDxgrid").addEventListener("click", () => { document.getElementById("thDxgrid").addEventListener("click", () => {
if (hslLastSort==4 && hslLastSortDir=="asc") if (hslLastSort == 4 && hslLastSortDir == "asc") hslLastSortDir = "desc";
hslLastSortDir="desc" else hslLastSortDir = "asc";
else sorthslTable(4);
hslLastSortDir="asc"
sorthslTable(4)
}); });
document.getElementById("thDist").addEventListener("click", () => { document.getElementById("thDist").addEventListener("click", () => {
if (hslLastSort==5 && hslLastSortDir=="asc") if (hslLastSort == 5 && hslLastSortDir == "asc") hslLastSortDir = "desc";
hslLastSortDir="desc" else hslLastSortDir = "asc";
else sorthslTable(5);
hslLastSortDir="asc"
sorthslTable(5)
}); });
}); });
@ -3559,7 +3549,15 @@ function changeGuiDesign(design) {
//https://www.w3schools.com/howto/howto_js_sort_table.asp //https://www.w3schools.com/howto/howto_js_sort_table.asp
function sorthslTable(n) { function sorthslTable(n) {
hslLastSort = n; hslLastSort = n;
var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0; var table,
rows,
switching,
i,
x,
y,
shouldSwitch,
dir,
switchcount = 0;
table = document.getElementById("tblHeardStationList"); table = document.getElementById("tblHeardStationList");
switching = true; switching = true;
// Set the sorting direction to ascending: // Set the sorting direction to ascending:
@ -3572,7 +3570,7 @@ function changeGuiDesign(design) {
rows = table.rows; rows = table.rows;
/* Loop through all table rows (except the /* Loop through all table rows (except the
first, which contains table headers): */ first, which contains table headers): */
for (i = 1; i < (rows.length - 1); i++) { for (i = 1; i < rows.length - 1; i++) {
// Start by saying there should be no switching: // Start by saying there should be no switching:
shouldSwitch = false; shouldSwitch = false;
/* Get the two elements you want to compare, /* Get the two elements you want to compare,

View file

@ -1163,8 +1163,7 @@
<!--<th scope="col">Off</th>--> <!--<th scope="col">Off</th>-->
</tr> </tr>
</thead> </thead>
<tbody id="heardstations"> <tbody id="heardstations"></tbody>
</tbody>
</table> </table>
</div> </div>
<!-- END OF HEARD STATIONS TABLE --> <!-- END OF HEARD STATIONS TABLE -->