@@ -241,6 +241,14 @@ firmware_flasher.initialize = function (callback) {
241
241
}
242
242
}
243
243
244
+ function updateOsdProtocolColor ( ) {
245
+ const osdProtocol = $ ( 'select[name="osdProtocols"] option:selected' ) . val ( ) ;
246
+ $ ( 'select[name="osdProtocols"]' )
247
+ . next ( ".select2-container" )
248
+ . find ( ".select2-selection__rendered" )
249
+ . attr ( "style" , osdProtocol === "" ? "color: red !important" : "" ) ;
250
+ }
251
+
244
252
function buildOptions ( data ) {
245
253
if ( ! ispConnected ( ) ) {
246
254
return ;
@@ -267,6 +275,12 @@ firmware_flasher.initialize = function (callback) {
267
275
buildOptionsList ( $ ( 'select[name="options"]' ) , data . generalOptions ) ;
268
276
buildOptionsList ( $ ( 'select[name="motorProtocols"]' ) , data . motorProtocols ) ;
269
277
278
+ // Using setTimeout to ensure this runs after Select2 has finished initializing/rendering
279
+ setTimeout ( updateOsdProtocolColor , 0 ) ;
280
+
281
+ // Add change handler to update color when selection changes
282
+ $ ( 'select[name="osdProtocols"]' ) . on ( "change" , updateOsdProtocolColor ) ;
283
+
270
284
if ( ! self . validateBuildKey ( ) ) {
271
285
preselectRadioProtocolFromStorage ( ) ;
272
286
}
@@ -838,11 +852,35 @@ firmware_flasher.initialize = function (callback) {
838
852
self . cancelBuild = true ;
839
853
} ) ;
840
854
841
- $ ( "a.load_remote_file" ) . on ( "click" , function ( evt ) {
855
+ async function enforceOSDSelection ( ) {
856
+ if ( $ ( 'select[name="osdProtocols"] option:selected' ) . val ( ) === "" ) {
857
+ return new Promise ( ( resolve ) => {
858
+ GUI . showYesNoDialog ( {
859
+ title : i18n . getMessage ( "firmwareFlasherOSDProtocolNotSelected" ) ,
860
+ text : i18n . getMessage ( "firmwareFlasherOSDProtocolNotSelectedDescription" ) ,
861
+ buttonYesText : i18n . getMessage ( "firmwareFlasherOSDProtocolNotSelectedContinue" ) ,
862
+ buttonNoText : i18n . getMessage ( "firmwareFlasherOSDProtocolSelect" ) ,
863
+ buttonYesCallback : ( ) => resolve ( true ) ,
864
+ buttonNoCallback : ( ) => resolve ( false ) ,
865
+ } ) ;
866
+ } ) ;
867
+ } else {
868
+ return true ; // No issue with OSD selection
869
+ }
870
+ }
871
+
872
+ $ ( "a.load_remote_file" ) . on ( "click" , async function ( evt ) {
842
873
if ( ! self . selectedBoard ) {
843
874
return ;
844
875
}
845
876
877
+ // Ensure the user has selected an OSD protocol
878
+ const shouldContinue = await enforceOSDSelection ( ) ;
879
+
880
+ if ( ! shouldContinue ) {
881
+ return ;
882
+ }
883
+
846
884
// Reset button when loading a new firmware
847
885
self . enableFlashButton ( false ) ;
848
886
self . enableLoadRemoteFileButton ( false ) ;
0 commit comments