1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-25 01:05:15 +03:00

Language sort optionlist at LED tab (#3178)

* Sort 2 optionlist using sortSelect

* Update led_strip.js

Do the suggestion to code
(and remove some blank lines)
This commit is contained in:
HThuren 2022-12-30 03:08:03 +01:00 committed by GitHub
parent b0f7ef669e
commit ff5913b6cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 21 deletions

View file

@ -6,7 +6,6 @@ const led_strip = {
directions: ['n', 'e', 's', 'w', 'u', 'd'], directions: ['n', 'e', 's', 'w', 'u', 'd'],
}; };
led_strip.initialize = function (callback, scrollPosition) { led_strip.initialize = function (callback, scrollPosition) {
let selectedColorIndex = null; let selectedColorIndex = null;
let selectedModeColor = null; let selectedModeColor = null;
@ -34,7 +33,6 @@ led_strip.initialize = function (callback, scrollPosition) {
MSP.send_message(MSPCodes.MSP_LED_STRIP_MODECOLOR, false, false, load_html); MSP.send_message(MSPCodes.MSP_LED_STRIP_MODECOLOR, false, false, load_html);
} }
function load_html() { function load_html() {
$('#content').load("./tabs/led_strip.html", process_html); $('#content').load("./tabs/led_strip.html", process_html);
} }
@ -186,7 +184,6 @@ led_strip.initialize = function (callback, scrollPosition) {
}); });
updateBulkCmd(); updateBulkCmd();
}); });
// Color sliders // Color sliders
@ -217,7 +214,6 @@ led_strip.initialize = function (callback, scrollPosition) {
} }
} }
setColorSliders(selectedColorIndex); setColorSliders(selectedColorIndex);
$(this).addClass('btnOn'); $(this).addClass('btnOn');
@ -396,6 +392,9 @@ led_strip.initialize = function (callback, scrollPosition) {
}, },
}); });
// Sort the element, if need to group, do it by lexical sort, ie. by naming of (the translated) selection text
$('#ledStripFunctionSelect').sortSelect(i18n.getMessage("ledStripFunctionNoneOption"));
// UI: select LED function from drop-down // UI: select LED function from drop-down
$('.functionSelect').on('change', function() { $('.functionSelect').on('change', function() {
clearModeColorSelection(); clearModeColorSelection();
@ -405,6 +404,9 @@ led_strip.initialize = function (callback, scrollPosition) {
updateBulkCmd(); updateBulkCmd();
}); });
// Sort the element, if need to group, do it by lexical sort, ie. by naming of (the translated) selection text
$('#ledStripModeColorsModeSelect').sortSelect(i18n.getMessage("ledStripModeColorsModeOrientation"));
// UI: select mode from drop-down // UI: select mode from drop-down
$('.modeSelect').on('change', function() { $('.modeSelect').on('change', function() {
@ -425,8 +427,7 @@ led_strip.initialize = function (callback, scrollPosition) {
$('.mode_colors').each(function() { setModeBackgroundColor($(this)); }); $('.mode_colors').each(function() { setModeBackgroundColor($(this)); });
}); });
function toggleSwitch(that, letter) function toggleSwitch(that, letter) {
{
if ($(that).is(':checked')) { if ($(that).is(':checked')) {
$('.ui-selected').find('.wire').each(function() { $('.ui-selected').find('.wire').each(function() {
if ($(this).text() != "") { if ($(this).text() != "") {
@ -528,8 +529,6 @@ led_strip.initialize = function (callback, scrollPosition) {
} }
}); });
$('.mainGrid').disableSelection(); $('.mainGrid').disableSelection();
$('.gPoint').each(function(){ $('.gPoint').each(function(){
@ -563,7 +562,6 @@ led_strip.initialize = function (callback, scrollPosition) {
} }
$(this).addClass(`color-${led.color}`); $(this).addClass(`color-${led.color}`);
}); });
$('a.save').on('click', function () { $('a.save').on('click', function () {
@ -582,7 +580,6 @@ led_strip.initialize = function (callback, scrollPosition) {
GUI.log(i18n.getMessage('ledStripEepromSaved')); GUI.log(i18n.getMessage('ledStripEepromSaved'));
}); });
} }
}); });
colorDefineSliders.hide(); colorDefineSliders.hide();
@ -601,12 +598,6 @@ led_strip.initialize = function (callback, scrollPosition) {
GUI.content_ready(callback); GUI.content_ready(callback);
} }
function findLed(x, y) { function findLed(x, y) {
for (let ledIndex = 0; ledIndex < FC.LED_STRIP.length; ledIndex++) { for (let ledIndex = 0; ledIndex < FC.LED_STRIP.length; ledIndex++) {
const led = FC.LED_STRIP[ledIndex]; const led = FC.LED_STRIP[ledIndex];
@ -617,7 +608,6 @@ led_strip.initialize = function (callback, scrollPosition) {
return undefined; return undefined;
} }
function updateBulkCmd() { function updateBulkCmd() {
const ledStripLength = FC.LED_STRIP.length; const ledStripLength = FC.LED_STRIP.length;
@ -943,7 +933,6 @@ led_strip.initialize = function (callback, scrollPosition) {
} }
} }
// refresh color buttons // refresh color buttons
$('.colors').children().each(function() { setBackgroundColor($(this)); }); $('.colors').children().each(function() { setBackgroundColor($(this)); });
$('.overlay-color').each(function() { setBackgroundColor($(this)); }); $('.overlay-color').each(function() { setBackgroundColor($(this)); });
@ -1005,7 +994,6 @@ led_strip.initialize = function (callback, scrollPosition) {
// only fire events when all values are set // only fire events when all values are set
if (change) if (change)
sliders.trigger('input'); sliders.trigger('input');
} }
function HsvToColor(input) { function HsvToColor(input) {

View file

@ -39,7 +39,7 @@
<div class="select"> <div class="select">
<span class="color_section" i18n="ledStripFunctionTitle"></span> <span class="color_section" i18n="ledStripFunctionTitle"></span>
<select class="functionSelect"> <select id="ledStripFunctionSelect" class="functionSelect">
<option value="" i18n="ledStripFunctionNoneOption"></option> <option value="" i18n="ledStripFunctionNoneOption"></option>
<option value="function-c" i18n="ledStripFunctionColorOption"></option> <option value="function-c" i18n="ledStripFunctionColorOption"></option>
<option value="function-f" i18n="ledStripFunctionModesOption"></option> <option value="function-f" i18n="ledStripFunctionModesOption"></option>
@ -112,7 +112,7 @@
<div class="mode_colors"> <div class="mode_colors">
<div class="section" i18n="ledStripModeColorsTitle"></div> <div class="section" i18n="ledStripModeColorsTitle"></div>
<select class="modeSelect"> <select id="ledStripModeColorsModeSelect" class="modeSelect">
<option value="0" i18n="ledStripModeColorsModeOrientation"></option> <option value="0" i18n="ledStripModeColorsModeOrientation"></option>
<option value="1" i18n="ledStripModeColorsModeHeadfree"></option> <option value="1" i18n="ledStripModeColorsModeHeadfree"></option>
<option value="2" i18n="ledStripModeColorsModeHorizon"></option> <option value="2" i18n="ledStripModeColorsModeHorizon"></option>