From f9a5eca69f89cfde5edc5a162c2c3202e1cb1b08 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Sat, 19 Feb 2022 19:59:26 +0000 Subject: [PATCH] Made highlighting switchable via the config gear --- _locales/en/messages.json | 3 ++ js/settings.js | 12 ++++---- main.js | 33 ++++++++++++++++++++-- src/css/dropdown-lists/css/style_lists.css | 4 +-- tabs/options.html | 10 +++++-- 5 files changed, 50 insertions(+), 12 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 7006b395..c63c9adf 100755 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -12,6 +12,9 @@ "options_improve_configurator": { "message": "Send anonymous usage data to the developer team" }, + "options_showProfileParameters": { + "message": "Highlight parameters that change when switching battery or control profiles" + }, "options_unit_type": { "message": "Set how the units render on the configurator only" }, diff --git a/js/settings.js b/js/settings.js index d7da43f8..cb98a8ec 100644 --- a/js/settings.js +++ b/js/settings.js @@ -12,12 +12,14 @@ var Settings = (function () { var settingName = input.data('setting'); var inputUnit = input.data('unit'); - if (FC.isBatteryProfileParameter(settingName)) { - input.css("background-color","#fef2d5"); - } + if (globalSettings.showProfileParameters) { + if (FC.isBatteryProfileParameter(settingName)) { + input.css("background-color","#fef2d5"); + } - if (FC.isControlProfileParameter(settingName)) { - input.css("background-color","#d5ebfe"); + if (FC.isControlProfileParameter(settingName)) { + input.css("background-color","#d5ebfe"); + } } return mspHelper.getSetting(settingName).then(function (s) { diff --git a/main.js b/main.js index 09407d5f..3d719944 100644 --- a/main.js +++ b/main.js @@ -28,7 +28,8 @@ let globalSettings = { mapProviderType: null, mapApiKey: null, proxyURL: null, - proxyLayer: null + proxyLayer: null, + showProfileParameters: null, }; $(document).ready(function () { @@ -65,6 +66,12 @@ $(document).ready(function () { } globalSettings.proxyLayer = result.proxylayer; }); + chrome.storage.local.get('show_profile_parameters', function (result) { + if (typeof result.show_profile_parameters === 'undefined') { + result.show_profile_parameters = 1; + } + globalSettings.showProfileParameters = result.show_profile_parameters; + }); // Resets the OSD units used by the unit coversion when the FC is disconnected. if (!CONFIGURATOR.connectionValid) { @@ -327,11 +334,33 @@ $(document).ready(function () { googleAnalyticsConfig.setTrackingPermitted(check); }); + $('div.show_profile_parameters input').change(function () { + globalSettings.showProfileParameters = $(this).is(':checked'); + chrome.storage.local.set({ + 'show_profile_parameters': globalSettings.showProfileParameters + }); + + // Update CSS on select boxes + if (globalSettings.showProfileParameters) { + $('.dropdown-dark #profilechange').addClass('showProfileParams'); + $('.dropdown-dark #batteryprofilechange').addClass('showProfileParams'); + } else { + $('.dropdown-dark #profilechange').removeClass('showProfileParams'); + $('.dropdown-dark #batteryprofilechange').removeClass('showProfileParams'); + } + + // Horrible way to reload the tab + const activeTab = $('#tabs li.active'); + activeTab.removeClass('active'); + activeTab.find('a').click(); + }); + $('#ui-unit-type').val(globalSettings.unitType); $('#map-provider-type').val(globalSettings.mapProviderType); $('#map-api-key').val(globalSettings.mapApiKey); $('#proxyurl').val(globalSettings.proxyURL); - $('#proxylayer').val(globalSettings.proxyLayer); + $('#proxylayer').val(globalSettings.proxyLayer); + $('#showProfileParameters').prop('checked', globalSettings.showProfileParameters); // Set the value of the unit type // none, OSD, imperial, metric diff --git a/src/css/dropdown-lists/css/style_lists.css b/src/css/dropdown-lists/css/style_lists.css index 9df4c9ef..878d0fdb 100644 --- a/src/css/dropdown-lists/css/style_lists.css +++ b/src/css/dropdown-lists/css/style_lists.css @@ -146,10 +146,10 @@ text-shadow: 0 1px rgba(0, 0, 0, 0.4); } -.dropdown-dark #profilechange { +.dropdown-dark #profilechange.showProfileParams { color: #d5ebfe; } -.dropdown-dark #batteryprofilechange { +.dropdown-dark #batteryprofilechange.showProfileParams { color: #fef2d5; } \ No newline at end of file diff --git a/tabs/options.html b/tabs/options.html index 10a3eff1..aa3f9ba3 100644 --- a/tabs/options.html +++ b/tabs/options.html @@ -8,14 +8,18 @@
- +
-
+
+ +
+ + +