11document . addEventListener ( 'DOMContentLoaded' , function ( ) {
22 const gamepadHelper = new GamepadHelper ( )
3- const gamepadHelperVersion = window . gamepadHelperVersion ;
3+ const gamepadHelperVersion = globalThis . gamepadHelperVersion ;
44 let gamepads = { } ;
55 let activeGamepadIndex = null ;
66 let animationFrameId = null ;
@@ -21,7 +21,7 @@ document.addEventListener('DOMContentLoaded', function() {
2121 const themeObserver = new MutationObserver ( function ( mutations ) {
2222 mutations . forEach ( function ( mutation ) {
2323 if ( mutation . type === 'attributes' && mutation . attributeName === 'data-bs-theme' ) {
24- // Theme changed, reinitialize buttons with new color scheme
24+ // Theme changed, reinitialize buttons with a new color scheme
2525 if ( activeGamepadIndex !== null ) {
2626 initGamepadButtons ( ) ;
2727 }
@@ -36,7 +36,7 @@ document.addEventListener('DOMContentLoaded', function() {
3636 } ) ;
3737
3838 // Setup gamepad event listeners
39- window . addEventListener ( "gamepadconnected" , function ( e ) {
39+ globalThis . addEventListener ( "gamepadconnected" , function ( e ) {
4040 gamepads [ e . gamepad . index ] = e . gamepad ;
4141
4242 // Always activate the newly connected gamepad
@@ -51,7 +51,7 @@ document.addEventListener('DOMContentLoaded', function() {
5151 }
5252 } ) ;
5353
54- window . addEventListener ( "gamepaddisconnected" , function ( e ) {
54+ globalThis . addEventListener ( "gamepaddisconnected" , function ( e ) {
5555 delete gamepads [ e . gamepad . index ] ;
5656 updateGamepadSelector ( ) ;
5757
@@ -76,7 +76,7 @@ document.addEventListener('DOMContentLoaded', function() {
7676 const card = e . target . closest ( '.gamepad-selector-card' ) ;
7777 if ( card ) {
7878 activeGamepadIndex = Number . parseInt ( card . dataset . index ) ;
79- updateGamepadSelector ( ) ; // Re-render to update active state
79+ updateGamepadSelector ( ) ; // Re-render to update the active state
8080 initGamepadButtons ( ) ;
8181 initGamepadAxes ( ) ;
8282 }
@@ -176,7 +176,7 @@ document.addEventListener('DOMContentLoaded', function() {
176176
177177 const controllerType = gamepadHelper . detectControllerType ( gamepad . id ) ;
178178
179- // Detect current theme - use Black icons for light theme, White icons for dark theme
179+ // Detect the current theme - use Black icons for the light theme, White icons for the dark theme
180180 const isDarkTheme = document . documentElement . dataset . bsTheme === 'dark' ;
181181 const colorScheme = isDarkTheme ? 'White' : 'Black' ;
182182
@@ -206,7 +206,7 @@ document.addEventListener('DOMContentLoaded', function() {
206206 const buttonContent = document . createElement ( 'div' ) ;
207207 buttonContent . className = 'button-content' ;
208208
209- // Add either image with fallback text, or just text
209+ // Add either image with fallback text or just text
210210 if ( buttonImagePath ) {
211211 buttonContent . innerHTML = `
212212 <div class="button-image-container">
@@ -318,7 +318,7 @@ document.addEventListener('DOMContentLoaded', function() {
318318 vibrationStatus . innerHTML = `<span class="badge bg-success">Supported</span> Actuator type: <span class="badge bg-secondary">${ vibrationCapabilities . type } </span>` ;
319319 vibrationButtons . classList . remove ( 'd-none' ) ;
320320
321- // Show appropriate controls based on actuator type
321+ // Show appropriate controls based on an actuator type
322322 if ( vibrationCapabilities . type === 'dual-rumble' ) {
323323 dualRumbleControls . classList . remove ( 'd-none' ) ;
324324 } else {
@@ -357,12 +357,12 @@ document.addEventListener('DOMContentLoaded', function() {
357357 // Only the right side rotates for the first half
358358 progressBarRightElement . style . transform = `rotate(${ degrees } deg)` ;
359359 } else {
360- // Right side is at full rotation, left side rotates for the remainder
360+ // The right side is at full rotation, the left side rotates for the remainder
361361 progressBarRightElement . style . transform = 'rotate(180deg)' ;
362362 progressBarLeftElement . style . transform = `rotate(${ degrees - 180 } deg)` ;
363363 }
364364
365- // Add/remove active class based on button state
365+ // Add/remove the active class based on the button state
366366 if ( isPressed ) {
367367 buttonElement . classList . add ( 'active' ) ;
368368 } else {
@@ -388,7 +388,7 @@ document.addEventListener('DOMContentLoaded', function() {
388388 const progressWidth = ( ( axisValue + 1 ) / 2 ) * 100 ;
389389 axisProgressElement . style . width = `${ progressWidth } %` ;
390390
391- // Change color based on direction
391+ // Change color based on the direction
392392 if ( axisValue > 0.1 ) {
393393 axisProgressElement . classList . remove ( 'bg-info' , 'bg-danger' ) ;
394394 axisProgressElement . classList . add ( 'bg-success' ) ;
@@ -506,7 +506,7 @@ document.addEventListener('DOMContentLoaded', function() {
506506 function startGamepadLoop ( ) {
507507 if ( animationFrameId ) return ;
508508
509- // Make sure UI elements are initialized when starting loop
509+ // Make sure UI elements are initialized when starting the loop
510510 if ( activeGamepadIndex !== null ) {
511511 initGamepadButtons ( ) ;
512512 initGamepadAxes ( ) ;
0 commit comments