From dedcc7f9d1867ef02e01eaa406a276f285617dd6 Mon Sep 17 00:00:00 2001 From: HThuren Date: Sun, 17 Sep 2023 12:27:40 +0200 Subject: [PATCH 01/32] At Auxiliaty tab, now switch to hide non FlightModes --- locales/en/messages.json | 4 +++ src/js/tabs/auxiliary.js | 58 +++++++++++++++++++++++++++++----------- src/tabs/auxiliary.html | 4 +++ 3 files changed, 51 insertions(+), 15 deletions(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index 668a66c527..184b55c519 100755 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -2314,6 +2314,10 @@ "auxiliaryToggleUnused": { "message": "Hide unused modes" }, + "auxiliaryToggleNoFlightMode": { + "message": "Show only flight modes", + "descripton": "Toggle if all modes are shown or only Flight modes" + }, "auxiliaryMin": { "message": "Min" }, diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index 0221f01d5e..46bdf4d523 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -13,6 +13,9 @@ import inflection from "inflection"; const auxiliary = {}; +const flightModes = ["ARM","ANGLE","HORIZON","ANTI GRAVITY","MAG","HEADFREE","HEADADJ","SERVO1","SERVO2","SERVO3", +"FAILSAFE","AIR MODE","3D","FPV ANGLE MIX","FLIP OVER AFTER CRASH","USER1","USER2","USER3","USER4","ACRO TRAINER","LAUNCH CONTROL"]; + auxiliary.initialize = function (callback) { GUI.active_tab_ref = this; GUI.active_tab = 'auxiliary'; @@ -47,6 +50,15 @@ auxiliary.initialize = function (callback) { $('#content').load("./tabs/auxiliary.html", process_html); } + function isFlightMode(name) { + for (let i = 0; i < flightModes.length; i++) { + if (name == flightModes[i]) { + return true; + } + } + return false; + } + MSP.send_message(MSPCodes.MSP_BOXNAMES, false, false, get_mode_ranges); function createMode(modeIndex, modeId) { @@ -303,6 +315,9 @@ auxiliary.initialize = function (callback) { } } + // translate to user-selected language + i18n.localizePage(); + const length = Math.max(...(FC.AUX_CONFIG.map(el => el.length))); $('.tab-auxiliary .mode .info').css('min-width', `${Math.round(length * getTextWidth('A'))}px`); @@ -318,9 +333,6 @@ auxiliary.initialize = function (callback) { addLinkedToMode(modeElement, 0, 0); }); - // translate to user-selected language - i18n.localizePage(); - // UI Hooks $('a.save').click(function () { @@ -411,7 +423,6 @@ auxiliary.initialize = function (callback) { } }); - function limit_channel(channelPosition) { if (channelPosition < 900) { channelPosition = 900; @@ -487,16 +498,19 @@ auxiliary.initialize = function (callback) { hasUsedMode = true; } - if (hasDirtyUnusedModes) { - hasDirtyUnusedModes = false; - let hideUnused = hideUnusedModes && hasUsedMode; - for (let i = 0; i < FC.AUX_CONFIG.length; i++) { - let modeElement = $(`#mode-${i}`); - if (!modeElement.find(' .range').length && !modeElement.find(' .link').length) { - modeElement.toggle(!hideUnused); - } + let hideUnused = hideUnusedModes && hasUsedMode; + let hideNoFlight = hideNoFlightMode && hasUsedMode; + for (let i = 0; i < FC.AUX_CONFIG.length; i++) { + let modeElement = $(`#mode-${i}`); + if (modeElement.find(' .range').length == 0 && modeElement.find(' .link').length == 0) { + // unused mode + modeElement.toggle(!hideUnused); } - } + if( ! isFlightMode(FC.AUX_CONFIG[i])) { + // not flightMode mode + modeElement.toggle(!hideNoFlight); + } + } auto_select_channel(FC.RC.channels, FC.RC.active_channels, FC.RSSI_CONFIG.channel); @@ -548,7 +562,10 @@ auxiliary.initialize = function (callback) { } let hideUnusedModes = false; - const result = getConfig('hideUnusedModes'); + let hideNoFlightMode = false; + + // hide unused modes + const configUnusedModes = getConfig('hideUnusedModes'); $("input#switch-toggle-unused") .change(function() { hideUnusedModes = $(this).prop("checked"); @@ -556,7 +573,18 @@ auxiliary.initialize = function (callback) { setConfig({ hideUnusedModes: hideUnusedModes }); update_ui(); }) - .prop("checked", !!result.hideUnusedModes) + .prop("checked", !!configUnusedModes.hideUnusedModes) + .change(); + + // hide non flightmodes + const configNoFlightMode = getConfig('hideNoFlightMode'); + $("input#switch-toggle-hideNoFlightMode") + .change(function() { + hideNoFlightMode = $(this).prop("checked"); + setConfig({ hideNoFlightMode: hideNoFlightMode }); + update_ui(); + }) + .prop("checked", !!configNoFlightMode.hideNoFlightMode) .change(); // update ui instantly on first load diff --git a/src/tabs/auxiliary.html b/src/tabs/auxiliary.html index 260208f034..dc40fb6434 100644 --- a/src/tabs/auxiliary.html +++ b/src/tabs/auxiliary.html @@ -13,6 +13,10 @@ +
+ + +
From 6a74af74166208154bfcd282405de1659f252711 Mon Sep 17 00:00:00 2001 From: HThuren Date: Sun, 17 Sep 2023 12:44:50 +0200 Subject: [PATCH 02/32] Fix code smell --- src/js/tabs/auxiliary.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index 46bdf4d523..4baa53e0a3 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -51,8 +51,8 @@ auxiliary.initialize = function (callback) { } function isFlightMode(name) { - for (let i = 0; i < flightModes.length; i++) { - if (name == flightModes[i]) { + for (let value of flightModes) { + if (name == value) { return true; } } @@ -469,7 +469,7 @@ auxiliary.initialize = function (callback) { } } else { - //ARM mode is a special case + // ARM mode is a special case if (i == 0) { let armSwitchActive = false; @@ -550,12 +550,14 @@ auxiliary.initialize = function (callback) { return (x > y) ? x : y; }, 0); - //minimum change to autoselect is 100 - if (largest < 100) return fillPrevChannelsValues(); + // minimum change to autoselect is 100 + if (largest < 100) { + return fillPrevChannelsValues(); + } const indexOfMaxValue = diff_array.indexOf(largest); - if (indexOfMaxValue >= 4 && indexOfMaxValue != RSSI_channel - 1){ //set channel - auto_option.parent().val(indexOfMaxValue - 4); + if (indexOfMaxValue >= 4 && indexOfMaxValue != RSSI_channel - 1) { + auto_option.parent().val(indexOfMaxValue - 4); //set channel } return fillPrevChannelsValues(); From 2e4863d71d3a38144d4b1899d2d583c822ca606d Mon Sep 17 00:00:00 2001 From: HThuren Date: Wed, 20 Sep 2023 14:56:45 +0200 Subject: [PATCH 03/32] Test --- src/js/tabs/auxiliary.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index 4baa53e0a3..371686b773 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -510,7 +510,7 @@ auxiliary.initialize = function (callback) { // not flightMode mode modeElement.toggle(!hideNoFlight); } - } + } auto_select_channel(FC.RC.channels, FC.RC.active_channels, FC.RSSI_CONFIG.channel); From 9d1e0ccf4c06dcfba46a14d9eb48d29814c1c71f Mon Sep 17 00:00:00 2001 From: HThuren Date: Thu, 21 Sep 2023 07:28:18 +0200 Subject: [PATCH 04/32] Simplification --- src/js/tabs/auxiliary.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index 371686b773..cad45ee274 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -51,12 +51,7 @@ auxiliary.initialize = function (callback) { } function isFlightMode(name) { - for (let value of flightModes) { - if (name == value) { - return true; - } - } - return false; + return flightModes.includes(name); } MSP.send_message(MSPCodes.MSP_BOXNAMES, false, false, get_mode_ranges); From 04277f6216cf02999f80faefd36c37bee0e69267 Mon Sep 17 00:00:00 2001 From: HThuren Date: Tue, 10 Oct 2023 06:49:34 +0200 Subject: [PATCH 05/32] Resolved --- src/js/tabs/auxiliary.js | 22 ++++++++++++++++++---- src/tabs/auxiliary.html | 8 ++++---- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index cad45ee274..6ad4590d9f 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -14,7 +14,7 @@ import inflection from "inflection"; const auxiliary = {}; const flightModes = ["ARM","ANGLE","HORIZON","ANTI GRAVITY","MAG","HEADFREE","HEADADJ","SERVO1","SERVO2","SERVO3", -"FAILSAFE","AIR MODE","3D","FPV ANGLE MIX","FLIP OVER AFTER CRASH","USER1","USER2","USER3","USER4","ACRO TRAINER","LAUNCH CONTROL"]; + "FAILSAFE","AIR MODE","3D","FPV ANGLE MIX","FLIP OVER AFTER CRASH","USER1","USER2","USER3","USER4","ACRO TRAINER","LAUNCH CONTROL"]; auxiliary.initialize = function (callback) { GUI.active_tab_ref = this; @@ -492,21 +492,35 @@ auxiliary.initialize = function (callback) { } hasUsedMode = true; } - + /* let hideUnused = hideUnusedModes && hasUsedMode; - let hideNoFlight = hideNoFlightMode && hasUsedMode; + // let hideNoFlight = hideNoFlightMode && hasUsedMode; for (let i = 0; i < FC.AUX_CONFIG.length; i++) { + let modeElement = $(`#mode-${i}`); + if (modeElement.find(' .range').length == 0 && modeElement.find(' .link').length == 0) { + // unused mode + modeElement.toggle( ! hideUnused); + } + if( isFlightMode(FC.AUX_CONFIG[i])) { + // not flightMode + modeElement.toggle( ! (hideNoFlightMode && hideUnused)); + } + } + */ + let hideUnused = hideUnusedModes && hasUsedMode; + let hideNoFlight = hideNoFlightMode && hasUsedMode; + for (let i = 1; i < FC.AUX_CONFIG.length; i++) { // ARM has index 0 let modeElement = $(`#mode-${i}`); if (modeElement.find(' .range').length == 0 && modeElement.find(' .link').length == 0) { // unused mode modeElement.toggle(!hideUnused); } + if( ! isFlightMode(FC.AUX_CONFIG[i])) { // not flightMode mode modeElement.toggle(!hideNoFlight); } } - auto_select_channel(FC.RC.channels, FC.RC.active_channels, FC.RSSI_CONFIG.channel); auxChannelCount = FC.RC.active_channels - 4; diff --git a/src/tabs/auxiliary.html b/src/tabs/auxiliary.html index dc40fb6434..25513d9c2d 100644 --- a/src/tabs/auxiliary.html +++ b/src/tabs/auxiliary.html @@ -9,14 +9,14 @@
-
- - -
+
+ + +
From ced6a31a527dc94c61e48c6620e9b0ef08e04b5b Mon Sep 17 00:00:00 2001 From: HThuren Date: Tue, 10 Oct 2023 06:50:42 +0200 Subject: [PATCH 06/32] Resolved --- src/js/tabs/auxiliary.js | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index 6ad4590d9f..761848a5fe 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -492,21 +492,7 @@ auxiliary.initialize = function (callback) { } hasUsedMode = true; } - /* - let hideUnused = hideUnusedModes && hasUsedMode; - // let hideNoFlight = hideNoFlightMode && hasUsedMode; - for (let i = 0; i < FC.AUX_CONFIG.length; i++) { - let modeElement = $(`#mode-${i}`); - if (modeElement.find(' .range').length == 0 && modeElement.find(' .link').length == 0) { - // unused mode - modeElement.toggle( ! hideUnused); - } - if( isFlightMode(FC.AUX_CONFIG[i])) { - // not flightMode - modeElement.toggle( ! (hideNoFlightMode && hideUnused)); - } - } - */ + let hideUnused = hideUnusedModes && hasUsedMode; let hideNoFlight = hideNoFlightMode && hasUsedMode; for (let i = 1; i < FC.AUX_CONFIG.length; i++) { // ARM has index 0 @@ -516,11 +502,12 @@ auxiliary.initialize = function (callback) { modeElement.toggle(!hideUnused); } - if( ! isFlightMode(FC.AUX_CONFIG[i])) { + if ( ! isFlightMode(FC.AUX_CONFIG[i])) { // not flightMode mode modeElement.toggle(!hideNoFlight); } } + auto_select_channel(FC.RC.channels, FC.RC.active_channels, FC.RSSI_CONFIG.channel); auxChannelCount = FC.RC.active_channels - 4; From 6a3fd3f59847ead8c4801ccd5dd6167c2ad3f1e2 Mon Sep 17 00:00:00 2001 From: HThuren Date: Sun, 12 Nov 2023 15:28:23 +0100 Subject: [PATCH 07/32] rebase --- src/js/tabs/auxiliary.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index 761848a5fe..34466d939f 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -495,16 +495,38 @@ auxiliary.initialize = function (callback) { let hideUnused = hideUnusedModes && hasUsedMode; let hideNoFlight = hideNoFlightMode && hasUsedMode; + console.log(`0 hideUnusedModes: ${hideUnusedModes}, hideNoFlightMode: ${hideNoFlightMode}`); + console.log(`0 hasUsedMode: ${hasUsedMode}, hideUnused: ${hideUnused}, hideNoFlight: ${hideNoFlight}`); + for (let i = 1; i < FC.AUX_CONFIG.length; i++) { // ARM has index 0 let modeElement = $(`#mode-${i}`); + let style = modeElement.css('display'); + if (modeElement.find(' .range').length == 0 && modeElement.find(' .link').length == 0) { // unused mode + style = modeElement.css('display'); + console.log(`1 HIDE: ${FC.AUX_CONFIG[i]} ${style}`); + modeElement.toggle(!hideUnused); + + style = modeElement.css('display'); + console.log(`2 HIDE: ${FC.AUX_CONFIG[i]} ${style}`); } if ( ! isFlightMode(FC.AUX_CONFIG[i])) { // not flightMode mode - modeElement.toggle(!hideNoFlight); + style = modeElement.css('display'); + console.log(`1 NOT flightmode: ${FC.AUX_CONFIG[i]} - ${hideNoFlight} - ${style}`); + // modeElement.toggle(!hideNoFlight); + if( hideNoFlight && ! style === 'none') { + modeElement.toggle(!hideUnused); + } + style = modeElement.css('display'); + console.log(`2 NOT flightmode: ${FC.AUX_CONFIG[i]} - ${hideNoFlight} - ${style}`); + } + else { + style = modeElement.css('display'); + console.log(`Flightmode: ${FC.AUX_CONFIG[i]} - ${style}`); } } From ee28800304253b5e7dcc928d4d36817cb4b360c0 Mon Sep 17 00:00:00 2001 From: HThuren Date: Mon, 20 Nov 2023 07:52:13 +0100 Subject: [PATCH 08/32] Change to category --- src/js/tabs/auxiliary.js | 68 ++++++++++++++++++++++++++++++---------- src/tabs/auxiliary.html | 17 +++++++--- 2 files changed, 65 insertions(+), 20 deletions(-) diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index 34466d939f..a0d11dbac0 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -1,5 +1,5 @@ import { i18n } from '../localization'; -import GUI from '../gui'; +import GUI, { TABS } from '../../js/gui'; import { get as getConfig, set as setConfig } from '../ConfigStorage'; import { bit_check } from '../bit'; import { mspHelper } from '../msp/MSPHelper'; @@ -16,12 +16,52 @@ const auxiliary = {}; const flightModes = ["ARM","ANGLE","HORIZON","ANTI GRAVITY","MAG","HEADFREE","HEADADJ","SERVO1","SERVO2","SERVO3", "FAILSAFE","AIR MODE","3D","FPV ANGLE MIX","FLIP OVER AFTER CRASH","USER1","USER2","USER3","USER4","ACRO TRAINER","LAUNCH CONTROL"]; +// Categories +let categoryTable = createTable([ + ['3D', '3D DISABLE / SWITCH'], + ['BEEP', 'BEEPER', 'BEEPER MUTE', 'GPS BEEP SATELLITE COUNT'], + ['BLACKBOX', 'BLACKBOX', 'BLACKBOX ERASE'], + ['CAM', 'CAMERA CONTROL 1', 'CAMERA CONTROL 2', 'CAMERA CONTROL 3'], + ['FLIGHTMODE', 'ARM','ANGLE','HORIZON','ANTI GRAVITY','MAG','HEADFREE','HEADADJ','SERVO1','SERVO2','SERVO3', + 'FAILSAFE','AIR MODE','3D','FPV ANGLE MIX','FLIP OVER AFTER CRASH','USER1','USER2','USER3','USER4','ACRO TRAINER','LAUNCH CONTROL'], + ['GPS', 'GPS BEEP SATELLITE COUNT', 'GPS RESCUE'], + ['LED', 'LEDLOW'], + ['OSD', 'OSD DISABLE'], + ['OTHER', 'CALIB', 'MSP OVERRIDE', 'LAP TIMER RESET', 'PASSTHRU', 'PARALYZE', 'PID AUDIO', 'PREARM', 'TELEMETRY'], + ['SERVO', 'SERVO1', 'SERVO2', 'SERVO3'], + ['USER', 'USER1', 'USER2', 'USER3', 'USER4'], + ['VTX', 'STICK COMMANDS DISABLE', 'VTX CONTROL DISABLE', 'VTX PIT MODE'], +]); + +const categoryFieldsSelect = $(".auxiliary_filter_category select"); + +function createTable(data) { + // Create a dynamic table with fixed values + let table = []; + + for (let i = 0; i < data.length; i++) { + let row = data[i].slice(); // Use slice to clone the array + table.push(row); + } + + return table; +} + +// Function to display the table in the console +function displayTable(table) { + for (let i = 0; i < table.length; i++) { + console.log(table[i].join('\t')); + } +} + auxiliary.initialize = function (callback) { GUI.active_tab_ref = this; GUI.active_tab = 'auxiliary'; let prevChannelsValues = null; let hasDirtyUnusedModes = true; + this._selectCategory = $('#auxiliary_filter_category'); + function get_mode_ranges() { MSP.send_message(MSPCodes.MSP_MODE_RANGES, false, false, get_mode_ranges_extra); } @@ -312,6 +352,10 @@ auxiliary.initialize = function (callback) { // translate to user-selected language i18n.localizePage(); + //categoryFieldsSelect + + // generate category multiple select + displayTable(categoryTable); const length = Math.max(...(FC.AUX_CONFIG.map(el => el.length))); $('.tab-auxiliary .mode .info').css('min-width', `${Math.round(length * getTextWidth('A'))}px`); @@ -495,39 +539,31 @@ auxiliary.initialize = function (callback) { let hideUnused = hideUnusedModes && hasUsedMode; let hideNoFlight = hideNoFlightMode && hasUsedMode; - console.log(`0 hideUnusedModes: ${hideUnusedModes}, hideNoFlightMode: ${hideNoFlightMode}`); - console.log(`0 hasUsedMode: ${hasUsedMode}, hideUnused: ${hideUnused}, hideNoFlight: ${hideNoFlight}`); for (let i = 1; i < FC.AUX_CONFIG.length; i++) { // ARM has index 0 let modeElement = $(`#mode-${i}`); - let style = modeElement.css('display'); if (modeElement.find(' .range').length == 0 && modeElement.find(' .link').length == 0) { // unused mode - style = modeElement.css('display'); - console.log(`1 HIDE: ${FC.AUX_CONFIG[i]} ${style}`); - modeElement.toggle(!hideUnused); - - style = modeElement.css('display'); - console.log(`2 HIDE: ${FC.AUX_CONFIG[i]} ${style}`); } + /* if ( ! isFlightMode(FC.AUX_CONFIG[i])) { // not flightMode mode + hide = hide || !hideNoFlight; style = modeElement.css('display'); - console.log(`1 NOT flightmode: ${FC.AUX_CONFIG[i]} - ${hideNoFlight} - ${style}`); + console.log(`1 HIDE not flightmode: ${FC.AUX_CONFIG[i]} -> ${hide}`); // modeElement.toggle(!hideNoFlight); + / * if( hideNoFlight && ! style === 'none') { modeElement.toggle(!hideUnused); } style = modeElement.css('display'); - console.log(`2 NOT flightmode: ${FC.AUX_CONFIG[i]} - ${hideNoFlight} - ${style}`); - } - else { - style = modeElement.css('display'); - console.log(`Flightmode: ${FC.AUX_CONFIG[i]} - ${style}`); + console.log(`2 NOT flightmode: ${FC.AUX_CONFIG[i]} - ${style}`); + * / } + */ } auto_select_channel(FC.RC.channels, FC.RC.active_channels, FC.RSSI_CONFIG.channel); diff --git a/src/tabs/auxiliary.html b/src/tabs/auxiliary.html index 25513d9c2d..77df3fd256 100644 --- a/src/tabs/auxiliary.html +++ b/src/tabs/auxiliary.html @@ -8,11 +8,20 @@

+
+
+
+
+
+
+ +
+
+
+
+
+
-
- - -
From 6a1b8b53865c48883dd7b933f065703bc5b451af Mon Sep 17 00:00:00 2001 From: HThuren Date: Tue, 28 Nov 2023 18:30:05 +0100 Subject: [PATCH 09/32] BuildOptions --- locales/en/messages.json | 13 ++--- src/js/tabs/auxiliary.js | 112 ++++++++++++++++++++++++++++++--------- src/tabs/auxiliary.html | 2 +- 3 files changed, 92 insertions(+), 35 deletions(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index 184b55c519..98065885c8 100755 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -366,21 +366,18 @@ "tabAuxiliary": { "message": "Modes" }, - "logActionHide": { "message": "Hide Log" }, "logActionShow": { "message": "Show Log" }, - "serialErrorFrameError": { "message": "Serial connection error: bad framing" }, "serialErrorParityError": { "message": "Serial connection error: bad parity" }, - "serialPortOpened": { "message": "Serial port successfully opened with ID: $1" }, @@ -2314,9 +2311,9 @@ "auxiliaryToggleUnused": { "message": "Hide unused modes" }, - "auxiliaryToggleNoFlightMode": { - "message": "Show only flight modes", - "descripton": "Toggle if all modes are shown or only Flight modes" + "auxiliaryFilterCategory": { + "message": "Category", + "descripton": "Category for Flight modes" }, "auxiliaryMin": { "message": "Min" @@ -2466,7 +2463,7 @@ "message": "Enable MSP Override mode", "description": "Help text to MSP OVERRIDE mode" }, - "auxiliaryHelpMode_OSDDISABLE": { + "auxiliaryHelpMode_OSD": { "message": "Enable/Disable On-Screen-Display", "description": "Help text to OSD mode" }, @@ -2526,7 +2523,7 @@ "message": "Use to toggle customized USER4. Controls arbitrary output via PINIO", "description": "Help text to customized USER4 mode" }, - "auxiliaryHelpMode_VTXCONTROLDISABLE": { + "auxiliaryHelpMode_DISABLEVTXCONTROL": { "message": "Disable the control of VTX settings through the OSD", "description": "Help text to VTX CONTROL DISABLE mode" }, diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index a0d11dbac0..8ee947d541 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -13,34 +13,50 @@ import inflection from "inflection"; const auxiliary = {}; +// BF build Options mapped to build Key +let buildMap = [ + { buildKey: 'xxx', buildOption: ['USE_ARCO_TRAINER', 'USE_DASHBOARD', 'USE_PINIO']}, + { buildKey: 'cam', buildOption: ['USE_CAMERA_CONTROL']}, + { buildKey: 'dshot', buildOption: ['USE_DSHOT']}, + { buildKey: 'gps', buildOption: ['USE_GPS', 'USE_GPS_PLUS_CODES']}, + { buildKey: 'led_strip', buildOption: ['USE_LED_STRIP', 'USE_LED_STRIP_64']}, + { buildKey: 'mag', buildOption: ['USE_MAG']}, + { buildKey: 'osd', buildOption: ['USE_OSD', 'USE_OSD_SD', 'USE_OSD_HD', 'USE_FRSKYOSD']}, + { buildKey: 'serial', buildOption: ['USE_SERIALRX', 'USE_SERIALRX_FPORT']}, + { buildKey: 'servos', buildOption: ['USE_SERVOS']}, + { buildKey: 'telemetry', buildOption: ['USE_TELEMETRY', 'USE_TELEMETRY_SMARTPORT']}, + { buildKey: 'vtx', buildOption: ['USE_VTX']}, +]; + const flightModes = ["ARM","ANGLE","HORIZON","ANTI GRAVITY","MAG","HEADFREE","HEADADJ","SERVO1","SERVO2","SERVO3", - "FAILSAFE","AIR MODE","3D","FPV ANGLE MIX","FLIP OVER AFTER CRASH","USER1","USER2","USER3","USER4","ACRO TRAINER","LAUNCH CONTROL"]; + "FAILSAFE","AIR MODE","FPV ANGLE MIX","FLIP OVER AFTER CRASH","USER1","USER2","USER3","USER4","ACRO TRAINER","LAUNCH CONTROL"]; // Categories -let categoryTable = createTable([ - ['3D', '3D DISABLE / SWITCH'], - ['BEEP', 'BEEPER', 'BEEPER MUTE', 'GPS BEEP SATELLITE COUNT'], - ['BLACKBOX', 'BLACKBOX', 'BLACKBOX ERASE'], - ['CAM', 'CAMERA CONTROL 1', 'CAMERA CONTROL 2', 'CAMERA CONTROL 3'], - ['FLIGHTMODE', 'ARM','ANGLE','HORIZON','ANTI GRAVITY','MAG','HEADFREE','HEADADJ','SERVO1','SERVO2','SERVO3', - 'FAILSAFE','AIR MODE','3D','FPV ANGLE MIX','FLIP OVER AFTER CRASH','USER1','USER2','USER3','USER4','ACRO TRAINER','LAUNCH CONTROL'], - ['GPS', 'GPS BEEP SATELLITE COUNT', 'GPS RESCUE'], - ['LED', 'LEDLOW'], - ['OSD', 'OSD DISABLE'], - ['OTHER', 'CALIB', 'MSP OVERRIDE', 'LAP TIMER RESET', 'PASSTHRU', 'PARALYZE', 'PID AUDIO', 'PREARM', 'TELEMETRY'], - ['SERVO', 'SERVO1', 'SERVO2', 'SERVO3'], - ['USER', 'USER1', 'USER2', 'USER3', 'USER4'], - ['VTX', 'STICK COMMANDS DISABLE', 'VTX CONTROL DISABLE', 'VTX PIT MODE'], -]); - -const categoryFieldsSelect = $(".auxiliary_filter_category select"); +let categoryTable = [ + { name: '3D', buildKey: ['dshot'], modes: ['3D', '3D DISABLE / SWITCH']}, + { name: 'BEEP', buildKey: ['all'], modes: ['BEEPER', 'BEEPER MUTE', 'GPS BEEP SATELLITE COUNT']}, + { name: 'BLACKBOX', buildKey: ['all'], modes: ['BLACKBOX', 'BLACKBOX ERASE']}, + { name: 'CAM', buildKey: ['cam'], modes: ['CAMERA CONTROL 1', 'CAMERA CONTROL 2', 'CAMERA CONTROL 3']}, + { name: 'FLIGHTMODE', buildKey: ['all'], modes: flightModes}, + { name: 'GPS', buildKey: ['gps'], modes: ['GPS BEEP SATELLITE COUNT', 'GPS RESCUE']}, + { name: 'LED', buildKey: ['led_strip'], modes: ['LEDLOW']}, + { name: 'OSD', buildKey: ['osd'], modes: ['OSD DISABLE']}, + { name: 'OTHER', buildKey: ['all'], modes: ['CALIB', 'MSP OVERRIDE', 'LAP TIMER RESET', 'PASSTHRU', 'PARALYZE', 'PID AUDIO', 'PREARM']}, + { name: 'SERVO', buildKey: ['servos'], modes: ['SERVO1', 'SERVO2', 'SERVO3']}, + { name: 'TELEMETRI', buildKey: ['telemetry'], modes: ['TELEMETRY']}, + { name: 'USER', buildKey: ['all'], modes: ['USER1', 'USER2', 'USER3', 'USER4']}, + { name: 'VTX', buildKey: ['vtx'], modes: ['STICK COMMANDS DISABLE', 'VTX CONTROL DISABLE', 'VTX PIT MODE']}, +]; + + +const categoryFieldsSelect = $('.auxiliary_category'); function createTable(data) { // Create a dynamic table with fixed values let table = []; for (let i = 0; i < data.length; i++) { - let row = data[i].slice(); // Use slice to clone the array + let row = data[i].modes.slice(); // Use slice to clone the array table.push(row); } @@ -50,18 +66,65 @@ function createTable(data) { // Function to display the table in the console function displayTable(table) { for (let i = 0; i < table.length; i++) { - console.log(table[i].join('\t')); + console.log(`${table[i].name}: ${table[i].modes}`); + } +} + +// Function to simulate mouseover and select an option +function simulateMouseoverAndSelectOption(selectElement, optionIndex) { + // Trigger mouseover event + const mouseoverEvent = new Event('mouseover'); + selectElement.dispatchEvent(mouseoverEvent); + + // Select the specified option + selectElement.selectedIndex = optionIndex; + + // Trigger change event to notify any listeners + const changeEvent = new Event('change'); + selectElement.dispatchEvent(changeEvent); +} + +// Function to iterate over options and simulate mouseover and selection +function simulateMouseoverAndSelectForEachOption() { + // Get the select element + const selectElement = document.getElementById('yourSelectElementId'); // Replace with your actual select element ID + + // Iterate over each option and simulate mouseover and selection + for (let i = 0; i < selectElement.options.length; i++) { + simulateMouseoverAndSelectOption(selectElement, i); + // You can add a delay here if needed + // setTimeout(() => { + // simulateMouseoverAndSelectOption(selectElement, i); + // }, 1000 * i); // Adjust the delay as needed + } +} + +// Call the function when needed +//simulateMouseoverAndSelectForEachOption(); +/* +Replace 'yourSelectElementId' with the actual ID of your select element. +The simulateMouseoverAndSelectForEachOption function iterates over each option in the select element, simulates a mouseover, and selects the option. +You can also add a delay between each iteration if needed (commented out in the code). Adjust the delay according to your requirements. +*/ + +function createCategorySelect(table) { + for (let i = 0; i < table.length; i++) { + const str = ``; + $('#auxiliary_filter_category .select').append(``); + console.log(str); } } +function isFlightMode(name) { + return flightModes.includes(name); +} + auxiliary.initialize = function (callback) { GUI.active_tab_ref = this; GUI.active_tab = 'auxiliary'; let prevChannelsValues = null; let hasDirtyUnusedModes = true; - this._selectCategory = $('#auxiliary_filter_category'); - function get_mode_ranges() { MSP.send_message(MSPCodes.MSP_MODE_RANGES, false, false, get_mode_ranges_extra); } @@ -90,10 +153,6 @@ auxiliary.initialize = function (callback) { $('#content').load("./tabs/auxiliary.html", process_html); } - function isFlightMode(name) { - return flightModes.includes(name); - } - MSP.send_message(MSPCodes.MSP_BOXNAMES, false, false, get_mode_ranges); function createMode(modeIndex, modeId) { @@ -356,6 +415,7 @@ auxiliary.initialize = function (callback) { // generate category multiple select displayTable(categoryTable); + createCategorySelect(categoryTable); const length = Math.max(...(FC.AUX_CONFIG.map(el => el.length))); $('.tab-auxiliary .mode .info').css('min-width', `${Math.round(length * getTextWidth('A'))}px`); diff --git a/src/tabs/auxiliary.html b/src/tabs/auxiliary.html index 77df3fd256..d100603dd0 100644 --- a/src/tabs/auxiliary.html +++ b/src/tabs/auxiliary.html @@ -14,7 +14,7 @@
- +
From 6d4a59f1defe50793a1f146f6a3d59d23a4b8bde Mon Sep 17 00:00:00 2001 From: HThuren Date: Wed, 29 Nov 2023 18:10:05 +0100 Subject: [PATCH 10/32] BuildOptions --- src/js/tabs/auxiliary.js | 28 +++++++++++++++++---------- src/tabs/auxiliary.html | 42 ++++++++++++++++++++++++---------------- 2 files changed, 43 insertions(+), 27 deletions(-) diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index 8ee947d541..3d505cad89 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -15,8 +15,8 @@ const auxiliary = {}; // BF build Options mapped to build Key let buildMap = [ - { buildKey: 'xxx', buildOption: ['USE_ARCO_TRAINER', 'USE_DASHBOARD', 'USE_PINIO']}, { buildKey: 'cam', buildOption: ['USE_CAMERA_CONTROL']}, + { buildKey: 'div', buildOption: ['USE_ARCO_TRAINER', 'USE_DASHBOARD', 'USE_PINIO']}, { buildKey: 'dshot', buildOption: ['USE_DSHOT']}, { buildKey: 'gps', buildOption: ['USE_GPS', 'USE_GPS_PLUS_CODES']}, { buildKey: 'led_strip', buildOption: ['USE_LED_STRIP', 'USE_LED_STRIP_64']}, @@ -48,9 +48,6 @@ let categoryTable = [ { name: 'VTX', buildKey: ['vtx'], modes: ['STICK COMMANDS DISABLE', 'VTX CONTROL DISABLE', 'VTX PIT MODE']}, ]; - -const categoryFieldsSelect = $('.auxiliary_category'); - function createTable(data) { // Create a dynamic table with fixed values let table = []; @@ -107,11 +104,13 @@ The simulateMouseoverAndSelectForEachOption function iterates over each option i You can also add a delay between each iteration if needed (commented out in the code). Adjust the delay according to your requirements. */ -function createCategorySelect(table) { - for (let i = 0; i < table.length; i++) { - const str = ``; - $('#auxiliary_filter_category .select').append(``); - console.log(str); +function isInBuildKey(map, name) { + + if(name === 'all') { + return true; + } + for (let i = 0; i < map.length; i++) { + return flightModes.includes(name); } } @@ -119,6 +118,16 @@ function isFlightMode(name) { return flightModes.includes(name); } +function createCategorySelect(table) { + let categorySelect = $('select.auxiliary_category_select'); + + for (let i = 0; i < table.length; i++) { + if (isInBuildKey(buildMap, table[i].buildKey)) { + categorySelect.append(``); + } + } +} + auxiliary.initialize = function (callback) { GUI.active_tab_ref = this; GUI.active_tab = 'auxiliary'; @@ -411,7 +420,6 @@ auxiliary.initialize = function (callback) { // translate to user-selected language i18n.localizePage(); - //categoryFieldsSelect // generate category multiple select displayTable(categoryTable); diff --git a/src/tabs/auxiliary.html b/src/tabs/auxiliary.html index d100603dd0..af1046f87a 100644 --- a/src/tabs/auxiliary.html +++ b/src/tabs/auxiliary.html @@ -8,25 +8,33 @@

-
-
-
-
-
-
- + + + + + + +
+
+
+
+
+
+
+ +
+
+
- - - - -
- - - - -
+
  +
+
+ + +
+
+
From 58f63babd48cea2c95314ffd7af5764ec04e215b Mon Sep 17 00:00:00 2001 From: HThuren Date: Thu, 30 Nov 2023 17:37:57 +0100 Subject: [PATCH 11/32] More build --- src/js/tabs/auxiliary.js | 49 +++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index 3d505cad89..d2bfb54616 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -48,6 +48,32 @@ let categoryTable = [ { name: 'VTX', buildKey: ['vtx'], modes: ['STICK COMMANDS DISABLE', 'VTX CONTROL DISABLE', 'VTX PIT MODE']}, ]; +function isInBuildKey(map, name) { + if (name === 'all') { + return true; + } + for (let i = 0; i < map.length; i++) { + if (name == map[i].buildKey) { + return FC.CONFIG.buildOptions.includes(map[i].buildOption); + } + } + return false; +} + +function isFlightMode(name) { + return flightModes.includes(name); +} + +function createCategorySelect(table) { + let categorySelect = $('select.auxiliary_category_select'); + + for (let i = 0; i < table.length; i++) { + if (isInBuildKey(buildMap, table[i].buildKey)) { + categorySelect.append(``); + } + } +} + function createTable(data) { // Create a dynamic table with fixed values let table = []; @@ -104,29 +130,6 @@ The simulateMouseoverAndSelectForEachOption function iterates over each option i You can also add a delay between each iteration if needed (commented out in the code). Adjust the delay according to your requirements. */ -function isInBuildKey(map, name) { - - if(name === 'all') { - return true; - } - for (let i = 0; i < map.length; i++) { - return flightModes.includes(name); - } -} - -function isFlightMode(name) { - return flightModes.includes(name); -} - -function createCategorySelect(table) { - let categorySelect = $('select.auxiliary_category_select'); - - for (let i = 0; i < table.length; i++) { - if (isInBuildKey(buildMap, table[i].buildKey)) { - categorySelect.append(``); - } - } -} auxiliary.initialize = function (callback) { GUI.active_tab_ref = this; From 4c0271155e0e394e3bebb6f30a2ca4a7d34bd8b9 Mon Sep 17 00:00:00 2001 From: HThuren Date: Fri, 1 Dec 2023 19:11:29 +0100 Subject: [PATCH 12/32] multiselect --- src/js/tabs/auxiliary.js | 25 +++++++++++++++++++------ src/tabs/auxiliary.html | 2 +- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index d2bfb54616..3efc0eeadb 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -49,21 +49,21 @@ let categoryTable = [ ]; function isInBuildKey(map, name) { - if (name === 'all') { + if (name == 'all') { return true; } for (let i = 0; i < map.length; i++) { if (name == map[i].buildKey) { - return FC.CONFIG.buildOptions.includes(map[i].buildOption); + for (let y = 0; y < map[i].buildOption.length; y++) { + if (FC.CONFIG.buildOptions.includes(map[i].buildOption[y])) { + return true; + } + } } } return false; } -function isFlightMode(name) { - return flightModes.includes(name); -} - function createCategorySelect(table) { let categorySelect = $('select.auxiliary_category_select'); @@ -72,6 +72,19 @@ function createCategorySelect(table) { categorySelect.append(``); } } + + categorySelect.multipleSelect({ + filter: true, + // locale: selectOptions, + showClear: true, + // minimumCountSelected : minimumCountSelected, + placeholder: i18n.getMessage("dropDownFilterDisabled"), + // onClick: () => { this.updateSearchResults(); }, + // onCheckAll: () => { this.updateSearchResults(); }, + // onUncheckAll: () => { this.updateSearchResults(); }, + formatSelectAll() { return i18n.getMessage("dropDownSelectAll"); }, + formatAllSelected() { return i18n.getMessage("dropDownAll"); }, + }); } function createTable(data) { diff --git a/src/tabs/auxiliary.html b/src/tabs/auxiliary.html index af1046f87a..955aa44a82 100644 --- a/src/tabs/auxiliary.html +++ b/src/tabs/auxiliary.html @@ -24,7 +24,7 @@
-   +    
From 9cff705c6c639a8621198fee904ba3a42db5b6d6 Mon Sep 17 00:00:00 2001 From: HThuren Date: Mon, 11 Dec 2023 01:19:00 +0100 Subject: [PATCH 13/32] more to go --- src/css/tabs/auxiliary.less | 14 +++ src/js/localization.js | 21 ++++- src/js/tabs/auxiliary.js | 167 +++++++++++++++++++++--------------- src/main.html | 1 + src/tabs/auxiliary.html | 22 ++--- 5 files changed, 141 insertions(+), 84 deletions(-) diff --git a/src/css/tabs/auxiliary.less b/src/css/tabs/auxiliary.less index c00095e646..28b6d53a24 100644 --- a/src/css/tabs/auxiliary.less +++ b/src/css/tabs/auxiliary.less @@ -11,6 +11,20 @@ color: rgb(105, 99, 99); padding: 10px 5px; } + .auxiliary_category_content { + width: 100%; + } + .auxiliary_category_header { + width: 100%; + margin-top: 6px; + padding: 4px; + padding-left: 8px; + padding-right: 8px; + color: white; + border: 1px solid var(--subtleAccent); + background-color: rgba(64, 64, 64, 1); + resize: none; + } .range { .marker { background: var(--accent); diff --git a/src/js/localization.js b/src/js/localization.js index 34d24935a5..a0d3057613 100644 --- a/src/js/localization.js +++ b/src/js/localization.js @@ -11,7 +11,8 @@ const i18n = {}; window.i18n = i18n; -const languagesAvailables = ['ca', 'da', 'de', 'en', 'es', 'eu', 'fr', 'gl', 'it', 'ja', 'ko', 'nl', 'pt', 'pt_BR', 'pl', 'ru', 'uk', 'zh_CN', 'zh_TW']; +const languagesAvailables = ['ca', 'da', 'de', 'en', 'es', 'eu', 'fr', 'gl', 'it', + 'ja', 'ko', 'nl', 'pt', 'pt_BR', 'pl', 'ru', 'uk', 'zh_CN', 'zh_TW']; const languageFallback = { 'pt': ['pt_BR', 'en'], @@ -19,6 +20,22 @@ const languageFallback = { 'default': ['en'], }; +// must be aligned with languagesAvailables +const languageISOcode = ['ca-ES', 'da-DK', 'de-DE', 'en-US', 'es-ES', 'eu-ES', 'fr-FR', 'gl-ES', 'it-IT', + 'ja-JP', 'ko-KR', 'nl-NL', 'pt-PT', 'pt-BR', 'pl-PL', 'ru-RU', 'uk-UA', 'zh-CN', 'zh-TW']; + +/** + * Functions that return ISO Language Code Table from http://www.lingoes.net/en/translator/langcode.htm + * Map between languagesAvailables and languageISOcode + * Fallback to en-US + */ +function getCurrentLocaleISO() { + const isoCodeIndex = languagesAvailables.indexOf(i18next.language); + if (isoCodeIndex === -1) + return 'en-US'; + return languageISOcode[isoCodeIndex]; +} + /** * Functions that depend on the i18n framework */ @@ -238,4 +255,4 @@ i18n.addResources = function(bundle) { i18next.addResourceBundle(lang, ns, bundle, true, true); }; -export { i18n }; +export { i18n, getCurrentLocaleISO }; diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index 3efc0eeadb..729eb795b1 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -1,4 +1,4 @@ -import { i18n } from '../localization'; +import { i18n, getCurrentLocaleISO } from "../localization"; import GUI, { TABS } from '../../js/gui'; import { get as getConfig, set as setConfig } from '../ConfigStorage'; import { bit_check } from '../bit'; @@ -13,7 +13,7 @@ import inflection from "inflection"; const auxiliary = {}; -// BF build Options mapped to build Key +// BF build Options mapped to buildKey. let buildMap = [ { buildKey: 'cam', buildOption: ['USE_CAMERA_CONTROL']}, { buildKey: 'div', buildOption: ['USE_ARCO_TRAINER', 'USE_DASHBOARD', 'USE_PINIO']}, @@ -31,10 +31,10 @@ let buildMap = [ const flightModes = ["ARM","ANGLE","HORIZON","ANTI GRAVITY","MAG","HEADFREE","HEADADJ","SERVO1","SERVO2","SERVO3", "FAILSAFE","AIR MODE","FPV ANGLE MIX","FLIP OVER AFTER CRASH","USER1","USER2","USER3","USER4","ACRO TRAINER","LAUNCH CONTROL"]; -// Categories +// Categories to be mapped with buildMap. Category 'all' are virtuel and always included let categoryTable = [ { name: '3D', buildKey: ['dshot'], modes: ['3D', '3D DISABLE / SWITCH']}, - { name: 'BEEP', buildKey: ['all'], modes: ['BEEPER', 'BEEPER MUTE', 'GPS BEEP SATELLITE COUNT']}, + { name: 'BEEP', buildKey: ['all'], modes: ['BEEPERON', 'BEEPER', 'BEEPER MUTE', 'GPS BEEP SATELLITE COUNT']}, { name: 'BLACKBOX', buildKey: ['all'], modes: ['BLACKBOX', 'BLACKBOX ERASE']}, { name: 'CAM', buildKey: ['cam'], modes: ['CAMERA CONTROL 1', 'CAMERA CONTROL 2', 'CAMERA CONTROL 3']}, { name: 'FLIGHTMODE', buildKey: ['all'], modes: flightModes}, @@ -48,7 +48,9 @@ let categoryTable = [ { name: 'VTX', buildKey: ['vtx'], modes: ['STICK COMMANDS DISABLE', 'VTX CONTROL DISABLE', 'VTX PIT MODE']}, ]; -function isInBuildKey(map, name) { +let modeList = []; + +function inBuildMap(map, name) { if (name == 'all') { return true; } @@ -64,46 +66,100 @@ function isInBuildKey(map, name) { return false; } -function createCategorySelect(table) { - let categorySelect = $('select.auxiliary_category_select'); +function isSelectedMode(mList, modeName) { + for (let i = 0; i < mList.length; i++) { + if (mList[i].includes(modeName)) { + return true; + } + } + return false; +} - for (let i = 0; i < table.length; i++) { - if (isInBuildKey(buildMap, table[i].buildKey)) { - categorySelect.append(``); +function resolveCategoryName(category, choise) { + let mList = []; + for (let i = 0; i < choise.length; i++) { + for (let j = 0; j < category.length; j++) { + if (choise[i] == category[j].name) { + mList.push(category[j].modes); + } } } + return mList; +} - categorySelect.multipleSelect({ - filter: true, - // locale: selectOptions, - showClear: true, - // minimumCountSelected : minimumCountSelected, - placeholder: i18n.getMessage("dropDownFilterDisabled"), - // onClick: () => { this.updateSearchResults(); }, - // onCheckAll: () => { this.updateSearchResults(); }, - // onUncheckAll: () => { this.updateSearchResults(); }, - formatSelectAll() { return i18n.getMessage("dropDownSelectAll"); }, - formatAllSelected() { return i18n.getMessage("dropDownAll"); }, - }); +function isPreSelectedCategory(categoryList, categoryName) { + for (let i = 0; i < categoryList.length; i++) { + if (categoryName == categoryList[i]) { + return true; + } + } + return false; } -function createTable(data) { - // Create a dynamic table with fixed values - let table = []; +function updateSearchResults() { + let categorySelect = $('select.auxiliary_category_select'); + + const categoryNameList = categorySelect.multipleSelect("getSelects", "text"); + setConfig({ auxiliaryCategoryNameList: categoryNameList }); // save as users choise + modeList = resolveCategoryName(categoryTable, categoryNameList); + // like to call, but not out of scope ---- update_ui(); +} - for (let i = 0; i < data.length; i++) { - let row = data[i].modes.slice(); // Use slice to clone the array - table.push(row); +function getCategoryNames(table, buildKey) { + // return names for buildKey category + let categoryChoise = []; + for (let i = 0; i < table.length; i++) { + if (buildKey == table[i].name) { + categoryChoise.push(table[i].name); + } } - - return table; + return categoryChoise; } -// Function to display the table in the console -function displayTable(table) { +function createCategorySelect(table, map) { + let categorySelect = $('select.auxiliary_category_select'); + + const categoryNameObj = getConfig('auxiliaryCategoryNameList'); // read user pre selected categories + let categoryNameList = categoryNameObj.auxiliaryCategoryNameList; + if (categoryNameList.length == 0) { + categoryNameList = getCategoryNames(table, 'all'); // empty choise -> select names from 'all' category + setConfig({ auxiliaryCategoryNameList: categoryNameList }); + } + for (let i = 0; i < table.length; i++) { - console.log(`${table[i].name}: ${table[i].modes}`); + if (inBuildMap(map, table[i].buildKey)) { + if (isPreSelectedCategory(categoryNameList, table[i].name)) { + categorySelect.append(``); + } + else { + categorySelect.append(``); + } + } + else { + categorySelect.append(``); + } } + + const modeWidth = 125; + const heightUnit = categoryTable.length; + + categorySelect.sortSelect().multipleSelect({ + width: modeWidth + 50, + dropWidth: modeWidth + 165, + minimumCountSelected: 3, // number before we use xx of yy + maxHeightUnit: heightUnit, // in px + locale: getCurrentLocaleISO(), + filter: false, + showClear: true, + ellipsis: true, + openOnHover: true, + placeholder: i18n.getMessage("dropDownFilterDisabled"), + onClick: () => { updateSearchResults(); }, + onCheckAll: () => { updateSearchResults(); }, + onUncheckAll: () => { updateSearchResults(); }, + formatSelectAll() { return i18n.getMessage("dropDownSelectAll"); }, + formatAllSelected() { return i18n.getMessage("dropDownAll"); }, + }); } // Function to simulate mouseover and select an option @@ -143,7 +199,6 @@ The simulateMouseoverAndSelectForEachOption function iterates over each option i You can also add a delay between each iteration if needed (commented out in the code). Adjust the delay according to your requirements. */ - auxiliary.initialize = function (callback) { GUI.active_tab_ref = this; GUI.active_tab = 'auxiliary'; @@ -437,10 +492,6 @@ auxiliary.initialize = function (callback) { // translate to user-selected language i18n.localizePage(); - // generate category multiple select - displayTable(categoryTable); - createCategorySelect(categoryTable); - const length = Math.max(...(FC.AUX_CONFIG.map(el => el.length))); $('.tab-auxiliary .mode .info').css('min-width', `${Math.round(length * getTextWidth('A'))}px`); @@ -456,6 +507,9 @@ auxiliary.initialize = function (callback) { addLinkedToMode(modeElement, 0, 0); }); + // setup category multiple select + createCategorySelect(categoryTable, buildMap); + // UI Hooks $('a.save').click(function () { @@ -622,32 +676,19 @@ auxiliary.initialize = function (callback) { } let hideUnused = hideUnusedModes && hasUsedMode; - let hideNoFlight = hideNoFlightMode && hasUsedMode; for (let i = 1; i < FC.AUX_CONFIG.length; i++) { // ARM has index 0 let modeElement = $(`#mode-${i}`); - if (modeElement.find(' .range').length == 0 && modeElement.find(' .link').length == 0) { - // unused mode - modeElement.toggle(!hideUnused); + if ( ! isSelectedMode(modeList, FC.AUX_CONFIG[i])) { + modeElement.toggle( false); } - - /* - if ( ! isFlightMode(FC.AUX_CONFIG[i])) { - // not flightMode mode - hide = hide || !hideNoFlight; - style = modeElement.css('display'); - console.log(`1 HIDE not flightmode: ${FC.AUX_CONFIG[i]} -> ${hide}`); - // modeElement.toggle(!hideNoFlight); - / * - if( hideNoFlight && ! style === 'none') { + else { + if ( ! isSelectedMode(modeList, FC.AUX_CONFIG[i]) && modeElement.find(' .range').length == 0 && modeElement.find(' .link').length == 0) { + // unused mode modeElement.toggle(!hideUnused); } - style = modeElement.css('display'); - console.log(`2 NOT flightmode: ${FC.AUX_CONFIG[i]} - ${style}`); - * / } - */ } auto_select_channel(FC.RC.channels, FC.RC.active_channels, FC.RSSI_CONFIG.channel); @@ -702,9 +743,8 @@ auxiliary.initialize = function (callback) { } let hideUnusedModes = false; - let hideNoFlightMode = false; - // hide unused modes + // get or save hide unused modes const configUnusedModes = getConfig('hideUnusedModes'); $("input#switch-toggle-unused") .change(function() { @@ -716,17 +756,6 @@ auxiliary.initialize = function (callback) { .prop("checked", !!configUnusedModes.hideUnusedModes) .change(); - // hide non flightmodes - const configNoFlightMode = getConfig('hideNoFlightMode'); - $("input#switch-toggle-hideNoFlightMode") - .change(function() { - hideNoFlightMode = $(this).prop("checked"); - setConfig({ hideNoFlightMode: hideNoFlightMode }); - update_ui(); - }) - .prop("checked", !!configNoFlightMode.hideNoFlightMode) - .change(); - // update ui instantly on first load update_ui(); diff --git a/src/main.html b/src/main.html index c0139ba8f8..cd62d6e1dc 100644 --- a/src/main.html +++ b/src/main.html @@ -49,6 +49,7 @@ + diff --git a/src/tabs/auxiliary.html b/src/tabs/auxiliary.html index 955aa44a82..f0e9b493c5 100644 --- a/src/tabs/auxiliary.html +++ b/src/tabs/auxiliary.html @@ -7,25 +7,22 @@

- - - +
-
-
-
-
-
-
- -
-
+
+
+
+
+
+
+
    +       
@@ -35,7 +32,6 @@
-
From 3d9e4c4598e9874a2ed77b65a3a42bfbf3b01ac4 Mon Sep 17 00:00:00 2001 From: HThuren Date: Mon, 11 Dec 2023 23:57:37 +0100 Subject: [PATCH 14/32] more to go --- src/js/tabs/auxiliary.js | 44 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index 729eb795b1..1b1fa32e14 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -1,5 +1,5 @@ import { i18n, getCurrentLocaleISO } from "../localization"; -import GUI, { TABS } from '../../js/gui'; +import GUI from '../../js/gui'; import { get as getConfig, set as setConfig } from '../ConfigStorage'; import { bit_check } from '../bit'; import { mspHelper } from '../msp/MSPHelper'; @@ -54,10 +54,10 @@ function inBuildMap(map, name) { if (name == 'all') { return true; } - for (let i = 0; i < map.length; i++) { - if (name == map[i].buildKey) { - for (let y = 0; y < map[i].buildOption.length; y++) { - if (FC.CONFIG.buildOptions.includes(map[i].buildOption[y])) { + for (let value of map) { + if (name == value.buildKey) { + for (let y = 0; y < value.buildOption.length; y++) { + if (FC.CONFIG.buildOptions.includes(value.buildOption[y])) { return true; } } @@ -67,8 +67,8 @@ function inBuildMap(map, name) { } function isSelectedMode(mList, modeName) { - for (let i = 0; i < mList.length; i++) { - if (mList[i].includes(modeName)) { + for (let value of mList) { + if (value.includes(modeName)) { return true; } } @@ -77,10 +77,10 @@ function isSelectedMode(mList, modeName) { function resolveCategoryName(category, choise) { let mList = []; - for (let i = 0; i < choise.length; i++) { - for (let j = 0; j < category.length; j++) { - if (choise[i] == category[j].name) { - mList.push(category[j].modes); + for (let value of choise) { + for (let elm of category) { + if (value == elm.name) { + mList.push(elm.modes); } } } @@ -88,8 +88,8 @@ function resolveCategoryName(category, choise) { } function isPreSelectedCategory(categoryList, categoryName) { - for (let i = 0; i < categoryList.length; i++) { - if (categoryName == categoryList[i]) { + for (let value of categoryList) { + if (value == categoryName) { return true; } } @@ -108,9 +108,9 @@ function updateSearchResults() { function getCategoryNames(table, buildKey) { // return names for buildKey category let categoryChoise = []; - for (let i = 0; i < table.length; i++) { - if (buildKey == table[i].name) { - categoryChoise.push(table[i].name); + for (let value of table) { + if (value.name == buildKey) { + categoryChoise.push(value.name); } } return categoryChoise; @@ -126,17 +126,17 @@ function createCategorySelect(table, map) { setConfig({ auxiliaryCategoryNameList: categoryNameList }); } - for (let i = 0; i < table.length; i++) { - if (inBuildMap(map, table[i].buildKey)) { - if (isPreSelectedCategory(categoryNameList, table[i].name)) { - categorySelect.append(``); + for (let value of table) { + if (inBuildMap(map, value.buildKey)) { + if (isPreSelectedCategory(categoryNameList, value.name)) { + categorySelect.append(``); } else { - categorySelect.append(``); + categorySelect.append(``); } } else { - categorySelect.append(``); + categorySelect.append(``); } } From 3a2e8b0bcd77c0cc79eb2670d0b06b67764df4a5 Mon Sep 17 00:00:00 2001 From: HThuren Date: Tue, 12 Dec 2023 00:11:40 +0100 Subject: [PATCH 15/32] more to go --- src/js/localization.js | 3 ++- src/js/tabs/auxiliary.js | 14 +++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/js/localization.js b/src/js/localization.js index a0d3057613..6348c7caef 100644 --- a/src/js/localization.js +++ b/src/js/localization.js @@ -31,8 +31,9 @@ const languageISOcode = ['ca-ES', 'da-DK', 'de-DE', 'en-US', 'es-ES', 'eu-ES', ' */ function getCurrentLocaleISO() { const isoCodeIndex = languagesAvailables.indexOf(i18next.language); - if (isoCodeIndex === -1) + if (isoCodeIndex === -1) { return 'en-US'; + } return languageISOcode[isoCodeIndex]; } diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index 1b1fa32e14..4b68e0fc81 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -56,8 +56,8 @@ function inBuildMap(map, name) { } for (let value of map) { if (name == value.buildKey) { - for (let y = 0; y < value.buildOption.length; y++) { - if (FC.CONFIG.buildOptions.includes(value.buildOption[y])) { + for (let option of value.buildOption) { + if (FC.CONFIG.buildOptions.includes(option)) { return true; } } @@ -480,9 +480,7 @@ auxiliary.initialize = function (callback) { if (range.start >= range.end) { continue; // invalid! } - addRangeToMode(newMode, modeRange.auxChannelIndex, modeRangeExtra.modeLogic, range); - } else { addLinkedToMode(newMode, modeRangeExtra.modeLogic, modeRangeExtra.linkedTo); } @@ -683,11 +681,9 @@ auxiliary.initialize = function (callback) { if ( ! isSelectedMode(modeList, FC.AUX_CONFIG[i])) { modeElement.toggle( false); } - else { - if ( ! isSelectedMode(modeList, FC.AUX_CONFIG[i]) && modeElement.find(' .range').length == 0 && modeElement.find(' .link').length == 0) { - // unused mode - modeElement.toggle(!hideUnused); - } + else if ( ! isSelectedMode(modeList, FC.AUX_CONFIG[i]) && modeElement.find(' .range').length == 0 && modeElement.find(' .link').length == 0) { + // unused mode + modeElement.toggle(!hideUnused); } } From f855b5ebc09e5ca42e93dbe18f683ec4a64ffd71 Mon Sep 17 00:00:00 2001 From: HThuren Date: Tue, 12 Dec 2023 00:19:11 +0100 Subject: [PATCH 16/32] more to go --- src/js/tabs/auxiliary.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index 4b68e0fc81..d46211d723 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -14,7 +14,7 @@ import inflection from "inflection"; const auxiliary = {}; // BF build Options mapped to buildKey. -let buildMap = [ +const buildMap = [ { buildKey: 'cam', buildOption: ['USE_CAMERA_CONTROL']}, { buildKey: 'div', buildOption: ['USE_ARCO_TRAINER', 'USE_DASHBOARD', 'USE_PINIO']}, { buildKey: 'dshot', buildOption: ['USE_DSHOT']}, @@ -32,7 +32,7 @@ const flightModes = ["ARM","ANGLE","HORIZON","ANTI GRAVITY","MAG","HEADFREE","HE "FAILSAFE","AIR MODE","FPV ANGLE MIX","FLIP OVER AFTER CRASH","USER1","USER2","USER3","USER4","ACRO TRAINER","LAUNCH CONTROL"]; // Categories to be mapped with buildMap. Category 'all' are virtuel and always included -let categoryTable = [ +const categoryTable = [ { name: '3D', buildKey: ['dshot'], modes: ['3D', '3D DISABLE / SWITCH']}, { name: 'BEEP', buildKey: ['all'], modes: ['BEEPERON', 'BEEPER', 'BEEPER MUTE', 'GPS BEEP SATELLITE COUNT']}, { name: 'BLACKBOX', buildKey: ['all'], modes: ['BLACKBOX', 'BLACKBOX ERASE']}, @@ -726,9 +726,7 @@ auxiliary.initialize = function (callback) { }, 0); // minimum change to autoselect is 100 - if (largest < 100) { - return fillPrevChannelsValues(); - } + if (largest < 100) return fillPrevChannelsValues(); const indexOfMaxValue = diff_array.indexOf(largest); if (indexOfMaxValue >= 4 && indexOfMaxValue != RSSI_channel - 1) { From c52d42473ca98a99e2d8bd0a750407e3f674490a Mon Sep 17 00:00:00 2001 From: HThuren Date: Tue, 12 Dec 2023 08:03:33 +0100 Subject: [PATCH 17/32] unused get to work --- src/js/tabs/auxiliary.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index d46211d723..4b3e4d728e 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -681,7 +681,7 @@ auxiliary.initialize = function (callback) { if ( ! isSelectedMode(modeList, FC.AUX_CONFIG[i])) { modeElement.toggle( false); } - else if ( ! isSelectedMode(modeList, FC.AUX_CONFIG[i]) && modeElement.find(' .range').length == 0 && modeElement.find(' .link').length == 0) { + else if ( modeElement.find(' .range').length == 0 && modeElement.find(' .link').length == 0) { // unused mode modeElement.toggle(!hideUnused); } @@ -725,7 +725,7 @@ auxiliary.initialize = function (callback) { return (x > y) ? x : y; }, 0); - // minimum change to autoselect is 100 + //minimum change to autoselect is 100 if (largest < 100) return fillPrevChannelsValues(); const indexOfMaxValue = diff_array.indexOf(largest); From 8cb27a26b7545695cf59654eee3ecd326bd0aa44 Mon Sep 17 00:00:00 2001 From: HThuren Date: Wed, 13 Dec 2023 00:38:03 +0100 Subject: [PATCH 18/32] ready --- src/js/tabs/auxiliary.js | 54 +++++++--------------------------------- src/tabs/auxiliary.html | 8 +++--- 2 files changed, 14 insertions(+), 48 deletions(-) diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index 4b3e4d728e..2146d5a7b4 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -100,9 +100,8 @@ function updateSearchResults() { let categorySelect = $('select.auxiliary_category_select'); const categoryNameList = categorySelect.multipleSelect("getSelects", "text"); - setConfig({ auxiliaryCategoryNameList: categoryNameList }); // save as users choise + setConfig({ auxiliaryCategoryNameList: categoryNameList }); // save as users choise modeList = resolveCategoryName(categoryTable, categoryNameList); - // like to call, but not out of scope ---- update_ui(); } function getCategoryNames(table, buildKey) { @@ -119,15 +118,16 @@ function getCategoryNames(table, buildKey) { function createCategorySelect(table, map) { let categorySelect = $('select.auxiliary_category_select'); - const categoryNameObj = getConfig('auxiliaryCategoryNameList'); // read user pre selected categories + const categoryNameObj = getConfig('auxiliaryCategoryNameList'); // read user pre selected categories let categoryNameList = categoryNameObj.auxiliaryCategoryNameList; if (categoryNameList.length == 0) { - categoryNameList = getCategoryNames(table, 'all'); // empty choise -> select names from 'all' category + categoryNameList = getCategoryNames(table, 'all'); // empty choise -> select names from 'all' category setConfig({ auxiliaryCategoryNameList: categoryNameList }); } for (let value of table) { - if (inBuildMap(map, value.buildKey)) { + if (inBuildMap(map, value.buildKey) || FC.CONFIG.buildOptions.length == 0) { + // selected build option or local build if (isPreSelectedCategory(categoryNameList, value.name)) { categorySelect.append(``); } @@ -145,14 +145,15 @@ function createCategorySelect(table, map) { categorySelect.sortSelect().multipleSelect({ width: modeWidth + 50, - dropWidth: modeWidth + 165, + dropWidth: modeWidth + 63, minimumCountSelected: 3, // number before we use xx of yy - maxHeightUnit: heightUnit, // in px + maxHeight: heightUnit * 30, // in px + maxHeightUnit: heightUnit, // show all categories locale: getCurrentLocaleISO(), filter: false, showClear: true, ellipsis: true, - openOnHover: true, + openOnHover: true, // open when muse over placeholder: i18n.getMessage("dropDownFilterDisabled"), onClick: () => { updateSearchResults(); }, onCheckAll: () => { updateSearchResults(); }, @@ -162,43 +163,6 @@ function createCategorySelect(table, map) { }); } -// Function to simulate mouseover and select an option -function simulateMouseoverAndSelectOption(selectElement, optionIndex) { - // Trigger mouseover event - const mouseoverEvent = new Event('mouseover'); - selectElement.dispatchEvent(mouseoverEvent); - - // Select the specified option - selectElement.selectedIndex = optionIndex; - - // Trigger change event to notify any listeners - const changeEvent = new Event('change'); - selectElement.dispatchEvent(changeEvent); -} - -// Function to iterate over options and simulate mouseover and selection -function simulateMouseoverAndSelectForEachOption() { - // Get the select element - const selectElement = document.getElementById('yourSelectElementId'); // Replace with your actual select element ID - - // Iterate over each option and simulate mouseover and selection - for (let i = 0; i < selectElement.options.length; i++) { - simulateMouseoverAndSelectOption(selectElement, i); - // You can add a delay here if needed - // setTimeout(() => { - // simulateMouseoverAndSelectOption(selectElement, i); - // }, 1000 * i); // Adjust the delay as needed - } -} - -// Call the function when needed -//simulateMouseoverAndSelectForEachOption(); -/* -Replace 'yourSelectElementId' with the actual ID of your select element. -The simulateMouseoverAndSelectForEachOption function iterates over each option in the select element, simulates a mouseover, and selects the option. -You can also add a delay between each iteration if needed (commented out in the code). Adjust the delay according to your requirements. -*/ - auxiliary.initialize = function (callback) { GUI.active_tab_ref = this; GUI.active_tab = 'auxiliary'; diff --git a/src/tabs/auxiliary.html b/src/tabs/auxiliary.html index f0e9b493c5..7fb7f71bd3 100644 --- a/src/tabs/auxiliary.html +++ b/src/tabs/auxiliary.html @@ -7,16 +7,17 @@

- +
+ +
-
+
- +
@@ -31,6 +32,7 @@
From 33fb347486a2b37804d9ea6c25e40c8067cb8bf9 Mon Sep 17 00:00:00 2001 From: HThuren Date: Wed, 13 Dec 2023 00:46:40 +0100 Subject: [PATCH 19/32] sonarcloud fix --- src/tabs/auxiliary.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tabs/auxiliary.html b/src/tabs/auxiliary.html index 7fb7f71bd3..00612d89d0 100644 --- a/src/tabs/auxiliary.html +++ b/src/tabs/auxiliary.html @@ -7,7 +7,7 @@

- +
@@ -17,7 +17,7 @@
- +
From f55ce01f3896ad310a9e87b9acecbf6eef0e6837 Mon Sep 17 00:00:00 2001 From: HThuren Date: Wed, 13 Dec 2023 22:00:18 +0100 Subject: [PATCH 20/32] update help text --- locales/en/messages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index 98065885c8..03d9e179f0 100755 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -2306,7 +2306,7 @@ "message": "Enable controls" }, "auxiliaryHelp": { - "message": "Configure modes here using a combination of ranges and/or links to other modes (links supported on BF 4.0 and later). Use ranges to define the switches on your transmitter and corresponding mode assignments. A receiver channel that gives a reading between a range min/max will activate the mode. Use a link to activate a mode when another mode is activated. Exceptions: ARM cannot be linked to or from another mode, modes cannot be linked to other modes that are configured with a link (chained links). Multiple ranges/links can be used to activate any mode. If there is more than one range/link defined for a mode, each of them can be set to AND or OR. A mode will be activated when:
- ALL AND ranges/links are active; OR
- at least one OR range/link is active.

Remember to save your settings using the Save button." + "message": "Configure modes here using a combination of ranges and/or links to other modes. The Category arrange modes in groups, at Cloud build only groups defined in Build are enabled. At local build all groups are enabled.
Use ranges to define the switches on your transmitter and corresponding mode assignments. A receiver channel that gives a reading between a range min/max will activate the mode. Use a link to activate a mode when another mode is activated. Multiple ranges/links can be used to activate any mode.
If there is more than one range/link defined for a mode, each of them can be set to AND or OR. A mode will be activated when: ALL AND ranges/links are active; OR at least one OR range/link is active.
Exceptions: ARM cannot be linked to or from another mode, modes cannot be linked to other modes that are configured with a link (chained links).
Remember to save your settings using the Save button." }, "auxiliaryToggleUnused": { "message": "Hide unused modes" From 9add38056b0c663b14a27ee8f7c9df48078da25b Mon Sep 17 00:00:00 2001 From: HThuren Date: Wed, 13 Dec 2023 22:01:09 +0100 Subject: [PATCH 21/32] update help text --- locales/en/messages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index 03d9e179f0..99bf83a0bf 100755 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -2306,7 +2306,7 @@ "message": "Enable controls" }, "auxiliaryHelp": { - "message": "Configure modes here using a combination of ranges and/or links to other modes. The Category arrange modes in groups, at Cloud build only groups defined in Build are enabled. At local build all groups are enabled.
Use ranges to define the switches on your transmitter and corresponding mode assignments. A receiver channel that gives a reading between a range min/max will activate the mode. Use a link to activate a mode when another mode is activated. Multiple ranges/links can be used to activate any mode.
If there is more than one range/link defined for a mode, each of them can be set to AND or OR. A mode will be activated when: ALL AND ranges/links are active; OR at least one OR range/link is active.
Exceptions: ARM cannot be linked to or from another mode, modes cannot be linked to other modes that are configured with a link (chained links).
Remember to save your settings using the Save button." + "message": "Configure modes here using a combination of ranges and/or links to other modes. The Category arrange modes in groups, at Cloud build only groups defined in Build are enabled. At local build all groups are enabled.
Use ranges to define the switches on your transmitter and corresponding mode assignments. A receiver channel that gives a reading between a range min/max will activate the mode. Use a link to activate a mode when another mode is activated. Multiple ranges/links can be used to activate any mode.
If there is more than one range/link defined for a mode, each of them can be set to AND or OR. A mode will be activated when: ALL AND ranges/links are active; OR at least one OR range/link is active.
Exceptions: ARM cannot be linked to or from another mode, modes cannot be linked to other modes that are configured with a link (chained links).
Notice: To work 'Hide unused modes' need minimum one configured mode.
Remember to save your settings using the Save button." }, "auxiliaryToggleUnused": { "message": "Hide unused modes" From 0a3375dcb95b4009d0b1bff9013dd3edc037fbe1 Mon Sep 17 00:00:00 2001 From: HThuren Date: Wed, 13 Dec 2023 22:01:35 +0100 Subject: [PATCH 22/32] update help text --- src/js/tabs/auxiliary.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index 2146d5a7b4..cdd6e3dc85 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -146,7 +146,7 @@ function createCategorySelect(table, map) { categorySelect.sortSelect().multipleSelect({ width: modeWidth + 50, dropWidth: modeWidth + 63, - minimumCountSelected: 3, // number before we use xx of yy + minimumCountSelected: 2, // number before we use xx of yy maxHeight: heightUnit * 30, // in px maxHeightUnit: heightUnit, // show all categories locale: getCurrentLocaleISO(), From d7283aa73981505683f35674d2b973bd4b5c84be Mon Sep 17 00:00:00 2001 From: HThuren Date: Fri, 15 Dec 2023 01:52:03 +0100 Subject: [PATCH 23/32] fix initial load --- locales/en/messages.json | 2 +- src/js/tabs/auxiliary.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index 99bf83a0bf..957f5fd300 100755 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -2306,7 +2306,7 @@ "message": "Enable controls" }, "auxiliaryHelp": { - "message": "Configure modes here using a combination of ranges and/or links to other modes. The Category arrange modes in groups, at Cloud build only groups defined in Build are enabled. At local build all groups are enabled.
Use ranges to define the switches on your transmitter and corresponding mode assignments. A receiver channel that gives a reading between a range min/max will activate the mode. Use a link to activate a mode when another mode is activated. Multiple ranges/links can be used to activate any mode.
If there is more than one range/link defined for a mode, each of them can be set to AND or OR. A mode will be activated when: ALL AND ranges/links are active; OR at least one OR range/link is active.
Exceptions: ARM cannot be linked to or from another mode, modes cannot be linked to other modes that are configured with a link (chained links).
Notice: To work 'Hide unused modes' need minimum one configured mode.
Remember to save your settings using the Save button." + "message": "Configure modes here using a combination of ranges and/or links to other modes. The Category arrange modes in groups, at Cloud build only groups defined in Build are enabled. At local build all groups are enabled.
Use ranges to define the switches on your transmitter and corresponding mode assignments. A receiver channel that gives a reading between a range min/max will activate the mode. Use a link to activate a mode when another mode is activated. Multiple ranges/links can be used to activate any mode.
If there is more than one range/link defined for a mode, each of them can be set to AND or OR. A mode will be activated when: ALL AND ranges/links are active; OR at least one OR range/link is active.
Exceptions: ARM cannot be linked to or from another mode, modes cannot be linked to other modes that are configured with a link (chained links).
Notice: 'Hide unused modes' need minimum one configured mode to really work.
Remember to save your settings using the Save button." }, "auxiliaryToggleUnused": { "message": "Hide unused modes" diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index cdd6e3dc85..6fdfeb4158 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -469,7 +469,7 @@ auxiliary.initialize = function (callback) { addLinkedToMode(modeElement, 0, 0); }); - // setup category multiple select + // create category multiple select createCategorySelect(categoryTable, buildMap); // UI Hooks @@ -714,6 +714,9 @@ auxiliary.initialize = function (callback) { .prop("checked", !!configUnusedModes.hideUnusedModes) .change(); + // setup categoryList + updateSearchResults(); + // update ui instantly on first load update_ui(); From f6ac8b19f37a2163c824eb080544078d6e1a7e98 Mon Sep 17 00:00:00 2001 From: HThuren Date: Sun, 17 Dec 2023 21:30:23 +0100 Subject: [PATCH 24/32] code review --- src/js/tabs/auxiliary.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index 6fdfeb4158..acd10a390e 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -55,7 +55,7 @@ function inBuildMap(map, name) { return true; } for (let value of map) { - if (name == value.buildKey) { + if (name.includes(value.buildKey)) { for (let option of value.buildOption) { if (FC.CONFIG.buildOptions.includes(option)) { return true; @@ -79,7 +79,7 @@ function resolveCategoryName(category, choise) { let mList = []; for (let value of choise) { for (let elm of category) { - if (value == elm.name) { + if (value.includes(elm.name)) { mList.push(elm.modes); } } @@ -87,15 +87,6 @@ function resolveCategoryName(category, choise) { return mList; } -function isPreSelectedCategory(categoryList, categoryName) { - for (let value of categoryList) { - if (value == categoryName) { - return true; - } - } - return false; -} - function updateSearchResults() { let categorySelect = $('select.auxiliary_category_select'); @@ -128,7 +119,7 @@ function createCategorySelect(table, map) { for (let value of table) { if (inBuildMap(map, value.buildKey) || FC.CONFIG.buildOptions.length == 0) { // selected build option or local build - if (isPreSelectedCategory(categoryNameList, value.name)) { + if (categoryNameList.includes(value.name)) { categorySelect.append(``); } else { From 7d2915941ec1355cbef29bfd66600fdc667de96a Mon Sep 17 00:00:00 2001 From: HThuren Date: Tue, 19 Dec 2023 01:51:28 +0100 Subject: [PATCH 25/32] update of CSS --- src/css/tabs/auxiliary.less | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/css/tabs/auxiliary.less b/src/css/tabs/auxiliary.less index 28b6d53a24..9172119be5 100644 --- a/src/css/tabs/auxiliary.less +++ b/src/css/tabs/auxiliary.less @@ -11,7 +11,12 @@ color: rgb(105, 99, 99); padding: 10px 5px; } - .auxiliary_category_content { + .xxxauxiliary_category { + flex-wrap: wrap; + width: 100%; + border-bottom: 0; + } + .xxxauxiliary_category_content { width: 100%; } .auxiliary_category_header { @@ -282,6 +287,11 @@ } @media all and (max-width: 575px) { .tab-auxiliary { + .auxiliary_category { + flex-wrap: wrap; + width: 100%; + border-bottom: 0; + } .mode { flex-wrap: wrap; .info { From f561436ff8852acdd46e9db114bf8c63717792da Mon Sep 17 00:00:00 2001 From: HThuren Date: Thu, 21 Dec 2023 23:43:40 +0100 Subject: [PATCH 26/32] fix quality issue --- src/css/tabs/auxiliary.less | 16 +++++++++------ src/tabs/auxiliary.html | 41 +++++++++++++++---------------------- 2 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/css/tabs/auxiliary.less b/src/css/tabs/auxiliary.less index 9172119be5..87f2e5663d 100644 --- a/src/css/tabs/auxiliary.less +++ b/src/css/tabs/auxiliary.less @@ -6,17 +6,17 @@ background-color: #ffcb18; margin-bottom: 10px; } - .toolbox { + .auxiliary_toolbox { font-weight: bold; color: rgb(105, 99, 99); - padding: 10px 5px; + padding: 5px 5px 1px; } - .xxxauxiliary_category { - flex-wrap: wrap; - width: 100%; + .auxiliary_category { + width: 10%; border-bottom: 0; + resize: none; } - .xxxauxiliary_category_content { + .auxiliary_category_content { width: 100%; } .auxiliary_category_header { @@ -30,6 +30,10 @@ background-color: rgba(64, 64, 64, 1); resize: none; } + .auxiliary_category_select_value { + width: 100%; + margin-bottom: 10px; + } .range { .marker { background: var(--accent); diff --git a/src/tabs/auxiliary.html b/src/tabs/auxiliary.html index 00612d89d0..8bd5457e87 100644 --- a/src/tabs/auxiliary.html +++ b/src/tabs/auxiliary.html @@ -7,33 +7,24 @@

- - - - - - - - -
-
-
-
-
-
-
- -
-
+
+ + + + +
+
+
+
+
+
-
       -
-
- - -
+
+
-
+ + +
From 35d0d0da9767564b4bd62a131cafff3f9f12eeff Mon Sep 17 00:00:00 2001 From: HThuren Date: Tue, 26 Dec 2023 13:05:40 +0100 Subject: [PATCH 27/32] more call of categories when initialize --- src/js/tabs/auxiliary.js | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index acd10a390e..5b1838accf 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -18,9 +18,8 @@ const buildMap = [ { buildKey: 'cam', buildOption: ['USE_CAMERA_CONTROL']}, { buildKey: 'div', buildOption: ['USE_ARCO_TRAINER', 'USE_DASHBOARD', 'USE_PINIO']}, { buildKey: 'dshot', buildOption: ['USE_DSHOT']}, - { buildKey: 'gps', buildOption: ['USE_GPS', 'USE_GPS_PLUS_CODES']}, + { buildKey: 'gps_mag', buildOption: ['USE_GPS', 'USE_GPS_PLUS_CODES', 'USE_MAG']}, { buildKey: 'led_strip', buildOption: ['USE_LED_STRIP', 'USE_LED_STRIP_64']}, - { buildKey: 'mag', buildOption: ['USE_MAG']}, { buildKey: 'osd', buildOption: ['USE_OSD', 'USE_OSD_SD', 'USE_OSD_HD', 'USE_FRSKYOSD']}, { buildKey: 'serial', buildOption: ['USE_SERIALRX', 'USE_SERIALRX_FPORT']}, { buildKey: 'servos', buildOption: ['USE_SERVOS']}, @@ -28,24 +27,23 @@ const buildMap = [ { buildKey: 'vtx', buildOption: ['USE_VTX']}, ]; -const flightModes = ["ARM","ANGLE","HORIZON","ANTI GRAVITY","MAG","HEADFREE","HEADADJ","SERVO1","SERVO2","SERVO3", - "FAILSAFE","AIR MODE","FPV ANGLE MIX","FLIP OVER AFTER CRASH","USER1","USER2","USER3","USER4","ACRO TRAINER","LAUNCH CONTROL"]; +const flightControl = ['ARM', 'ANGLE', 'HORIZON', 'ANTI GRAVITY', 'HEADFREE', 'HEADADJ', 'FAILSAFE', 'AIR MODE', 'FPV ANGLE MIX', 'ACRO TRAINER', 'LAUNCH CONTROL']; // Categories to be mapped with buildMap. Category 'all' are virtuel and always included const categoryTable = [ - { name: '3D', buildKey: ['dshot'], modes: ['3D', '3D DISABLE / SWITCH']}, - { name: 'BEEP', buildKey: ['all'], modes: ['BEEPERON', 'BEEPER', 'BEEPER MUTE', 'GPS BEEP SATELLITE COUNT']}, - { name: 'BLACKBOX', buildKey: ['all'], modes: ['BLACKBOX', 'BLACKBOX ERASE']}, - { name: 'CAM', buildKey: ['cam'], modes: ['CAMERA CONTROL 1', 'CAMERA CONTROL 2', 'CAMERA CONTROL 3']}, - { name: 'FLIGHTMODE', buildKey: ['all'], modes: flightModes}, - { name: 'GPS', buildKey: ['gps'], modes: ['GPS BEEP SATELLITE COUNT', 'GPS RESCUE']}, - { name: 'LED', buildKey: ['led_strip'], modes: ['LEDLOW']}, - { name: 'OSD', buildKey: ['osd'], modes: ['OSD DISABLE']}, - { name: 'OTHER', buildKey: ['all'], modes: ['CALIB', 'MSP OVERRIDE', 'LAP TIMER RESET', 'PASSTHRU', 'PARALYZE', 'PID AUDIO', 'PREARM']}, - { name: 'SERVO', buildKey: ['servos'], modes: ['SERVO1', 'SERVO2', 'SERVO3']}, - { name: 'TELEMETRI', buildKey: ['telemetry'], modes: ['TELEMETRY']}, - { name: 'USER', buildKey: ['all'], modes: ['USER1', 'USER2', 'USER3', 'USER4']}, - { name: 'VTX', buildKey: ['vtx'], modes: ['STICK COMMANDS DISABLE', 'VTX CONTROL DISABLE', 'VTX PIT MODE']}, + { name: 'BEEP', buildKey: ['all'], modes: ['BEEPERON', 'BEEPER', 'BEEPER MUTE', 'GPS BEEP SATELLITE COUNT']}, + { name: 'BLACKBOX', buildKey: ['all'], modes: ['BLACKBOX', 'BLACKBOX ERASE']}, + { name: 'CAM', buildKey: ['cam'], modes: ['CAMERA CONTROL 1', 'CAMERA CONTROL 2', 'CAMERA CONTROL 3']}, + { name: 'DSHOT / 3D', buildKey: ['dshot'], modes: ['3D', '3D DISABLE / SWITCH', 'FLIP OVER AFTER CRASH']}, + { name: 'FLIGHT CONTROL', buildKey: ['all'], modes: flightControl}, + { name: 'GPS / MAG', buildKey: ['gps_mag'], modes: ['GPS BEEP SATELLITE COUNT', 'GPS RESCUE', 'MAG']}, + { name: 'LED', buildKey: ['led_strip'], modes: ['LEDLOW']}, + { name: 'OSD', buildKey: ['osd'], modes: ['OSD DISABLE']}, + { name: 'OTHER', buildKey: ['all'], modes: ['CALIB', 'MSP OVERRIDE', 'LAP TIMER RESET', 'PASSTHRU', 'PARALYZE', 'PID AUDIO', 'PREARM', 'READY']}, + { name: 'SERVO', buildKey: ['servos'], modes: ['SERVO1', 'SERVO2', 'SERVO3']}, + { name: 'TELEMETRY', buildKey: ['telemetry'], modes: ['TELEMETRY']}, + { name: 'USER', buildKey: ['all'], modes: ['USER1', 'USER2', 'USER3', 'USER4']}, + { name: 'VTX', buildKey: ['vtx'], modes: ['STICK COMMANDS DISABLE', 'VTX CONTROL DISABLE', 'VTX PIT MODE']}, ]; let modeList = []; @@ -628,6 +626,9 @@ auxiliary.initialize = function (callback) { hasUsedMode = true; } + // setup categoryList to reflect changes when aux change + updateSearchResults(); + let hideUnused = hideUnusedModes && hasUsedMode; for (let i = 1; i < FC.AUX_CONFIG.length; i++) { // ARM has index 0 From e8e59c49556a45e214e5791fd6e1619bea528efb Mon Sep 17 00:00:00 2001 From: HThuren Date: Wed, 21 Feb 2024 01:41:42 +0100 Subject: [PATCH 28/32] fix bugs for not update ui, when unselect mode --- src/js/tabs/auxiliary.js | 158 +++++++++++++++++++-------------------- src/js/utils/common.js | 9 +-- src/main.html | 1 - 3 files changed, 83 insertions(+), 85 deletions(-) diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index 5b1838accf..01a5af6b02 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -46,6 +46,8 @@ const categoryTable = [ { name: 'VTX', buildKey: ['vtx'], modes: ['STICK COMMANDS DISABLE', 'VTX CONTROL DISABLE', 'VTX PIT MODE']}, ]; +let notSorted = true; +let hideUnusedModes = false; let modeList = []; function inBuildMap(map, name) { @@ -65,8 +67,8 @@ function inBuildMap(map, name) { } function isSelectedMode(mList, modeName) { - for (let value of mList) { - if (value.includes(modeName)) { + for (let i = 0; i < mList.length; i++) { // for (let value of mList) don't break on first hit + if (mList[i].includes(modeName)) { return true; } } @@ -91,6 +93,7 @@ function updateSearchResults() { const categoryNameList = categorySelect.multipleSelect("getSelects", "text"); setConfig({ auxiliaryCategoryNameList: categoryNameList }); // save as users choise modeList = resolveCategoryName(categoryTable, categoryNameList); + updateModes(); // update UI } function getCategoryNames(table, buildKey) { @@ -144,16 +147,83 @@ function createCategorySelect(table, map) { ellipsis: true, openOnHover: true, // open when muse over placeholder: i18n.getMessage("dropDownFilterDisabled"), + onClear: () => { updateSearchResults(); }, onClick: () => { updateSearchResults(); }, + onFilter: () => { updateSearchResults(); }, onCheckAll: () => { updateSearchResults(); }, onUncheckAll: () => { updateSearchResults(); }, formatSelectAll() { return i18n.getMessage("dropDownSelectAll"); }, formatAllSelected() { return i18n.getMessage("dropDownAll"); }, }); } +function updateModes() { + let hasUsedMode = false; + + for (let i = 0; i < FC.AUX_CONFIG.length; i++) { + let modeElement = $(`#mode-${i}`); + + if (modeElement.find(' .range').length == 0 && modeElement.find(' .link').length == 0) { + // if the mode is unused, skip it + modeElement.removeClass('off').removeClass('on').removeClass('disabled'); + continue; + } + + if (bit_check(FC.CONFIG.mode, i)) { + $('.mode .name').eq(i).data('modeElement').addClass('on').removeClass('off').removeClass('disabled'); + + // ARM mode is a special case + if (i == 0) { + $('.mode .name').eq(i).html(FC.AUX_CONFIG[i]); + } + } else { + + // ARM mode is a special case + if (i == 0) { + let armSwitchActive = false; + + if (FC.CONFIG.armingDisableCount > 0) { + // check the highest bit of the armingDisableFlags. This will be the ARMING_DISABLED_ARMSWITCH flag. + const armSwitchMask = 1 << (FC.CONFIG.armingDisableCount - 1); + if ((FC.CONFIG.armingDisableFlags & armSwitchMask) > 0) { + armSwitchActive = true; + } + } + + // If the ARMING_DISABLED_ARMSWITCH flag is set then that means that arming is disabled + // and the arm switch is in a valid arming range. Highlight the mode in red to indicate + // that arming is disabled. + if (armSwitchActive) { + $('.mode .name').eq(i).data('modeElement').removeClass('on').removeClass('off').addClass('disabled'); + $('.mode .name').eq(i).html(`${FC.AUX_CONFIG[i]}
${i18n.getMessage('auxiliaryDisabled')}`); + } else { + $('.mode .name').eq(i).data('modeElement').removeClass('on').removeClass('disabled').addClass('off'); + $('.mode .name').eq(i).html(FC.AUX_CONFIG[i]); + } + } else { + $('.mode .name').eq(i).data('modeElement').removeClass('on').removeClass('disabled').addClass('off'); + } + } + hasUsedMode = true; + } + + let hideUnused = hideUnusedModes && hasUsedMode; + + for (let i = 1; i < FC.AUX_CONFIG.length; i++) { // ARM has index 0 + let modeElement = $(`#mode-${i}`); + + if ( ! isSelectedMode(modeList, FC.AUX_CONFIG[i])) { + modeElement.toggle( false); + } + else { + modeElement.toggle( true); + if ( modeElement.find(' .range').length == 0 && modeElement.find(' .link').length == 0) { + modeElement.toggle(!hideUnused); // unused mode + } + } + } +} auxiliary.initialize = function (callback) { - GUI.active_tab_ref = this; GUI.active_tab = 'auxiliary'; let prevChannelsValues = null; let hasDirtyUnusedModes = true; @@ -413,9 +483,9 @@ auxiliary.initialize = function (callback) { const modeTableBodyElement = $('.tab-auxiliary .modes'); for (let modeIndex = 0; modeIndex < FC.AUX_CONFIG.length; modeIndex++) { - const modeId = FC.AUX_CONFIG_IDS[modeIndex]; const newMode = createMode(modeIndex, modeId); + modeTableBodyElement.append(newMode); // generate ranges from the supplied AUX names and MODE_RANGES[_EXTRA] data @@ -579,69 +649,7 @@ auxiliary.initialize = function (callback) { } function update_ui() { - let hasUsedMode = false; - for (let i = 0; i < FC.AUX_CONFIG.length; i++) { - let modeElement = $(`#mode-${i}`); - if (modeElement.find(' .range').length == 0 && modeElement.find(' .link').length == 0) { - // if the mode is unused, skip it - modeElement.removeClass('off').removeClass('on').removeClass('disabled'); - continue; - } - - if (bit_check(FC.CONFIG.mode, i)) { - $('.mode .name').eq(i).data('modeElement').addClass('on').removeClass('off').removeClass('disabled'); - - // ARM mode is a special case - if (i == 0) { - $('.mode .name').eq(i).html(FC.AUX_CONFIG[i]); - } - } else { - - // ARM mode is a special case - if (i == 0) { - let armSwitchActive = false; - - if (FC.CONFIG.armingDisableCount > 0) { - // check the highest bit of the armingDisableFlags. This will be the ARMING_DISABLED_ARMSWITCH flag. - const armSwitchMask = 1 << (FC.CONFIG.armingDisableCount - 1); - if ((FC.CONFIG.armingDisableFlags & armSwitchMask) > 0) { - armSwitchActive = true; - } - } - - // If the ARMING_DISABLED_ARMSWITCH flag is set then that means that arming is disabled - // and the arm switch is in a valid arming range. Highlight the mode in red to indicate - // that arming is disabled. - if (armSwitchActive) { - $('.mode .name').eq(i).data('modeElement').removeClass('on').removeClass('off').addClass('disabled'); - $('.mode .name').eq(i).html(`${FC.AUX_CONFIG[i]}
${i18n.getMessage('auxiliaryDisabled')}`); - } else { - $('.mode .name').eq(i).data('modeElement').removeClass('on').removeClass('disabled').addClass('off'); - $('.mode .name').eq(i).html(FC.AUX_CONFIG[i]); - } - } else { - $('.mode .name').eq(i).data('modeElement').removeClass('on').removeClass('disabled').addClass('off'); - } - } - hasUsedMode = true; - } - - // setup categoryList to reflect changes when aux change - updateSearchResults(); - - let hideUnused = hideUnusedModes && hasUsedMode; - - for (let i = 1; i < FC.AUX_CONFIG.length; i++) { // ARM has index 0 - let modeElement = $(`#mode-${i}`); - - if ( ! isSelectedMode(modeList, FC.AUX_CONFIG[i])) { - modeElement.toggle( false); - } - else if ( modeElement.find(' .range').length == 0 && modeElement.find(' .link').length == 0) { - // unused mode - modeElement.toggle(!hideUnused); - } - } + updateSearchResults(); // setup categoryList and show selected Modes auto_select_channel(FC.RC.channels, FC.RC.active_channels, FC.RSSI_CONFIG.channel); @@ -692,23 +700,15 @@ auxiliary.initialize = function (callback) { return fillPrevChannelsValues(); } - let hideUnusedModes = false; - // get or save hide unused modes const configUnusedModes = getConfig('hideUnusedModes'); - $("input#switch-toggle-unused") - .change(function() { - hideUnusedModes = $(this).prop("checked"); - hasDirtyUnusedModes = true; - setConfig({ hideUnusedModes: hideUnusedModes }); - update_ui(); - }) + $("input#switch-toggle-unused").change(function() { + hideUnusedModes = $(this).prop("checked"); + setConfig({ hideUnusedModes: hideUnusedModes }); + update_ui();}) .prop("checked", !!configUnusedModes.hideUnusedModes) .change(); - // setup categoryList - updateSearchResults(); - // update ui instantly on first load update_ui(); diff --git a/src/js/utils/common.js b/src/js/utils/common.js index 6cb4a1acd5..02aa9da797 100644 --- a/src/js/utils/common.js +++ b/src/js/utils/common.js @@ -101,20 +101,19 @@ export function urlExists(url) { } /** - * Returns jquery sorted option list with optional value staying on top of the list. + * Returns jquery sorted option list with optional value topText staying on top of the list. * * @param {string} optional value staying on top of the list. * @return {object} sorted option list. */ - -$.fn.sortSelect = function(text = "") { +$.fn.sortSelect = function(topText = "") { const op = this.children("option"); op.sort((a, b) => { - if (a.text === text) { + if (a.text === topText) { return -1; } - if (b.text === text) { + if (b.text === topText) { return 1; } return a.text.localeCompare(b.text, window.navigator.language, { ignorePunctuation: true }); diff --git a/src/main.html b/src/main.html index cd62d6e1dc..c0139ba8f8 100644 --- a/src/main.html +++ b/src/main.html @@ -49,7 +49,6 @@ - From 929567585a66ef13bc1f617368fdb04d9092989e Mon Sep 17 00:00:00 2001 From: HThuren Date: Wed, 21 Feb 2024 19:30:03 +0100 Subject: [PATCH 29/32] fix zero issue --- src/js/tabs/auxiliary.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index 01a5af6b02..9062dc235e 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -110,7 +110,7 @@ function getCategoryNames(table, buildKey) { function createCategorySelect(table, map) { let categorySelect = $('select.auxiliary_category_select'); - const categoryNameObj = getConfig('auxiliaryCategoryNameList'); // read user pre selected categories + const categoryNameObj = getConfig('auxiliaryCategoryNameList', ''); // read user pre selected categories let categoryNameList = categoryNameObj.auxiliaryCategoryNameList; if (categoryNameList.length == 0) { categoryNameList = getCategoryNames(table, 'all'); // empty choise -> select names from 'all' category From 569b4c9294d15eb9d4e74c21c7d51725f7f3e908 Mon Sep 17 00:00:00 2001 From: HThuren Date: Wed, 21 Feb 2024 20:44:48 +0100 Subject: [PATCH 30/32] Design changes --- locales/en/messages.json | 4 ---- src/css/tabs/auxiliary.less | 1 + src/js/tabs/auxiliary.js | 3 ++- src/tabs/auxiliary.html | 3 --- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index 957f5fd300..5b8c638e36 100755 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -2311,10 +2311,6 @@ "auxiliaryToggleUnused": { "message": "Hide unused modes" }, - "auxiliaryFilterCategory": { - "message": "Category", - "descripton": "Category for Flight modes" - }, "auxiliaryMin": { "message": "Min" }, diff --git a/src/css/tabs/auxiliary.less b/src/css/tabs/auxiliary.less index 87f2e5663d..bf5e24891a 100644 --- a/src/css/tabs/auxiliary.less +++ b/src/css/tabs/auxiliary.less @@ -33,6 +33,7 @@ .auxiliary_category_select_value { width: 100%; margin-bottom: 10px; + margin-top: 10px; } .range { .marker { diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index 9062dc235e..2a3ab5d611 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -46,7 +46,6 @@ const categoryTable = [ { name: 'VTX', buildKey: ['vtx'], modes: ['STICK COMMANDS DISABLE', 'VTX CONTROL DISABLE', 'VTX PIT MODE']}, ]; -let notSorted = true; let hideUnusedModes = false; let modeList = []; @@ -127,9 +126,11 @@ function createCategorySelect(table, map) { categorySelect.append(``); } } +/* else { categorySelect.append(``); } +*/ } const modeWidth = 125; diff --git a/src/tabs/auxiliary.html b/src/tabs/auxiliary.html index 8bd5457e87..3d589d147d 100644 --- a/src/tabs/auxiliary.html +++ b/src/tabs/auxiliary.html @@ -16,9 +16,6 @@
-
-
-
From e8a91e5e29bc147a8ec0352a135e82cd23635cac Mon Sep 17 00:00:00 2001 From: HThuren Date: Wed, 21 Feb 2024 20:54:30 +0100 Subject: [PATCH 31/32] Default list are all cat --- src/js/tabs/auxiliary.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index 2a3ab5d611..2966c43d2b 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -106,13 +106,22 @@ function getCategoryNames(table, buildKey) { return categoryChoise; } +function generateDefaultList(categoryTable) { + let list = []; + for (const item of categoryTable) { + list.push(item.name); + } + return list; +} + function createCategorySelect(table, map) { let categorySelect = $('select.auxiliary_category_select'); + const allCat = generateDefaultList(categoryTable); - const categoryNameObj = getConfig('auxiliaryCategoryNameList', ''); // read user pre selected categories + const categoryNameObj = getConfig('auxiliaryCategoryNameList', allCat); // read user pre selected categories, if empty default to complete list let categoryNameList = categoryNameObj.auxiliaryCategoryNameList; if (categoryNameList.length == 0) { - categoryNameList = getCategoryNames(table, 'all'); // empty choise -> select names from 'all' category + categoryNameList = getCategoryNames(table, 'all'); // empty choise -> select names from 'all' category setConfig({ auxiliaryCategoryNameList: categoryNameList }); } @@ -126,11 +135,6 @@ function createCategorySelect(table, map) { categorySelect.append(``); } } -/* - else { - categorySelect.append(``); - } -*/ } const modeWidth = 125; From f42d1743e2c6bb3e0753765423d7f18a9039b9e5 Mon Sep 17 00:00:00 2001 From: HThuren Date: Sun, 3 Mar 2024 12:11:55 +0100 Subject: [PATCH 32/32] fix from review --- src/js/tabs/auxiliary.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js index 2966c43d2b..6f4885a680 100644 --- a/src/js/tabs/auxiliary.js +++ b/src/js/tabs/auxiliary.js @@ -95,10 +95,10 @@ function updateSearchResults() { updateModes(); // update UI } -function getCategoryNames(table, buildKey) { +function getCategoryChoise(buildKey) { // return names for buildKey category let categoryChoise = []; - for (let value of table) { + for (let value of categoryTable) { if (value.name == buildKey) { categoryChoise.push(value.name); } @@ -114,24 +114,23 @@ function generateDefaultList(categoryTable) { return list; } -function createCategorySelect(table, map) { +function createCategorySelect(map) { let categorySelect = $('select.auxiliary_category_select'); const allCat = generateDefaultList(categoryTable); const categoryNameObj = getConfig('auxiliaryCategoryNameList', allCat); // read user pre selected categories, if empty default to complete list let categoryNameList = categoryNameObj.auxiliaryCategoryNameList; if (categoryNameList.length == 0) { - categoryNameList = getCategoryNames(table, 'all'); // empty choise -> select names from 'all' category + categoryNameList = getCategoryChoise('all'); // empty choise -> select names from 'all' category setConfig({ auxiliaryCategoryNameList: categoryNameList }); } - for (let value of table) { + for (let value of categoryTable) { if (inBuildMap(map, value.buildKey) || FC.CONFIG.buildOptions.length == 0) { // selected build option or local build if (categoryNameList.includes(value.name)) { categorySelect.append(``); - } - else { + } else { categorySelect.append(``); } } @@ -161,6 +160,7 @@ function createCategorySelect(table, map) { formatAllSelected() { return i18n.getMessage("dropDownAll"); }, }); } + function updateModes() { let hasUsedMode = false; @@ -181,7 +181,6 @@ function updateModes() { $('.mode .name').eq(i).html(FC.AUX_CONFIG[i]); } } else { - // ARM mode is a special case if (i == 0) { let armSwitchActive = false; @@ -216,11 +215,11 @@ function updateModes() { for (let i = 1; i < FC.AUX_CONFIG.length; i++) { // ARM has index 0 let modeElement = $(`#mode-${i}`); - if ( ! isSelectedMode(modeList, FC.AUX_CONFIG[i])) { - modeElement.toggle( false); + if (! isSelectedMode(modeList, FC.AUX_CONFIG[i])) { + modeElement.toggle(false); } else { - modeElement.toggle( true); + modeElement.toggle(true); if ( modeElement.find(' .range').length == 0 && modeElement.find(' .link').length == 0) { modeElement.toggle(!hideUnused); // unused mode } @@ -534,7 +533,7 @@ auxiliary.initialize = function (callback) { }); // create category multiple select - createCategorySelect(categoryTable, buildMap); + createCategorySelect(buildMap); // UI Hooks $('a.save').click(function () {