Use Number.parseInt/parseFloat/isNaN/isFinite instead of globals (S7773)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 00:26:59 +08:00
parent 12068281e9
commit 3768c6e5ec
11 changed files with 27 additions and 27 deletions

View File

@@ -341,7 +341,7 @@ const secondaryStatData = ref(null);
*/
const getPercentLabel = (val) => {
if (Number((val * 100).toFixed(1)) >= 100) return 100;
else return parseFloat((val * 100).toFixed(1));
else return Number.parseFloat((val * 100).toFixed(1));
};
/**

View File

@@ -505,7 +505,7 @@ const progressWidth = (value) => {
*/
const getPercentLabel = (val) => {
if (Number((val * 100).toFixed(1)) >= 100) return 100;
else return parseFloat((val * 100).toFixed(1));
else return Number.parseFloat((val * 100).toFixed(1));
};
/**

View File

@@ -277,7 +277,7 @@ watch(infinite404, (newValue) => {
*/
function getPercentLabel(val) {
if (Number((val * 100).toFixed(1)) >= 100) return 100;
else return parseFloat((val * 100).toFixed(1));
else return Number.parseFloat((val * 100).toFixed(1));
}
/**
* set progress bar width

View File

@@ -936,7 +936,7 @@ function sliderValueRange(e, direction) {
}
}
// Recalculate the chart mask
if (!isNaN(closestIndexes[0]) && !isNaN(closestIndexes[1]))
if (!Number.isNaN(closestIndexes[0]) && !Number.isNaN(closestIndexes[1]))
resizeMask(chartComplete.value);
else return;
}

View File

@@ -391,7 +391,7 @@ function sliderTimeRange(e, direction) {
if (direction === "start") endMinDate.value = e;
else if (direction === "end") startMaxDate.value = e;
// Recalculate the chart mask
if (!isNaN(closestIndexes[0]) && !isNaN(closestIndexes[1]))
if (!Number.isNaN(closestIndexes[0]) && !Number.isNaN(closestIndexes[1]))
resizeMask(chart.value);
else return;
}

View File

@@ -334,7 +334,7 @@ function barOptions() {
*/
function getPercentLabel(val) {
if (Number((val * 100).toFixed(1)) >= 100) return 100;
else return parseFloat((val * 100).toFixed(1));
else return Number.parseFloat((val * 100).toFixed(1));
}
/**

View File

@@ -179,7 +179,7 @@ const statData = ref(null);
*/
function getPercentLabel(val) {
if (Number((val * 100).toFixed(1)) >= 100) return 100;
else return parseFloat((val * 100).toFixed(1));
else return Number.parseFloat((val * 100).toFixed(1));
}
/** Transforms raw stats into display-ready format with localized numbers and time labels. */

View File

@@ -196,16 +196,16 @@ function onFocus(event) {
*/
function onChange(event) {
let decoratedInputValue;
if (isNaN(event.target.value)) {
if (Number.isNaN(Number(event.target.value))) {
event.target.value = "00";
} else {
event.target.value = event.target.value.toString();
}
decoratedInputValue = event.target.value.toString();
const inputValue = parseInt(event.target.value, 10);
const max = parseInt(event.target.dataset.max, 10);
const min = parseInt(event.target.dataset.min, 10);
const inputValue = Number.parseInt(event.target.value, 10);
const max = Number.parseInt(event.target.dataset.max, 10);
const min = Number.parseInt(event.target.dataset.min, 10);
if (inputValue > max) {
decoratedInputValue = max.toString().padStart(2, "0");
} else if (inputValue < min) {
@@ -266,8 +266,8 @@ function actionUpDown(input, goUp, selectIt = false) {
}
function getNewValue(input) {
const newVal = parseInt(input.value, 10);
return isNaN(newVal) ? 0 : newVal;
const newVal = Number.parseInt(input.value, 10);
return Number.isNaN(newVal) ? 0 : newVal;
}
function handleArrowUp(newVal, tUnit, input) {
@@ -294,7 +294,7 @@ function handleArrowDown(newVal, tUnit) {
function incrementPreviousUnit(input) {
if (input.dataset.index > 0) {
const prevUnit = document.querySelector(
`input[data-index="${parseInt(input.dataset.index, 10) - 1}"]`,
`input[data-index="${Number.parseInt(input.dataset.index, 10) - 1}"]`,
);
if (prevUnit) actionUpDown(prevUnit, true);
}
@@ -324,8 +324,8 @@ function updateInputValue(input, newVal, tUnit) {
* @param {string} [size] - 'max' or 'min' to set boundary days.
*/
function secondToDate(totalSec, size) {
totalSec = parseInt(totalSec, 10);
if (!isNaN(totalSec)) {
totalSec = Number.parseInt(totalSec, 10);
if (!Number.isNaN(totalSec)) {
seconds.value = totalSec % 60;
minutes.value = (Math.floor(totalSec - seconds.value) / 60) % 60;
hours.value = Math.floor(totalSec / 3600) % 24;
@@ -344,8 +344,8 @@ function calculateTotalSeconds() {
let total = 0;
for (const unit in tUnits.value) {
const val = parseInt(tUnits.value[unit].val, 10);
if (!isNaN(val)) {
const val = Number.parseInt(tUnits.value[unit].val, 10);
if (!Number.isNaN(val)) {
total += val * tUnits.value[unit].rate;
}
}