From 41d29ec176ea410ced421a39e2c2d54e302544cd Mon Sep 17 00:00:00 2001 From: Mashintime Date: Sun, 14 May 2023 09:10:01 -0400 Subject: [PATCH 1/2] Allow sorting of heard station list --- gui/preload-main.js | 94 ++++++++++++++++++++++++++++++++++++++++++++- gui/src/index.html | 20 +++------- 2 files changed, 98 insertions(+), 16 deletions(-) diff --git a/gui/preload-main.js b/gui/preload-main.js index 163d5af6..4f03536b 100644 --- a/gui/preload-main.js +++ b/gui/preload-main.js @@ -1601,6 +1601,42 @@ window.addEventListener("DOMContentLoaded", () => { }; ipcRenderer.send("request-show-chat-window", Data); }); + + document.getElementById("thTime").addEventListener("click", () => { + if (hslLastSort==0 && hslLastSortDir=="asc") + hslLastSortDir="desc" + else + hslLastSortDir="asc" + sorthslTable(0) + }); + document.getElementById("thFreq").addEventListener("click", () => { + if (hslLastSort==1 && hslLastSortDir=="asc") + hslLastSortDir="desc" + else + hslLastSortDir="asc" + sorthslTable(1) + }); + document.getElementById("thDxcall").addEventListener("click", () => { + if (hslLastSort==3 && hslLastSortDir=="asc") + hslLastSortDir="desc" + else + hslLastSortDir="asc" + sorthslTable(3) + }); + document.getElementById("thDxgrid").addEventListener("click", () => { + if (hslLastSort==4 && hslLastSortDir=="asc") + hslLastSortDir="desc" + else + hslLastSortDir="asc" + sorthslTable(4) + }); + document.getElementById("thDist").addEventListener("click", () => { + if (hslLastSort==5 && hslLastSortDir=="asc") + hslLastSortDir="desc" + else + hslLastSortDir="asc" + sorthslTable(5) + }); }); function connectedStation(data) { @@ -2368,6 +2404,7 @@ function updateHeardStations(arg) { tbl.appendChild(row); } + sorthslTable(hslLastSort); } var populateSerial = false; @@ -3514,6 +3551,60 @@ function changeGuiDesign(design) { //update path to css file document.getElementById("bootstrap_theme").href = escape(theme_path); +} + + var hslLastSort=0; + var hslLastSortDir="asc"; + + //https://www.w3schools.com/howto/howto_js_sort_table.asp + function sorthslTable(n) { + hslLastSort=n; + var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0; + table = document.getElementById("tblHeardStationList"); + switching = true; + // Set the sorting direction to ascending: + //hslLastSortDir = "asc"; + /* Make a loop that will continue until + no switching has been done: */ + while (switching) { + // Start by saying: no switching is done: + switching = false; + rows = table.rows; + /* Loop through all table rows (except the + first, which contains table headers): */ + for (i = 1; i < (rows.length - 1); i++) { + // Start by saying there should be no switching: + shouldSwitch = false; + /* Get the two elements you want to compare, + one from current row and one from the next: */ + x = rows[i].getElementsByTagName("TD")[n]; + y = rows[i + 1].getElementsByTagName("TD")[n]; + /* Check if the two rows should switch place, + based on the direction, asc or desc: */ + if (hslLastSortDir == "asc") { + if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) { + // If so, mark as a switch and break the loop: + shouldSwitch = true; + break; + } + } else if (hslLastSortDir == "desc") { + if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) { + // If so, mark as a switch and break the loop: + shouldSwitch = true; + break; + } + } + } + if (shouldSwitch) { + /* If a switch has been marked, make the switch + and mark that a switch has been done: */ + rows[i].parentNode.insertBefore(rows[i + 1], rows[i]); + switching = true; + // Each time a switch is done, increase this count by 1: + switchcount ++; + } + } + } function autostart() { //Auto start stuff if option is enabled @@ -3529,5 +3620,4 @@ function changeGuiDesign(design) { } setTimeout(() => { autostart(); - }, 5000); -} + }, 5000); \ No newline at end of file diff --git a/gui/src/index.html b/gui/src/index.html index fa68d615..848c8efe 100644 --- a/gui/src/index.html +++ b/gui/src/index.html @@ -1149,29 +1149,21 @@
- +
- - + + - - - + + + -
TimeFrequencyTimeFrequency  DXCallDXGridDistanceDXCallDXGridDistance Type SNR (rx/dx)
From 6ea0b2fbf731f5be3dff5199cb90e102ae06106e Mon Sep 17 00:00:00 2001 From: Mashintime Date: Sun, 14 May 2023 13:11:10 +0000 Subject: [PATCH 2/2] Prettified Code! --- gui/preload-main.js | 158 ++++++++++++++++++++++---------------------- gui/src/index.html | 3 +- 2 files changed, 79 insertions(+), 82 deletions(-) diff --git a/gui/preload-main.js b/gui/preload-main.js index 4f03536b..be7dc993 100644 --- a/gui/preload-main.js +++ b/gui/preload-main.js @@ -1603,39 +1603,29 @@ window.addEventListener("DOMContentLoaded", () => { }); document.getElementById("thTime").addEventListener("click", () => { - if (hslLastSort==0 && hslLastSortDir=="asc") - hslLastSortDir="desc" - else - hslLastSortDir="asc" - sorthslTable(0) + if (hslLastSort == 0 && hslLastSortDir == "asc") hslLastSortDir = "desc"; + else hslLastSortDir = "asc"; + sorthslTable(0); }); document.getElementById("thFreq").addEventListener("click", () => { - if (hslLastSort==1 && hslLastSortDir=="asc") - hslLastSortDir="desc" - else - hslLastSortDir="asc" - sorthslTable(1) + if (hslLastSort == 1 && hslLastSortDir == "asc") hslLastSortDir = "desc"; + else hslLastSortDir = "asc"; + sorthslTable(1); }); document.getElementById("thDxcall").addEventListener("click", () => { - if (hslLastSort==3 && hslLastSortDir=="asc") - hslLastSortDir="desc" - else - hslLastSortDir="asc" - sorthslTable(3) + if (hslLastSort == 3 && hslLastSortDir == "asc") hslLastSortDir = "desc"; + else hslLastSortDir = "asc"; + sorthslTable(3); }); document.getElementById("thDxgrid").addEventListener("click", () => { - if (hslLastSort==4 && hslLastSortDir=="asc") - hslLastSortDir="desc" - else - hslLastSortDir="asc" - sorthslTable(4) + if (hslLastSort == 4 && hslLastSortDir == "asc") hslLastSortDir = "desc"; + else hslLastSortDir = "asc"; + sorthslTable(4); }); document.getElementById("thDist").addEventListener("click", () => { - if (hslLastSort==5 && hslLastSortDir=="asc") - hslLastSortDir="desc" - else - hslLastSortDir="asc" - sorthslTable(5) + if (hslLastSort == 5 && hslLastSortDir == "asc") hslLastSortDir = "desc"; + else hslLastSortDir = "asc"; + sorthslTable(5); }); }); @@ -3553,71 +3543,79 @@ function changeGuiDesign(design) { document.getElementById("bootstrap_theme").href = escape(theme_path); } - var hslLastSort=0; - var hslLastSortDir="asc"; +var hslLastSort = 0; +var hslLastSortDir = "asc"; - //https://www.w3schools.com/howto/howto_js_sort_table.asp - function sorthslTable(n) { - hslLastSort=n; - var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0; - table = document.getElementById("tblHeardStationList"); - switching = true; - // Set the sorting direction to ascending: - //hslLastSortDir = "asc"; - /* Make a loop that will continue until +//https://www.w3schools.com/howto/howto_js_sort_table.asp +function sorthslTable(n) { + hslLastSort = n; + var table, + rows, + switching, + i, + x, + y, + shouldSwitch, + dir, + switchcount = 0; + table = document.getElementById("tblHeardStationList"); + switching = true; + // Set the sorting direction to ascending: + //hslLastSortDir = "asc"; + /* Make a loop that will continue until no switching has been done: */ - while (switching) { - // Start by saying: no switching is done: - switching = false; - rows = table.rows; - /* Loop through all table rows (except the + while (switching) { + // Start by saying: no switching is done: + switching = false; + rows = table.rows; + /* Loop through all table rows (except the first, which contains table headers): */ - for (i = 1; i < (rows.length - 1); i++) { - // Start by saying there should be no switching: - shouldSwitch = false; - /* Get the two elements you want to compare, + for (i = 1; i < rows.length - 1; i++) { + // Start by saying there should be no switching: + shouldSwitch = false; + /* Get the two elements you want to compare, one from current row and one from the next: */ - x = rows[i].getElementsByTagName("TD")[n]; - y = rows[i + 1].getElementsByTagName("TD")[n]; - /* Check if the two rows should switch place, + x = rows[i].getElementsByTagName("TD")[n]; + y = rows[i + 1].getElementsByTagName("TD")[n]; + /* Check if the two rows should switch place, based on the direction, asc or desc: */ - if (hslLastSortDir == "asc") { - if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) { - // If so, mark as a switch and break the loop: - shouldSwitch = true; - break; - } - } else if (hslLastSortDir == "desc") { - if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) { - // If so, mark as a switch and break the loop: - shouldSwitch = true; - break; - } + if (hslLastSortDir == "asc") { + if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) { + // If so, mark as a switch and break the loop: + shouldSwitch = true; + break; + } + } else if (hslLastSortDir == "desc") { + if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) { + // If so, mark as a switch and break the loop: + shouldSwitch = true; + break; } } - if (shouldSwitch) { - /* If a switch has been marked, make the switch + } + if (shouldSwitch) { + /* If a switch has been marked, make the switch and mark that a switch has been done: */ - rows[i].parentNode.insertBefore(rows[i + 1], rows[i]); - switching = true; - // Each time a switch is done, increase this count by 1: - switchcount ++; - } + rows[i].parentNode.insertBefore(rows[i + 1], rows[i]); + switching = true; + // Each time a switch is done, increase this count by 1: + switchcount++; } } +} - function autostart() { - //Auto start stuff if option is enabled - if (config.auto_start == 1) { - //Start rigctld if radiocontrol is in correct mode and is not active - if (config.radiocontrol == "rigctld" && rigctldActive == false) { - //console.log("Autostarting rigctld"); - document.getElementById("hamlib_rigctld_start").click(); - } - //Now start TNC - document.getElementById("startTNC").click(); +function autostart() { + //Auto start stuff if option is enabled + if (config.auto_start == 1) { + //Start rigctld if radiocontrol is in correct mode and is not active + if (config.radiocontrol == "rigctld" && rigctldActive == false) { + //console.log("Autostarting rigctld"); + document.getElementById("hamlib_rigctld_start").click(); } + //Now start TNC + document.getElementById("startTNC").click(); } - setTimeout(() => { - autostart(); - }, 5000); \ No newline at end of file +} +setTimeout(() => { + autostart(); +}, 5000); diff --git a/gui/src/index.html b/gui/src/index.html index 848c8efe..8e42e8d3 100644 --- a/gui/src/index.html +++ b/gui/src/index.html @@ -1163,8 +1163,7 @@ - - +