Skip to content

Commit 79792cc

Browse files
fix: Use Number.parseInt/parseFloat for parsing values (#287)
1 parent 9badacc commit 79792cc

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

assets/js/gamepad-tester.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ document.addEventListener('DOMContentLoaded', function() {
4444
// If there are other gamepads, select the first one
4545
const remainingIndices = Object.keys(gamepads);
4646
if (remainingIndices.length > 0) {
47-
activeGamepadIndex = parseInt(remainingIndices[0]);
47+
activeGamepadIndex = Number.parseInt(remainingIndices[0]);
4848
gamepadSelector.value = activeGamepadIndex;
4949
} else {
5050
stopGamepadLoop();
@@ -54,7 +54,7 @@ document.addEventListener('DOMContentLoaded', function() {
5454

5555
// Event listener for gamepad selector change
5656
gamepadSelector.addEventListener('change', function() {
57-
activeGamepadIndex = parseInt(this.value);
57+
activeGamepadIndex = Number.parseInt(this.value);
5858
initGamepadButtons();
5959
initGamepadAxes();
6060
});
@@ -409,14 +409,14 @@ document.addEventListener('DOMContentLoaded', function() {
409409
const vibrationCapabilities = gamepadHelper.getVibrationCapabilities(gamepad);
410410
if (!vibrationCapabilities.supported) return;
411411

412-
const duration = parseInt(document.getElementById('vibration-duration').value);
412+
const duration = Number.parseInt(document.getElementById('vibration-duration').value);
413413
let vibrationOptions = { duration };
414414

415415
if (vibrationCapabilities.type === 'dual-rumble') {
416-
vibrationOptions.weakMagnitude = parseFloat(document.getElementById('vibration-weak').value);
417-
vibrationOptions.strongMagnitude = parseFloat(document.getElementById('vibration-strong').value);
416+
vibrationOptions.weakMagnitude = Number.parseFloat(document.getElementById('vibration-weak').value);
417+
vibrationOptions.strongMagnitude = Number.parseFloat(document.getElementById('vibration-strong').value);
418418
} else {
419-
const magnitude = parseFloat(document.getElementById('vibration-magnitude').value);
419+
const magnitude = Number.parseFloat(document.getElementById('vibration-magnitude').value);
420420
vibrationOptions.weakMagnitude = magnitude;
421421
vibrationOptions.strongMagnitude = magnitude;
422422
vibrationOptions.magnitude = magnitude;
@@ -491,7 +491,7 @@ document.addEventListener('DOMContentLoaded', function() {
491491

492492
// If we have gamepads already, start the loop
493493
if (Object.keys(gamepads).length > 0) {
494-
activeGamepadIndex = parseInt(Object.keys(gamepads)[0]);
494+
activeGamepadIndex = Number.parseInt(Object.keys(gamepads)[0]);
495495
updateStatus(`Gamepad ${gamepads[activeGamepadIndex].id} connected`);
496496
startGamepadLoop();
497497
}

assets/js/roadmap.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ document.addEventListener('DOMContentLoaded', function() {
8686
labelEl.style.backgroundColor = `#${label.color}`;
8787

8888
// Determine if label text should be dark or light based on background
89-
const r = parseInt(label.color.substring(0, 2), 16);
90-
const g = parseInt(label.color.substring(2, 4), 16);
91-
const b = parseInt(label.color.substring(4, 6), 16);
89+
const r = Number.parseInt(label.color.substring(0, 2), 16);
90+
const g = Number.parseInt(label.color.substring(2, 4), 16);
91+
const b = Number.parseInt(label.color.substring(4, 6), 16);
9292
const brightness = (r * 299 + g * 587 + b * 114) / 1000;
9393
labelEl.style.color = brightness > 125 ? '#000' : '#fff';
9494

@@ -173,9 +173,9 @@ document.addEventListener('DOMContentLoaded', function() {
173173
labelEl.style.backgroundColor = `#${label.color}`;
174174

175175
// Determine if label text should be dark or light based on background
176-
const r = parseInt(label.color.substring(0, 2), 16);
177-
const g = parseInt(label.color.substring(2, 4), 16);
178-
const b = parseInt(label.color.substring(4, 6), 16);
176+
const r = Number.parseInt(label.color.substring(0, 2), 16);
177+
const g = Number.parseInt(label.color.substring(2, 4), 16);
178+
const b = Number.parseInt(label.color.substring(4, 6), 16);
179179
const brightness = (r * 299 + g * 587 + b * 114) / 1000;
180180
labelEl.style.color = brightness > 125 ? '#000' : '#fff';
181181

0 commit comments

Comments
 (0)