From d2779242efe9e3b2d4579ada8ef6e1441f5d1592 Mon Sep 17 00:00:00 2001 From: Mark Haslinghuis Date: Fri, 8 Nov 2024 12:29:56 +0100 Subject: [PATCH] Fix gps color (#4241) * Fix gps color * Refactor and ease usedColor * [chore]Refactor lexical scoping --- src/js/tabs/gps.js | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/src/js/tabs/gps.js b/src/js/tabs/gps.js index 3a56c6b677..240832ed6e 100644 --- a/src/js/tabs/gps.js +++ b/src/js/tabs/gps.js @@ -265,31 +265,18 @@ gps.initialize = async function (callback) { rowContent += `${FC.GPS_DATA.svid[i]}`; rowContent += ``; - let quality = i18n.getMessage(qualityArray[FC.GPS_DATA.quality[i] & 0x7]); - let used = i18n.getMessage(usedArray[(FC.GPS_DATA.quality[i] & 0x8) >> 3]); - let usedColor = ''; + const quality = i18n.getMessage(qualityArray[FC.GPS_DATA.quality[i] & 0x7]); + const used = i18n.getMessage(usedArray[(FC.GPS_DATA.quality[i] & 0x8) >> 3]); // Add color to the text - // 2nd column: no signal = red, unusable = red, searching = red, locked = yellow and fully locked = green - if (quality.startsWith(i18n.getMessage('gnssQualityFullyLocked'))) { - usedColor = 'locked'; - quality = `${quality}`; - } else if (quality.startsWith(i18n.getMessage('gnssQualityLocked'))) { - usedColor = 'notReady'; - quality = `${quality}`; - } else { - quality = `${quality}`; - } - - // 1st column: unused = red, used = green - if (used.startsWith(i18n.getMessage('gnssUsedUsed'))) { - used = `${used}`; - } else { - used = `${used}`; - } - - rowContent += `${used} - ${quality}`; + const qualityColor = quality.startsWith(i18n.getMessage('gnssQualityFullyLocked')) ? 'ready' : quality.startsWith(i18n.getMessage('gnssQualityLocked')) ? 'locked' : 'low'; + const qualityHtml = `${quality}`; + + const usedColor = used.startsWith(i18n.getMessage('gnssUsedUsed')) ? 'ready' : 'low'; + const usedHtml = `${used}`; + + rowContent += `${usedHtml} + ${qualityHtml}`; } eSsTable.append(`${rowContent}`); }