WebUI: use native function when converting to numbers

PR #22246.
This commit is contained in:
Chocobo1 2025-02-08 17:58:48 +08:00 committed by GitHub
commit c65a68251e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 6 deletions

View file

@ -1515,7 +1515,7 @@ window.addEventListener("DOMContentLoaded", () => {
}); });
let prop_h = LocalPreferences.get("properties_height_rel"); let prop_h = LocalPreferences.get("properties_height_rel");
if (prop_h !== null) if (prop_h !== null)
prop_h = prop_h.toFloat() * Window.getSize().y; prop_h = Number(prop_h) * Window.getSize().y;
else else
prop_h = Window.getSize().y / 2.0; prop_h = Window.getSize().y / 2.0;
new MochaUI.Panel({ new MochaUI.Panel({

View file

@ -1247,7 +1247,7 @@ window.qBittorrent.DynamicTable ??= (() => {
else { else {
if (progressColumnWidth < 0) if (progressColumnWidth < 0)
progressColumnWidth = td.offsetWidth; progressColumnWidth = td.offsetWidth;
td.append(new window.qBittorrent.ProgressBar.ProgressBar(progressFormatted.toFloat(), { td.append(new window.qBittorrent.ProgressBar.ProgressBar(progressFormatted, {
width: progressColumnWidth - 5 width: progressColumnWidth - 5
})); }));
td.resized = false; td.resized = false;
@ -2598,17 +2598,17 @@ window.qBittorrent.DynamicTable ??= (() => {
// progress // progress
this.columns["progress"].updateTd = function(td, row) { this.columns["progress"].updateTd = function(td, row) {
const id = row.rowId; const id = row.rowId;
const value = this.getRowValue(row); const value = Number(this.getRowValue(row));
const progressBar = $(`pbf_${id}`); const progressBar = $(`pbf_${id}`);
if (progressBar === null) { if (progressBar === null) {
td.append(new window.qBittorrent.ProgressBar.ProgressBar(value.toFloat(), { td.append(new window.qBittorrent.ProgressBar.ProgressBar(value, {
id: `pbf_${id}`, id: `pbf_${id}`,
width: 80 width: 80
})); }));
} }
else { else {
progressBar.setValue(value.toFloat()); progressBar.setValue(value);
} }
}; };
this.columns["progress"].staticWidth = 100; this.columns["progress"].staticWidth = 100;

View file

@ -2878,7 +2878,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
// Share Ratio Limiting // Share Ratio Limiting
let max_ratio = -1; let max_ratio = -1;
if ($("max_ratio_checkbox").checked) { if ($("max_ratio_checkbox").checked) {
max_ratio = $("max_ratio_value").value.toFloat(); max_ratio = Number($("max_ratio_value").value);
if (isNaN(max_ratio) || (max_ratio < 0) || (max_ratio > 9998)) { if (isNaN(max_ratio) || (max_ratio < 0) || (max_ratio > 9998)) {
alert("QBT_TR(Share ratio limit must be between 0 and 9998.)QBT_TR[CONTEXT=HttpServer]"); alert("QBT_TR(Share ratio limit must be between 0 and 9998.)QBT_TR[CONTEXT=HttpServer]");
return; return;