@@ -490,35 +490,46 @@ led_strip.initialize = function (callback, scrollPosition) {
490490 return $ ( that ) . is ( ':checked' ) ;
491491 }
492492
493+ // Disable all other functions except the one being activated
494+ function disableOtherFunctions ( activeFunction ) {
495+ const functions = [ '.function-o' , '.function-b' , '.function-x' ] ;
496+
497+ functions . forEach ( func => {
498+ if ( ! activeFunction . is ( func ) ) {
499+ const checkbox = $ ( `.checkbox ${ func } ` ) ;
500+ if ( checkbox . is ( ':checked' ) ) {
501+ checkbox . prop ( 'checked' , false ) ;
502+ checkbox . trigger ( 'change' ) ;
503+ toggleSwitch ( checkbox , func . slice ( - 1 ) ) ; // Pass the last character as the identifier
504+ }
505+ }
506+ } ) ;
507+ }
508+
493509 // UI: check-box toggle
494510 $ ( '.checkbox' ) . on ( 'change' , function ( e ) {
495511 if ( e . originalEvent ) {
496512 // user-triggered event
497513 const that = $ ( this ) . find ( 'input' ) ;
498514
499- //disable Blink always or Larson scanner, both functions are not working properly at the same time
500- if ( that . is ( '.function-o' ) ) {
501- const blink = $ ( '.checkbox .function-b' ) ;
502- if ( blink . is ( ':checked' ) ) {
503- blink . prop ( 'checked' , false ) ;
504- blink . trigger ( 'change' ) ;
505- toggleSwitch ( blink , 'b' ) ;
515+ // Event handlers for each function
516+ $ ( '.checkbox .function-o' ) . on ( 'change' , function ( ) {
517+ if ( $ ( this ) . is ( ':checked' ) ) {
518+ disableOtherFunctions ( $ ( this ) ) ;
506519 }
507- } else if ( that . is ( '.function-b' ) ) {
508- const aurora = $ ( '.checkbox .function-x' ) ;
509- if ( $ ( '.checkbox .function-x' ) . is ( ':checked' ) ) {
510- aurora . prop ( 'checked' , false ) ;
511- aurora . trigger ( 'change' ) ;
512- toggleSwitch ( aurora , 'x' ) ;
520+ } ) ;
521+
522+ $ ( '.checkbox .function-b' ) . on ( 'change' , function ( ) {
523+ if ( $ ( this ) . is ( ':checked' ) ) {
524+ disableOtherFunctions ( $ ( this ) ) ;
513525 }
514- } else if ( that . is ( '.function-b' ) ) {
515- const larson = $ ( '.checkbox .function-o' ) ;
516- if ( $ ( '.checkbox .function-o' ) . is ( ':checked' ) ) {
517- larson . prop ( 'checked' , false ) ;
518- larson . trigger ( 'change' ) ;
519- toggleSwitch ( larson , 'o' ) ;
526+ } ) ;
527+
528+ $ ( '.checkbox .function-x' ) . on ( 'change' , function ( ) {
529+ if ( $ ( this ) . is ( ':checked' ) ) {
530+ disableOtherFunctions ( $ ( this ) ) ;
520531 }
521- }
532+ } ) ;
522533
523534 //Change Rainbow slider visibility
524535 if ( that . is ( '.function-y' ) ) {
0 commit comments