@@ -13,34 +13,50 @@ import inflection from "inflection";
1313
1414const auxiliary = { } ;
1515
16+ // BF build Options mapped to build Key
17+ let buildMap = [
18+ { buildKey : 'xxx' , buildOption : [ 'USE_ARCO_TRAINER' , 'USE_DASHBOARD' , 'USE_PINIO' ] } ,
19+ { buildKey : 'cam' , buildOption : [ 'USE_CAMERA_CONTROL' ] } ,
20+ { buildKey : 'dshot' , buildOption : [ 'USE_DSHOT' ] } ,
21+ { buildKey : 'gps' , buildOption : [ 'USE_GPS' , 'USE_GPS_PLUS_CODES' ] } ,
22+ { buildKey : 'led_strip' , buildOption : [ 'USE_LED_STRIP' , 'USE_LED_STRIP_64' ] } ,
23+ { buildKey : 'mag' , buildOption : [ 'USE_MAG' ] } ,
24+ { buildKey : 'osd' , buildOption : [ 'USE_OSD' , 'USE_OSD_SD' , 'USE_OSD_HD' , 'USE_FRSKYOSD' ] } ,
25+ { buildKey : 'serial' , buildOption : [ 'USE_SERIALRX' , 'USE_SERIALRX_FPORT' ] } ,
26+ { buildKey : 'servos' , buildOption : [ 'USE_SERVOS' ] } ,
27+ { buildKey : 'telemetry' , buildOption : [ 'USE_TELEMETRY' , 'USE_TELEMETRY_SMARTPORT' ] } ,
28+ { buildKey : 'vtx' , buildOption : [ 'USE_VTX' ] } ,
29+ ] ;
30+
1631const flightModes = [ "ARM" , "ANGLE" , "HORIZON" , "ANTI GRAVITY" , "MAG" , "HEADFREE" , "HEADADJ" , "SERVO1" , "SERVO2" , "SERVO3" ,
17- "FAILSAFE" , "AIR MODE" , "3D" , " FPV ANGLE MIX", "FLIP OVER AFTER CRASH" , "USER1" , "USER2" , "USER3" , "USER4" , "ACRO TRAINER" , "LAUNCH CONTROL" ] ;
32+ "FAILSAFE" , "AIR MODE" , "FPV ANGLE MIX" , "FLIP OVER AFTER CRASH" , "USER1" , "USER2" , "USER3" , "USER4" , "ACRO TRAINER" , "LAUNCH CONTROL" ] ;
1833
1934// Categories
20- let categoryTable = createTable ( [
21- [ '3D' , '3D DISABLE / SWITCH' ] ,
22- [ 'BEEP' , 'BEEPER' , 'BEEPER MUTE' , 'GPS BEEP SATELLITE COUNT' ] ,
23- [ 'BLACKBOX' , 'BLACKBOX' , 'BLACKBOX ERASE' ] ,
24- [ 'CAM' , 'CAMERA CONTROL 1' , 'CAMERA CONTROL 2' , 'CAMERA CONTROL 3' ] ,
25- [ 'FLIGHTMODE' , 'ARM' , 'ANGLE' , 'HORIZON' , 'ANTI GRAVITY' , 'MAG' , 'HEADFREE' , 'HEADADJ' , 'SERVO1' , 'SERVO2' , 'SERVO3' ,
26- 'FAILSAFE' , 'AIR MODE' , '3D' , 'FPV ANGLE MIX' , 'FLIP OVER AFTER CRASH' , 'USER1' , 'USER2' , 'USER3' , 'USER4' , 'ACRO TRAINER' , 'LAUNCH CONTROL' ] ,
27- [ 'GPS' , 'GPS BEEP SATELLITE COUNT' , 'GPS RESCUE' ] ,
28- [ 'LED' , 'LEDLOW' ] ,
29- [ 'OSD' , 'OSD DISABLE' ] ,
30- [ 'OTHER' , 'CALIB' , 'MSP OVERRIDE' , 'LAP TIMER RESET' , 'PASSTHRU' , 'PARALYZE' , 'PID AUDIO' , 'PREARM' , 'TELEMETRY' ] ,
31- [ 'SERVO' , 'SERVO1' , 'SERVO2' , 'SERVO3' ] ,
32- [ 'USER' , 'USER1' , 'USER2' , 'USER3' , 'USER4' ] ,
33- [ 'VTX' , 'STICK COMMANDS DISABLE' , 'VTX CONTROL DISABLE' , 'VTX PIT MODE' ] ,
34- ] ) ;
35-
36- const categoryFieldsSelect = $ ( ".auxiliary_filter_category select" ) ;
35+ let categoryTable = [
36+ { name : '3D' , buildKey : [ 'dshot' ] , modes : [ '3D' , '3D DISABLE / SWITCH' ] } ,
37+ { name : 'BEEP' , buildKey : [ 'all' ] , modes : [ 'BEEPER' , 'BEEPER MUTE' , 'GPS BEEP SATELLITE COUNT' ] } ,
38+ { name : 'BLACKBOX' , buildKey : [ 'all' ] , modes : [ 'BLACKBOX' , 'BLACKBOX ERASE' ] } ,
39+ { name : 'CAM' , buildKey : [ 'cam' ] , modes : [ 'CAMERA CONTROL 1' , 'CAMERA CONTROL 2' , 'CAMERA CONTROL 3' ] } ,
40+ { name : 'FLIGHTMODE' , buildKey : [ 'all' ] , modes : flightModes } ,
41+ { name : 'GPS' , buildKey : [ 'gps' ] , modes : [ 'GPS BEEP SATELLITE COUNT' , 'GPS RESCUE' ] } ,
42+ { name : 'LED' , buildKey : [ 'led_strip' ] , modes : [ 'LEDLOW' ] } ,
43+ { name : 'OSD' , buildKey : [ 'osd' ] , modes : [ 'OSD DISABLE' ] } ,
44+ { name : 'OTHER' , buildKey : [ 'all' ] , modes : [ 'CALIB' , 'MSP OVERRIDE' , 'LAP TIMER RESET' , 'PASSTHRU' , 'PARALYZE' , 'PID AUDIO' , 'PREARM' ] } ,
45+ { name : 'SERVO' , buildKey : [ 'servos' ] , modes : [ 'SERVO1' , 'SERVO2' , 'SERVO3' ] } ,
46+ { name : 'TELEMETRI' , buildKey : [ 'telemetry' ] , modes : [ 'TELEMETRY' ] } ,
47+ { name : 'USER' , buildKey : [ 'all' ] , modes : [ 'USER1' , 'USER2' , 'USER3' , 'USER4' ] } ,
48+ { name : 'VTX' , buildKey : [ 'vtx' ] , modes : [ 'STICK COMMANDS DISABLE' , 'VTX CONTROL DISABLE' , 'VTX PIT MODE' ] } ,
49+ ] ;
50+
51+
52+ const categoryFieldsSelect = $ ( '.auxiliary_category' ) ;
3753
3854function createTable ( data ) {
3955 // Create a dynamic table with fixed values
4056 let table = [ ] ;
4157
4258 for ( let i = 0 ; i < data . length ; i ++ ) {
43- let row = data [ i ] . slice ( ) ; // Use slice to clone the array
59+ let row = data [ i ] . modes . slice ( ) ; // Use slice to clone the array
4460 table . push ( row ) ;
4561 }
4662
@@ -50,17 +66,64 @@ function createTable(data) {
5066// Function to display the table in the console
5167function displayTable ( table ) {
5268 for ( let i = 0 ; i < table . length ; i ++ ) {
53- console . log ( table [ i ] . join ( '\t' ) ) ;
69+ console . log ( `${ table [ i ] . name } : ${ table [ i ] . modes } ` ) ;
70+ }
71+ }
72+
73+ // Function to simulate mouseover and select an option
74+ function simulateMouseoverAndSelectOption ( selectElement , optionIndex ) {
75+ // Trigger mouseover event
76+ const mouseoverEvent = new Event ( 'mouseover' ) ;
77+ selectElement . dispatchEvent ( mouseoverEvent ) ;
78+
79+ // Select the specified option
80+ selectElement . selectedIndex = optionIndex ;
81+
82+ // Trigger change event to notify any listeners
83+ const changeEvent = new Event ( 'change' ) ;
84+ selectElement . dispatchEvent ( changeEvent ) ;
85+ }
86+
87+ // Function to iterate over options and simulate mouseover and selection
88+ function simulateMouseoverAndSelectForEachOption ( ) {
89+ // Get the select element
90+ const selectElement = document . getElementById ( 'yourSelectElementId' ) ; // Replace with your actual select element ID
91+
92+ // Iterate over each option and simulate mouseover and selection
93+ for ( let i = 0 ; i < selectElement . options . length ; i ++ ) {
94+ simulateMouseoverAndSelectOption ( selectElement , i ) ;
95+ // You can add a delay here if needed
96+ // setTimeout(() => {
97+ // simulateMouseoverAndSelectOption(selectElement, i);
98+ // }, 1000 * i); // Adjust the delay as needed
99+ }
100+ }
101+
102+ // Call the function when needed
103+ //simulateMouseoverAndSelectForEachOption();
104+ /*
105+ Replace 'yourSelectElementId' with the actual ID of your select element.
106+ The simulateMouseoverAndSelectForEachOption function iterates over each option in the select element, simulates a mouseover, and selects the option.
107+ You can also add a delay between each iteration if needed (commented out in the code). Adjust the delay according to your requirements.
108+ */
109+
110+ function createCategorySelect ( table ) {
111+ for ( let i = 0 ; i < table . length ; i ++ ) {
112+ const str = `<option value="${ table [ i ] . name } ">${ table [ i ] . name } </option>` ;
113+ $ ( '#auxiliary_filter_category .select' ) . append ( `<option value="${ table [ i ] . name } ">${ table [ i ] . name } </option>` ) ;
114+ console . log ( str ) ;
54115 }
55116}
56117
118+ function isFlightMode ( name ) {
119+ return flightModes . includes ( name ) ;
120+ }
121+
57122auxiliary . initialize = function ( callback ) {
58123 GUI . active_tab_ref = this ;
59124 GUI . active_tab = 'auxiliary' ;
60125 let prevChannelsValues = null ;
61126
62- this . _selectCategory = $ ( '#auxiliary_filter_category' ) ;
63-
64127 function get_mode_ranges ( ) {
65128 MSP . send_message ( MSPCodes . MSP_MODE_RANGES , false , false , get_mode_ranges_extra ) ;
66129 }
@@ -89,10 +152,6 @@ auxiliary.initialize = function (callback) {
89152 $ ( '#content' ) . load ( "./tabs/auxiliary.html" , process_html ) ;
90153 }
91154
92- function isFlightMode ( name ) {
93- return flightModes . includes ( name ) ;
94- }
95-
96155 MSP . send_message ( MSPCodes . MSP_BOXNAMES , false , false , get_mode_ranges ) ;
97156
98157 function createMode ( modeIndex , modeId ) {
@@ -355,6 +414,7 @@ auxiliary.initialize = function (callback) {
355414
356415 // generate category multiple select
357416 displayTable ( categoryTable ) ;
417+ createCategorySelect ( categoryTable ) ;
358418
359419 const length = Math . max ( ...( FC . AUX_CONFIG . map ( el => el . length ) ) ) ;
360420 $ ( '.tab-auxiliary .mode .info' ) . css ( 'min-width' , `${ Math . round ( length * getTextWidth ( 'A' ) ) } px` ) ;
0 commit comments