Skip to content

Commit

Permalink
WebUI: use recommended function for checking NaN values
Browse files Browse the repository at this point in the history
Also fix a few variable names along the way.
  • Loading branch information
Chocobo1 committed Feb 10, 2025
1 parent b052ad0 commit f0a84ad
Show file tree
Hide file tree
Showing 4 changed files with 233 additions and 223 deletions.
2 changes: 1 addition & 1 deletion src/webui/www/private/scripts/dynamicTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1856,7 +1856,7 @@ window.qBittorrent.DynamicTable ??= (() => {
};
const displayDate = function(td, row) {
const value = this.getRowValue(row) * 1000;
const formattedValue = (isNaN(value) || (value <= 0)) ? "" : (new Date(value).toLocaleString());
const formattedValue = (Number.isNaN(value) || (value <= 0)) ? "" : (new Date(value).toLocaleString());
td.textContent = formattedValue;
td.title = formattedValue;
};
Expand Down
4 changes: 2 additions & 2 deletions src/webui/www/private/scripts/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ window.qBittorrent.Misc ??= (() => {

const friendlyPercentage = (value) => {
let percentage = (value * 100).round(1);
if (isNaN(percentage) || (percentage < 0))
if (Number.isNaN(percentage) || (percentage < 0))
percentage = 0;
if (percentage > 100)
percentage = 100;
Expand All @@ -189,7 +189,7 @@ window.qBittorrent.Misc ??= (() => {

const tryToNumber = (str) => {
const num = Number(str);
return (isNaN(num) ? str : num);
return (Number.isNaN(num) ? str : num);
};

const ver = versionString.split(".", 4).map(val => tryToNumber(val));
Expand Down
2 changes: 1 addition & 1 deletion src/webui/www/private/scripts/progressbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ window.qBittorrent.ProgressBar ??= (() => {

function ProgressBar_setValue(value) {
value = parseFloat(value);
if (isNaN(value))
if (Number.isNaN(value))
value = 0;
value = Math.min(Math.max(value, 0), 100);
this.vals.value = value;
Expand Down
Loading

0 comments on commit f0a84ad

Please sign in to comment.