WebUI: inline redundant function

This also fix share ratio dialog which had been broken in recent cleanup.
This commit is contained in:
Chocobo1 2025-02-08 01:11:13 +08:00
commit 5218442620
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
2 changed files with 3 additions and 9 deletions

View file

@ -37,7 +37,6 @@ window.qBittorrent.Misc ??= (() => {
friendlyUnit: friendlyUnit, friendlyUnit: friendlyUnit,
friendlyDuration: friendlyDuration, friendlyDuration: friendlyDuration,
friendlyPercentage: friendlyPercentage, friendlyPercentage: friendlyPercentage,
friendlyFloat: friendlyFloat,
parseHtmlLinks: parseHtmlLinks, parseHtmlLinks: parseHtmlLinks,
parseVersion: parseVersion, parseVersion: parseVersion,
escapeHtml: escapeHtml, escapeHtml: escapeHtml,
@ -172,10 +171,6 @@ window.qBittorrent.Misc ??= (() => {
return `${percentage.toFixed(1)}%`; return `${percentage.toFixed(1)}%`;
}; };
const friendlyFloat = (value, precision) => {
return parseFloat(value).toFixed(precision);
};
/* /*
* JS counterpart of the function in src/misc.cpp * JS counterpart of the function in src/misc.cpp
*/ */

View file

@ -9,7 +9,6 @@
<script src="scripts/lib/MooTools-More-1.6.0-compat-compressed.js"></script> <script src="scripts/lib/MooTools-More-1.6.0-compat-compressed.js"></script>
<script src="scripts/localpreferences.js?v=${CACHEID}"></script> <script src="scripts/localpreferences.js?v=${CACHEID}"></script>
<script src="scripts/color-scheme.js?v=${CACHEID}"></script> <script src="scripts/color-scheme.js?v=${CACHEID}"></script>
<script src="scripts/misc.js?locale=${LANG}&v=${CACHEID}"></script>
<script> <script>
"use strict"; "use strict";
@ -34,10 +33,10 @@
const origValues = searchParams.get("orig").split("|"); const origValues = searchParams.get("orig").split("|");
const values = { const values = {
ratioLimit: window.qBittorrent.Misc.friendlyFloat(origValues[0], 2), ratioLimit: Number(origValues[0]),
seedingTimeLimit: Number(origValues[1]), seedingTimeLimit: Number(origValues[1]),
inactiveSeedingTimeLimit: Number(origValues[2]), inactiveSeedingTimeLimit: Number(origValues[2]),
maxRatio: window.qBittorrent.Misc.friendlyFloat(origValues[3], 2), maxRatio: Number(origValues[3]),
maxSeedingTime: Number(origValues[4]), maxSeedingTime: Number(origValues[4]),
maxInactiveSeedingTime: Number(origValues[5]) maxInactiveSeedingTime: Number(origValues[5])
}; };
@ -58,7 +57,7 @@
setSelectedRadioValue("shareLimit", "custom"); setSelectedRadioValue("shareLimit", "custom");
if (values.ratioLimit >= 0) { if (values.ratioLimit >= 0) {
$("setRatio").checked = true; $("setRatio").checked = true;
$("ratio").value = values.ratioLimit; $("ratio").value = values.ratioLimit.toFixed(2);
} }
if (values.seedingTimeLimit >= 0) { if (values.seedingTimeLimit >= 0) {
$("setTotalMinutes").checked = true; $("setTotalMinutes").checked = true;