From 6d28cac0342cd132f53c654b4ba0cca3e187136a Mon Sep 17 00:00:00 2001 From: mikeller Date: Mon, 23 Oct 2017 09:49:21 +1300 Subject: [PATCH] Refactored version display, made text congruent. --- _locales/en/messages.json | 4 ++-- main.js | 31 +++++++++++++++++++++---------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index afc0df0e..74d3c0ea 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -213,8 +213,8 @@ "fcInfoReceived": { "message": "Flight controller info, identifier: $1, version: $2" }, - "versionLabelHardware": { - "message": "Board" + "versionLabelTarget": { + "message": "Target" }, "versionLabelFirmware": { "message": "Firmware" diff --git a/main.js b/main.js index 2152b0df..12e10b43 100644 --- a/main.js +++ b/main.js @@ -518,31 +518,42 @@ function generateFilename(prefix, suffix) { return filename + '.' + suffix; } -function updateTopBarVersion(firmwareVersion, firmwareId, hardwareId) { - var versionText = chrome.i18n.getMessage('versionLabelConfigurator') + ': ' + chrome.runtime.getManifest().version + '
'; +function getFirmwareVersion(firmwareVersion, firmwareId, hardwareId) { + var versionText = ''; if (firmwareVersion) { versionText += chrome.i18n.getMessage('versionLabelFirmware') + ': ' + firmwareId + ' ' + firmwareVersion; + if (hardwareId) { - versionText += ' (Target: ' + hardwareId + ')'; + versionText += ' (' + chrome.i18n.getMessage('versionLabelTarget') + ': ' + hardwareId + ')'; } } + return versionText; +} + +function getConfiguratorVersion() { + return chrome.i18n.getMessage('versionLabelConfigurator') + ': ' + chrome.runtime.getManifest().version; +} + +function updateTopBarVersion(firmwareVersion, firmwareId, hardwareId) { + var versionText = getConfiguratorVersion() + '
'; + + versionText = versionText + getFirmwareVersion(firmwareVersion, firmwareId, hardwareId); + $('#logo .logo_text').html(versionText); } function updateStatusBarVersion(firmwareVersion, firmwareId, hardwareId) { var versionText = ''; - if (hardwareId) { - versionText = versionText + chrome.i18n.getMessage('versionLabelHardware') + ': ' + hardwareId + ', '; + versionText = versionText + getFirmwareVersion(firmwareVersion, firmwareId, hardwareId); + + if (versionText !== '') { + versionText = versionText + ', '; } - if (firmwareVersion) { - versionText = versionText + chrome.i18n.getMessage('versionLabelFirmware') + ': ' + firmwareId + ' ' + firmwareVersion + ', '; - } - - versionText = versionText + chrome.i18n.getMessage('versionLabelConfigurator') + ': ' + chrome.runtime.getManifest().version; + versionText = versionText + getConfiguratorVersion(); $('#status-bar .version').text(versionText); }