From f71e4d0d1e1d68d2545aa2949d864e31bfa5cca8 Mon Sep 17 00:00:00 2001 From: Tomas Chmelevskij Date: Wed, 22 Dec 2021 14:22:00 +0100 Subject: [PATCH] refactor: use js to generate table contents --- .sonarcloud.properties | 1 - src/css/dark-theme.css | 2 +- src/css/main.css | 2 +- src/js/tabs/gps.js | 63 +++++++------ src/tabs/gps.html | 199 +---------------------------------------- 5 files changed, 40 insertions(+), 227 deletions(-) diff --git a/.sonarcloud.properties b/.sonarcloud.properties index bc97ccc6..e69de29b 100644 --- a/.sonarcloud.properties +++ b/.sonarcloud.properties @@ -1 +0,0 @@ -sonar.cpd.exclusions=src/*.html \ No newline at end of file diff --git a/src/css/dark-theme.css b/src/css/dark-theme.css index d74e61d7..4eecd53f 100644 --- a/src/css/dark-theme.css +++ b/src/css/dark-theme.css @@ -147,7 +147,7 @@ button { border-style: solid; } -.noboarder td { +.cf_table tr:last-child td { border-style: unset; } diff --git a/src/css/main.css b/src/css/main.css index 5e706e5e..f9be1f08 100644 --- a/src/css/main.css +++ b/src/css/main.css @@ -2148,7 +2148,7 @@ dialog .dialog_toolbar .btn a.disabled { width: 33%; } -.noboarder td { +.cf_table tr:last-child td { border: none; } diff --git a/src/js/tabs/gps.js b/src/js/tabs/gps.js index e11d2b74..86e23104 100644 --- a/src/js/tabs/gps.js +++ b/src/js/tabs/gps.js @@ -67,56 +67,67 @@ TABS.gps.initialize = function (callback) { $('.GPS_info td.distToHome').text(FC.GPS_DATA.distanceToHome + ' m'); // Update GPS Signal Strengths - const eSsTable = $('div.GPS_signal_strength table tr:not(.titles)'); + const eSsTable = $('div.GPS_signal_strength table'); + eSsTable.html(''); + eSsTable.append(` + + ${i18n.getMessage('gpsSignalGnssId')} + ${i18n.getMessage('gpsSignalSatId')} + ${i18n.getMessage('gpsSignalStr')} + ${i18n.getMessage('gpsSignalStatusQly')} + + `); if (FC.GPS_DATA.chn.length <= 16) { // Legacy code path: old BF firmware or old ublox module for (let i = 0; i < FC.GPS_DATA.chn.length; i++) { - const row = eSsTable.eq(i); - - $('td', row).eq(0).text('-'); - $('td', row).eq(1).text(FC.GPS_DATA.svid[i]); - $('td', row).eq(2).find('progress').val(FC.GPS_DATA.cno[i]); - $('td', row).eq(3).text(FC.GPS_DATA.quality[i]); + eSsTable.append(` + + - + ${FC.GPS_DATA.svid[i]} + + ${FC.GPS_DATA.quality[i]} + + `); } // Cleanup the rest of the table for (let i = FC.GPS_DATA.chn.length; i < 32; i++) { - const row = eSsTable.eq(i); - - $('td', row).eq(0).text('-'); - $('td', row).eq(1).text('-'); - $('td', row).eq(2).find('progress').val(0); - $('td', row).eq(3).text(' '); + eSsTable.append(` + + - + - + + + + `); } } else { // M8N/M9N on newer firmware const maxUIChannels = 32; //the list in html can only show 32 channels but future firmware could send more - let channels = Math.min(maxUIChannels, FC.GPS_DATA.chn.length); + let channels = Math.min(maxUIChannels, FC.GPS_DATA.chn.length) || 32; for (let i = 0; i < channels; i++) { - const row = eSsTable.eq(i); - + let rowContent = ''; if (FC.GPS_DATA.chn[i] <= 6) { - $('td', row).eq(0).text(gnssArray[FC.GPS_DATA.chn[i]]); + rowContent += `${gnssArray[FC.GPS_DATA.chn[i]]}`; } else { - $('td', row).eq(0).text('-'); + rowContent += '-'; } if (FC.GPS_DATA.chn[i] >= 7) { - $('td', row).eq(1).text('-'); - $('td', row).eq(2).find('progress').val(0); - $('td', row).eq(3).text(' '); + rowContent += '-'; + rowContent += ``; + rowContent += ` `; } else { - $('td', row).eq(1).text(FC.GPS_DATA.svid[i]); - $('td', row).eq(2).find('progress').val(FC.GPS_DATA.cno[i]); - + rowContent += `${FC.GPS_DATA.svid[i]}`; + rowContent += ``; const quality = i18n.getMessage(qualityArray[FC.GPS_DATA.quality[i] & 0x7]); const used = i18n.getMessage(usedArray[(FC.GPS_DATA.quality[i] & 0x8) >> 3]); const healthy = i18n.getMessage(healthyArray[(FC.GPS_DATA.quality[i] & 0x30) >> 4]); - - $('td', row).eq(3).text(`${quality} | ${used} | ${healthy}`); + rowContent += `${quality} | ${used} | ${healthy}`; } + eSsTable.append(`${rowContent}`); } } diff --git a/src/tabs/gps.html b/src/tabs/gps.html index 5ce8937a..a93579b8 100644 --- a/src/tabs/gps.html +++ b/src/tabs/gps.html @@ -52,204 +52,7 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000