Skip to content

Commit

Permalink
Refactor and ease usedColor
Browse files Browse the repository at this point in the history
  • Loading branch information
haslinghuis committed Nov 4, 2024
1 parent b60592d commit dd7b079
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions src/js/tabs/gps.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,29 +267,17 @@ gps.initialize = async function (callback) {

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 = '';
let usedColor;

// 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 = `<span class="colorToggle ready">${quality}</span>`;
} else if (quality.startsWith(i18n.getMessage('gnssQualityLocked'))) {
usedColor = 'notReady';
quality = `<span class="colorToggle locked">${quality}</span>`;
} else {
quality = `<span class="colorToggle">${quality}</span>`;
}

// 1st column: unused = red, used = green
if (used.startsWith(i18n.getMessage('gnssUsedUsed'))) {
used = `<span class="colorToggle ready">${used}</span>`;
} else {
used = `<span class="colorToggle">${used}</span>`;
}

rowContent += `<td style="text-align: left; width: 17%;">${used}</td>
<td style="text-align: left; width: 33%;">${quality}</td>`;
usedColor = quality.startsWith(i18n.getMessage('gnssQualityFullyLocked')) ? 'ready' : quality.startsWith(i18n.getMessage('gnssQualityLocked')) ? 'locked' : 'low';
const qualityHtml = `<span class="colorToggle ${usedColor}">${quality}</span>`;

usedColor = used.startsWith(i18n.getMessage('gnssUsedUsed')) ? 'ready' : 'low';
const usedHtml = `<span class="colorToggle ${usedColor}">${used}</span>`;

rowContent += `<td style="text-align: left; width: 17%;">${usedHtml}</td>
<td style="text-align: left; width: 33%;">${qualityHtml}</td>`;
}
eSsTable.append(`<tr>${rowContent}</tr>`);
}
Expand Down

0 comments on commit dd7b079

Please sign in to comment.