WebUI: use recommended function for checking NaN values

Also fix a few variable names along the way.

PR #22264.
This commit is contained in:
Chocobo1 2025-02-12 15:11:54 +08:00 committed by GitHub
commit 38070c6eee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 232 additions and 222 deletions

View file

@ -1856,7 +1856,7 @@ window.qBittorrent.DynamicTable ??= (() => {
}; };
const displayDate = function(td, row) { const displayDate = function(td, row) {
const value = this.getRowValue(row) * 1000; 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.textContent = formattedValue;
td.title = formattedValue; td.title = formattedValue;
}; };

View file

@ -164,7 +164,7 @@ window.qBittorrent.Misc ??= (() => {
const friendlyPercentage = (value) => { const friendlyPercentage = (value) => {
let percentage = (value * 100).round(1); let percentage = (value * 100).round(1);
if (isNaN(percentage) || (percentage < 0)) if (Number.isNaN(percentage) || (percentage < 0))
percentage = 0; percentage = 0;
if (percentage > 100) if (percentage > 100)
percentage = 100; percentage = 100;
@ -189,7 +189,7 @@ window.qBittorrent.Misc ??= (() => {
const tryToNumber = (str) => { const tryToNumber = (str) => {
const num = Number(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)); const ver = versionString.split(".", 4).map(val => tryToNumber(val));

View file

@ -117,7 +117,7 @@ window.qBittorrent.ProgressBar ??= (() => {
function ProgressBar_setValue(value) { function ProgressBar_setValue(value) {
value = parseFloat(value); value = parseFloat(value);
if (isNaN(value)) if (Number.isNaN(value))
value = 0; value = 0;
value = Math.min(Math.max(value, 0), 100); value = Math.min(Math.max(value, 0), 100);
this.vals.value = value; this.vals.value = value;

View file

@ -399,13 +399,13 @@
<fieldset class="settings"> <fieldset class="settings">
<legend>QBT_TR(Listening Port)QBT_TR[CONTEXT=OptionsDialog]</legend> <legend>QBT_TR(Listening Port)QBT_TR[CONTEXT=OptionsDialog]</legend>
<div class="formRow"> <div class="formRow">
<label for="port_value">QBT_TR(Port used for incoming connections:)QBT_TR[CONTEXT=OptionsDialog]</label> <label for="portValue">QBT_TR(Port used for incoming connections:)QBT_TR[CONTEXT=OptionsDialog]</label>
<input type="text" id="port_value" style="width: 6em;" title="QBT_TR(Set to 0 to let your system pick an unused port)QBT_TR[CONTEXT=OptionsDialog]"> <input type="text" id="portValue" style="width: 6em;" title="QBT_TR(Set to 0 to let your system pick an unused port)QBT_TR[CONTEXT=OptionsDialog]">
<button type="button" onclick="qBittorrent.Preferences.generateRandomPort();">QBT_TR(Random)QBT_TR[CONTEXT=OptionsDialog]</button> <button type="button" onclick="qBittorrent.Preferences.generateRandomPort();">QBT_TR(Random)QBT_TR[CONTEXT=OptionsDialog]</button>
</div> </div>
<div class="formRow"> <div class="formRow">
<input type="checkbox" id="upnp_checkbox"> <input type="checkbox" id="upnpCheckbox">
<label for="upnp_checkbox">QBT_TR(Use UPnP / NAT-PMP port forwarding from my router)QBT_TR[CONTEXT=OptionsDialog]</label> <label for="upnpCheckbox">QBT_TR(Use UPnP / NAT-PMP port forwarding from my router)QBT_TR[CONTEXT=OptionsDialog]</label>
</div> </div>
</fieldset> </fieldset>
@ -415,31 +415,31 @@
<tbody> <tbody>
<tr> <tr>
<td> <td>
<input type="checkbox" id="max_connec_checkbox" onclick="qBittorrent.Preferences.updateMaxConnecEnabled();"> <input type="checkbox" id="maxConnectionsCheckbox" onclick="qBittorrent.Preferences.updateMaxConnecEnabled();">
<label id="maxConnectionsLabel" for="max_connec_checkbox">QBT_TR(Global maximum number of connections:)QBT_TR[CONTEXT=OptionsDialog]</label> <label id="maxConnectionsLabel" for="maxConnectionsCheckbox">QBT_TR(Global maximum number of connections:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td> </td>
<td><input type="text" id="max_connec_value" aria-labelledby="maxConnectionsLabel" style="width: 6em;"></td> <td><input type="text" id="maxConnectionsValue" aria-labelledby="maxConnectionsLabel" style="width: 6em;"></td>
</tr> </tr>
<tr> <tr>
<td> <td>
<input type="checkbox" id="max_connec_per_torrent_checkbox" onclick="qBittorrent.Preferences.updateMaxConnecPerTorrentEnabled();"> <input type="checkbox" id="maxConnectionsPerTorrentCheckbox" onclick="qBittorrent.Preferences.updateMaxConnecPerTorrentEnabled();">
<label id="maxConnectionsPerTorrentLabel" for="max_connec_per_torrent_checkbox">QBT_TR(Maximum number of connections per torrent:)QBT_TR[CONTEXT=OptionsDialog]</label> <label id="maxConnectionsPerTorrentLabel" for="maxConnectionsPerTorrentCheckbox">QBT_TR(Maximum number of connections per torrent:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td> </td>
<td><input type="text" id="max_connec_per_torrent_value" aria-labelledby="maxConnectionsPerTorrentLabel" style="width: 6em;"></td> <td><input type="text" id="maxConnectionsPerTorrentValue" aria-labelledby="maxConnectionsPerTorrentLabel" style="width: 6em;"></td>
</tr> </tr>
<tr> <tr>
<td> <td>
<input type="checkbox" id="max_uploads_checkbox" onclick="qBittorrent.Preferences.updateMaxUploadsEnabled();"> <input type="checkbox" id="maxUploadsCheckbox" onclick="qBittorrent.Preferences.updateMaxUploadsEnabled();">
<label id="maxUploadsLabel" for="max_uploads_checkbox">QBT_TR(Global maximum number of upload slots:)QBT_TR[CONTEXT=OptionsDialog]</label> <label id="maxUploadsLabel" for="maxUploadsCheckbox">QBT_TR(Global maximum number of upload slots:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td> </td>
<td><input type="text" id="max_uploads_value" aria-labelledby="maxUploadsLabel" style="width: 6em;"></td> <td><input type="text" id="max_uploads_value" aria-labelledby="maxUploadsLabel" style="width: 6em;"></td>
</tr> </tr>
<tr> <tr>
<td> <td>
<input type="checkbox" id="max_uploads_per_torrent_checkbox" onclick="qBittorrent.Preferences.updateMaxUploadsPerTorrentEnabled();"> <input type="checkbox" id="maxUploadsPerTorrentCheckbox" onclick="qBittorrent.Preferences.updateMaxUploadsPerTorrentEnabled();">
<label id="maxUploadsPerTorrentLabel" for="max_uploads_per_torrent_checkbox">QBT_TR(Maximum number of upload slots per torrent:)QBT_TR[CONTEXT=OptionsDialog]</label> <label id="maxUploadsPerTorrentLabel" for="maxUploadsPerTorrentCheckbox">QBT_TR(Maximum number of upload slots per torrent:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td> </td>
<td><input type="text" id="max_uploads_per_torrent_value" aria-labelledby="maxUploadsPerTorrentLabel" style="width: 6em;"></td> <td><input type="text" id="maxUploadsPerTorrentValue" aria-labelledby="maxUploadsPerTorrentLabel" style="width: 6em;"></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -592,12 +592,12 @@
<td rowspan="2"> <td rowspan="2">
<img src="images/slow_off.svg" style="height: 2.5em;" alt="QBT_TR(Alternative speed limits)QBT_TR[CONTEXT=MainWindow]"> <img src="images/slow_off.svg" style="height: 2.5em;" alt="QBT_TR(Alternative speed limits)QBT_TR[CONTEXT=MainWindow]">
</td> </td>
<td><label for="up_limit_value">QBT_TR(Upload:)QBT_TR[CONTEXT=OptionsDialog]</label></td> <td><label for="upLimitValue">QBT_TR(Upload:)QBT_TR[CONTEXT=OptionsDialog]</label></td>
<td><input type="number" id="up_limit_value" style="width: 6em;" min="0">&nbsp;&nbsp;QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]</td> <td><input type="number" id="upLimitValue" style="width: 6em;" min="0">&nbsp;&nbsp;QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]</td>
</tr> </tr>
<tr> <tr>
<td><label for="dl_limit_value">QBT_TR(Download:)QBT_TR[CONTEXT=OptionsDialog]</label></td> <td><label for="dlLimitValue">QBT_TR(Download:)QBT_TR[CONTEXT=OptionsDialog]</label></td>
<td><input type="number" id="dl_limit_value" style="width: 6em;" min="0">&nbsp;&nbsp;QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]</td> <td><input type="number" id="dlLimitValue" style="width: 6em;" min="0">&nbsp;&nbsp;QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -612,12 +612,12 @@
<td rowspan="2"> <td rowspan="2">
<img src="images/slow.svg" style="height: 2.5em;" alt="QBT_TR(Alternative speed limits)QBT_TR[CONTEXT=MainWindow]"> <img src="images/slow.svg" style="height: 2.5em;" alt="QBT_TR(Alternative speed limits)QBT_TR[CONTEXT=MainWindow]">
</td> </td>
<td><label for="alt_up_limit_value">QBT_TR(Upload:)QBT_TR[CONTEXT=OptionsDialog]</label></td> <td><label for="altUpLimitValue">QBT_TR(Upload:)QBT_TR[CONTEXT=OptionsDialog]</label></td>
<td><input type="number" id="alt_up_limit_value" style="width: 6em;" min="0">&nbsp;&nbsp;QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]</td> <td><input type="number" id="altUpLimitValue" style="width: 6em;" min="0">&nbsp;&nbsp;QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]</td>
</tr> </tr>
<tr> <tr>
<td><label for="alt_dl_limit_value">QBT_TR(Download:)QBT_TR[CONTEXT=OptionsDialog]</label></td> <td><label for="altDlLimitValue">QBT_TR(Download:)QBT_TR[CONTEXT=OptionsDialog]</label></td>
<td><input type="number" id="alt_dl_limit_value" style="width: 6em;" min="0">&nbsp;&nbsp;QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]</td> <td><input type="number" id="altDlLimitValue" style="width: 6em;" min="0">&nbsp;&nbsp;QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -705,66 +705,66 @@
<fieldset class="settings"> <fieldset class="settings">
<legend> <legend>
<input type="checkbox" id="queueing_checkbox" onclick="qBittorrent.Preferences.updateQueueingSystem();"> <input type="checkbox" id="queueingCheckbox" onclick="qBittorrent.Preferences.updateQueueingSystem();">
<label for="queueing_checkbox">QBT_TR(Torrent Queueing)QBT_TR[CONTEXT=OptionsDialog]</label> <label for="queueingCheckbox">QBT_TR(Torrent Queueing)QBT_TR[CONTEXT=OptionsDialog]</label>
</legend> </legend>
<table> <table>
<tbody> <tbody>
<tr> <tr>
<td> <td>
<label for="max_active_dl_value">QBT_TR(Maximum active downloads:)QBT_TR[CONTEXT=OptionsDialog]</label> <label for="maxActiveDlValue">QBT_TR(Maximum active downloads:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td> </td>
<td> <td>
<input type="text" id="max_active_dl_value" style="width: 6em;"> <input type="text" id="maxActiveDlValue" style="width: 6em;">
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<label for="max_active_up_value">QBT_TR(Maximum active uploads:)QBT_TR[CONTEXT=OptionsDialog]</label> <label for="maxActiveUpValue">QBT_TR(Maximum active uploads:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td> </td>
<td> <td>
<input type="text" id="max_active_up_value" style="width: 6em;"> <input type="text" id="maxActiveUpValue" style="width: 6em;">
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<label for="max_active_to_value">QBT_TR(Maximum active torrents:)QBT_TR[CONTEXT=OptionsDialog]</label> <label for="maxActiveToValue">QBT_TR(Maximum active torrents:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td> </td>
<td> <td>
<input type="text" id="max_active_to_value" style="width: 6em;"> <input type="text" id="maxActiveToValue" style="width: 6em;">
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<fieldset class="settings"> <fieldset class="settings">
<legend> <legend>
<input type="checkbox" id="dont_count_slow_torrents_checkbox" onclick="qBittorrent.Preferences.updateSlowTorrentsSettings();"> <input type="checkbox" id="dontCountSlowTorrentsCheckbox" onclick="qBittorrent.Preferences.updateSlowTorrentsSettings();">
<label for="dont_count_slow_torrents_checkbox">QBT_TR(Do not count slow torrents in these limits)QBT_TR[CONTEXT=OptionsDialog]</label> <label for="dontCountSlowTorrentsCheckbox">QBT_TR(Do not count slow torrents in these limits)QBT_TR[CONTEXT=OptionsDialog]</label>
</legend> </legend>
<table> <table>
<tbody> <tbody>
<tr> <tr>
<td> <td>
<label for="dl_rate_threshold">QBT_TR(Download rate threshold:)QBT_TR[CONTEXT=OptionsDialog]</label> <label for="dlRateThresholdValue">QBT_TR(Download rate threshold:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td> </td>
<td> <td>
<input type="text" id="dl_rate_threshold" style="width: 6em;">&nbsp;&nbsp;QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog] <input type="text" id="dlRateThresholdValue" style="width: 6em;">&nbsp;&nbsp;QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<label for="ul_rate_threshold">QBT_TR(Upload rate threshold:)QBT_TR[CONTEXT=OptionsDialog]</label> <label for="ulRateThresholdValue">QBT_TR(Upload rate threshold:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td> </td>
<td> <td>
<input type="text" id="ul_rate_threshold" style="width: 6em;">&nbsp;&nbsp;QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog] <input type="text" id="ulRateThresholdValue" style="width: 6em;">&nbsp;&nbsp;QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<label for="torrent_inactive_timer">QBT_TR(Torrent inactivity timer:)QBT_TR[CONTEXT=OptionsDialog]</label> <label for="torrentInactiveTimerValue">QBT_TR(Torrent inactivity timer:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td> </td>
<td> <td>
<input type="text" id="torrent_inactive_timer" style="width: 6em;">&nbsp;&nbsp;QBT_TR(seconds)QBT_TR[CONTEXT=OptionsDialog] <input type="text" id="torrentInactiveTimerValue" style="width: 6em;">&nbsp;&nbsp;QBT_TR(seconds)QBT_TR[CONTEXT=OptionsDialog]
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -778,35 +778,35 @@
<tbody> <tbody>
<tr> <tr>
<td> <td>
<input type="checkbox" id="max_ratio_checkbox" onclick="qBittorrent.Preferences.updateMaxRatioTimeEnabled();"> <input type="checkbox" id="maxRatioCheckbox" onclick="qBittorrent.Preferences.updateMaxRatioTimeEnabled();">
<label id="maxRatioLabel" for="max_ratio_checkbox">QBT_TR(When ratio reaches)QBT_TR[CONTEXT=OptionsDialog]</label> <label id="maxRatioLabel" for="maxRatioCheckbox">QBT_TR(When ratio reaches)QBT_TR[CONTEXT=OptionsDialog]</label>
</td> </td>
<td> <td>
<input type="text" id="max_ratio_value" style="width: 6em;" aria-labelledby="maxRatioLabel"> <input type="text" id="maxRatioValue" style="width: 6em;" aria-labelledby="maxRatioLabel">
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<input type="checkbox" id="max_seeding_time_checkbox" onclick="qBittorrent.Preferences.updateMaxRatioTimeEnabled();"> <input type="checkbox" id="maxSeedingTimeCheckbox" onclick="qBittorrent.Preferences.updateMaxRatioTimeEnabled();">
<label id="maxSeedingTimeLabel" for="max_seeding_time_checkbox">QBT_TR(When total seeding time reaches)QBT_TR[CONTEXT=OptionsDialog]</label> <label id="maxSeedingTimeLabel" for="maxSeedingTimeCheckbox">QBT_TR(When total seeding time reaches)QBT_TR[CONTEXT=OptionsDialog]</label>
</td> </td>
<td> <td>
<input type="text" id="max_seeding_time_value" style="width: 6em;" aria-labelledby="maxSeedingTimeLabel">QBT_TR(minutes)QBT_TR[CONTEXT=OptionsDialog] <input type="text" id="maxSeedingTimeValue" style="width: 6em;" aria-labelledby="maxSeedingTimeLabel">QBT_TR(minutes)QBT_TR[CONTEXT=OptionsDialog]
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<input type="checkbox" id="max_inactive_seeding_time_checkbox" onclick="qBittorrent.Preferences.updateMaxRatioTimeEnabled();"> <input type="checkbox" id="maxInactiveSeedingTimeCheckbox" onclick="qBittorrent.Preferences.updateMaxRatioTimeEnabled();">
<label id="maxInactiveSeedingTimeLabel" for="max_inactive_seeding_time_checkbox">QBT_TR(When inactive seeding time reaches)QBT_TR[CONTEXT=OptionsDialog]</label> <label id="maxInactiveSeedingTimeLabel" for="maxInactiveSeedingTimeCheckbox">QBT_TR(When inactive seeding time reaches)QBT_TR[CONTEXT=OptionsDialog]</label>
</td> </td>
<td> <td>
<input type="text" id="max_inactive_seeding_time_value" style="width: 6em;" aria-labelledby="maxInactiveSeedingTimeLabel">QBT_TR(minutes)QBT_TR[CONTEXT=OptionsDialog] <input type="text" id="maxInactiveSeedingTimeValue" style="width: 6em;" aria-labelledby="maxInactiveSeedingTimeLabel">QBT_TR(minutes)QBT_TR[CONTEXT=OptionsDialog]
</td> </td>
</tr> </tr>
<tr> <tr>
<td style="text-align: right;"><label for="max_ratio_act">QBT_TR(then)QBT_TR[CONTEXT=OptionsDialog]</label></td> <td style="text-align: right;"><label for="maxRatioSelect">QBT_TR(then)QBT_TR[CONTEXT=OptionsDialog]</label></td>
<td> <td>
<select id="max_ratio_act"> <select id="maxRatioSelect">
<option value="0">QBT_TR(Stop torrent)QBT_TR[CONTEXT=OptionsDialog]</option> <option value="0">QBT_TR(Stop torrent)QBT_TR[CONTEXT=OptionsDialog]</option>
<option value="1">QBT_TR(Remove torrent)QBT_TR[CONTEXT=OptionsDialog]</option> <option value="1">QBT_TR(Remove torrent)QBT_TR[CONTEXT=OptionsDialog]</option>
<option value="3">QBT_TR(Remove torrent and its files)QBT_TR[CONTEXT=OptionsDialog]</option> <option value="3">QBT_TR(Remove torrent and its files)QBT_TR[CONTEXT=OptionsDialog]</option>
@ -909,19 +909,19 @@
<tbody> <tbody>
<tr> <tr>
<td> <td>
<label for="webui_address_value">QBT_TR(IP address:)QBT_TR[CONTEXT=OptionsDialog]</label> <label for="webuiAddressValue">QBT_TR(IP address:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td> </td>
<td> <td>
<input type="text" id="webui_address_value"> <input type="text" id="webuiAddressValue">
<label for="webui_port_value" style="margin-left: 10px;">QBT_TR(Port:)QBT_TR[CONTEXT=OptionsDialog]</label> <label for="webuiPortValue" style="margin-left: 10px;">QBT_TR(Port:)QBT_TR[CONTEXT=OptionsDialog]</label>
<input type="text" id="webui_port_value" style="width: 6em;"> <input type="text" id="webuiPortValue" style="width: 6em;">
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<div class="formRow"> <div class="formRow">
<input type="checkbox" id="webui_upnp_checkbox"> <input type="checkbox" id="webuiUpnpCheckbox">
<label for="webui_upnp_checkbox">QBT_TR(Use UPnP / NAT-PMP to forward the port from my router)QBT_TR[CONTEXT=OptionsDialog]</label> <label for="webuiUpnpCheckbox">QBT_TR(Use UPnP / NAT-PMP to forward the port from my router)QBT_TR[CONTEXT=OptionsDialog]</label>
</div> </div>
<fieldset class="settings"> <fieldset class="settings">
<legend> <legend>
@ -1043,10 +1043,10 @@
<tbody> <tbody>
<tr> <tr>
<td> <td>
<label for="webui_domain_textarea">QBT_TR(Server domains:)QBT_TR[CONTEXT=OptionsDialog]</label> <label for="webuiDomainTextarea">QBT_TR(Server domains:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td> </td>
<td> <td>
<textarea id="webui_domain_textarea" rows="1" cols="60" title="QBT_TR(Whitelist for filtering HTTP Host header values. <textarea id="webuiDomainTextarea" rows="1" cols="60" title="QBT_TR(Whitelist for filtering HTTP Host header values.
In order to defend against DNS rebinding attack, In order to defend against DNS rebinding attack,
you should put in domain names used by WebUI server. you should put in domain names used by WebUI server.
@ -1940,23 +1940,23 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
// Connection tab // Connection tab
const updateMaxConnecEnabled = () => { const updateMaxConnecEnabled = () => {
const isMaxConnecEnabled = $("max_connec_checkbox").checked; const isMaxConnecEnabled = $("maxConnectionsCheckbox").checked;
$("max_connec_value").disabled = !isMaxConnecEnabled; $("maxConnectionsValue").disabled = !isMaxConnecEnabled;
}; };
const updateMaxConnecPerTorrentEnabled = () => { const updateMaxConnecPerTorrentEnabled = () => {
const isMaxConnecPerTorrentEnabled = $("max_connec_per_torrent_checkbox").checked; const isMaxConnecPerTorrentEnabled = $("maxConnectionsPerTorrentCheckbox").checked;
$("max_connec_per_torrent_value").disabled = !isMaxConnecPerTorrentEnabled; $("maxConnectionsPerTorrentValue").disabled = !isMaxConnecPerTorrentEnabled;
}; };
const updateMaxUploadsEnabled = () => { const updateMaxUploadsEnabled = () => {
const isMaxUploadsEnabled = $("max_uploads_checkbox").checked; const isMaxUploadsEnabled = $("maxUploadsCheckbox").checked;
$("max_uploads_value").disabled = !isMaxUploadsEnabled; $("max_uploads_value").disabled = !isMaxUploadsEnabled;
}; };
const updateMaxUploadsPerTorrentEnabled = () => { const updateMaxUploadsPerTorrentEnabled = () => {
const isMaxUploadsPerTorrentEnabled = $("max_uploads_per_torrent_checkbox").checked; const isMaxUploadsPerTorrentEnabled = $("maxUploadsPerTorrentCheckbox").checked;
$("max_uploads_per_torrent_value").disabled = !isMaxUploadsPerTorrentEnabled; $("maxUploadsPerTorrentValue").disabled = !isMaxUploadsPerTorrentEnabled;
}; };
const updateI2PSettingsEnabled = () => { const updateI2PSettingsEnabled = () => {
@ -2009,32 +2009,32 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
// Bittorrent tab // Bittorrent tab
const updateQueueingSystem = () => { const updateQueueingSystem = () => {
const isQueueingEnabled = $("queueing_checkbox").checked; const isQueueingEnabled = $("queueingCheckbox").checked;
$("max_active_dl_value").disabled = !isQueueingEnabled; $("maxActiveDlValue").disabled = !isQueueingEnabled;
$("max_active_up_value").disabled = !isQueueingEnabled; $("maxActiveUpValue").disabled = !isQueueingEnabled;
$("max_active_to_value").disabled = !isQueueingEnabled; $("maxActiveToValue").disabled = !isQueueingEnabled;
$("dont_count_slow_torrents_checkbox").disabled = !isQueueingEnabled; $("dontCountSlowTorrentsCheckbox").disabled = !isQueueingEnabled;
updateSlowTorrentsSettings(); updateSlowTorrentsSettings();
}; };
const updateSlowTorrentsSettings = () => { const updateSlowTorrentsSettings = () => {
const isDontCountSlowTorrentsEnabled = (!$("dont_count_slow_torrents_checkbox").disabled) && $("dont_count_slow_torrents_checkbox").checked; const isDontCountSlowTorrentsEnabled = (!$("dontCountSlowTorrentsCheckbox").disabled) && $("dontCountSlowTorrentsCheckbox").checked;
$("dl_rate_threshold").disabled = !isDontCountSlowTorrentsEnabled; $("dlRateThresholdValue").disabled = !isDontCountSlowTorrentsEnabled;
$("ul_rate_threshold").disabled = !isDontCountSlowTorrentsEnabled; $("ulRateThresholdValue").disabled = !isDontCountSlowTorrentsEnabled;
$("torrent_inactive_timer").disabled = !isDontCountSlowTorrentsEnabled; $("torrentInactiveTimerValue").disabled = !isDontCountSlowTorrentsEnabled;
}; };
const updateMaxRatioTimeEnabled = () => { const updateMaxRatioTimeEnabled = () => {
const isMaxRatioEnabled = $("max_ratio_checkbox").checked; const isMaxRatioEnabled = $("maxRatioCheckbox").checked;
$("max_ratio_value").disabled = !isMaxRatioEnabled; $("maxRatioValue").disabled = !isMaxRatioEnabled;
const isMaxSeedingTimeEnabled = $("max_seeding_time_checkbox").checked; const isMaxSeedingTimeEnabled = $("maxSeedingTimeCheckbox").checked;
$("max_seeding_time_value").disabled = !isMaxSeedingTimeEnabled; $("maxSeedingTimeValue").disabled = !isMaxSeedingTimeEnabled;
const isMaxInactiveSeedingTimeEnabled = $("max_inactive_seeding_time_checkbox").checked; const isMaxInactiveSeedingTimeEnabled = $("maxInactiveSeedingTimeCheckbox").checked;
$("max_inactive_seeding_time_value").disabled = !isMaxInactiveSeedingTimeEnabled; $("maxInactiveSeedingTimeValue").disabled = !isMaxInactiveSeedingTimeEnabled;
$("max_ratio_act").disabled = !(isMaxRatioEnabled || isMaxSeedingTimeEnabled || isMaxInactiveSeedingTimeEnabled); $("maxRatioSelect").disabled = !(isMaxRatioEnabled || isMaxSeedingTimeEnabled || isMaxInactiveSeedingTimeEnabled);
}; };
const updateAddTrackersEnabled = () => { const updateAddTrackersEnabled = () => {
@ -2066,7 +2066,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
const updateHostHeaderValidationSettings = () => { const updateHostHeaderValidationSettings = () => {
const isHostHeaderValidationEnabled = $("host_header_validation_checkbox").checked; const isHostHeaderValidationEnabled = $("host_header_validation_checkbox").checked;
$("webui_domain_textarea").disabled = !isHostHeaderValidationEnabled; $("webuiDomainTextarea").disabled = !isHostHeaderValidationEnabled;
}; };
const updateWebUICustomHTTPHeadersSettings = () => { const updateWebUICustomHTTPHeadersSettings = () => {
@ -2098,7 +2098,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
const min = 1024; const min = 1024;
const max = 65535; const max = 65535;
const port = Math.floor(Math.random() * (max - min + 1) + min); const port = Math.floor(Math.random() * (max - min + 1) + min);
$("port_value").value = port; $("portValue").value = port;
}; };
const time_padding = (val) => { const time_padding = (val) => {
@ -2329,48 +2329,51 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
// Connection tab // Connection tab
// Listening Port // Listening Port
$("port_value").value = Number(pref.listen_port); $("portValue").value = Number(pref.listen_port);
$("upnp_checkbox").checked = pref.upnp; $("upnpCheckbox").checked = pref.upnp;
// Connections Limits // Connections Limits
const max_connec = Number(pref.max_connec); const maxConnec = Number(pref.max_connec);
if (max_connec <= 0) { if (maxConnec <= 0) {
$("max_connec_checkbox").checked = false; $("maxConnectionsCheckbox").checked = false;
$("max_connec_value").value = 500; $("maxConnectionsValue").value = 500;
} }
else { else {
$("max_connec_checkbox").checked = true; $("maxConnectionsCheckbox").checked = true;
$("max_connec_value").value = max_connec; $("maxConnectionsValue").value = maxConnec;
} }
updateMaxConnecEnabled(); updateMaxConnecEnabled();
const max_connec_per_torrent = Number(pref.max_connec_per_torrent);
if (max_connec_per_torrent <= 0) { const maxConnecPerTorrent = Number(pref.max_connec_per_torrent);
$("max_connec_per_torrent_checkbox").checked = false; if (maxConnecPerTorrent <= 0) {
$("max_connec_per_torrent_value").value = 100; $("maxConnectionsPerTorrentCheckbox").checked = false;
$("maxConnectionsPerTorrentValue").value = 100;
} }
else { else {
$("max_connec_per_torrent_checkbox").checked = true; $("maxConnectionsPerTorrentCheckbox").checked = true;
$("max_connec_per_torrent_value").value = max_connec_per_torrent; $("maxConnectionsPerTorrentValue").value = maxConnecPerTorrent;
} }
updateMaxConnecPerTorrentEnabled(); updateMaxConnecPerTorrentEnabled();
const max_uploads = Number(pref.max_uploads);
if (max_uploads <= 0) { const maxUploads = Number(pref.max_uploads);
$("max_uploads_checkbox").checked = false; if (maxUploads <= 0) {
$("maxUploadsCheckbox").checked = false;
$("max_uploads_value").value = 8; $("max_uploads_value").value = 8;
} }
else { else {
$("max_uploads_checkbox").checked = true; $("maxUploadsCheckbox").checked = true;
$("max_uploads_value").value = max_uploads; $("max_uploads_value").value = maxUploads;
} }
updateMaxUploadsEnabled(); updateMaxUploadsEnabled();
const max_uploads_per_torrent = Number(pref.max_uploads_per_torrent);
if (max_uploads_per_torrent <= 0) { const maxUploadsPerTorrent = Number(pref.max_uploads_per_torrent);
$("max_uploads_per_torrent_checkbox").checked = false; if (maxUploadsPerTorrent <= 0) {
$("max_uploads_per_torrent_value").value = 4; $("maxUploadsPerTorrentCheckbox").checked = false;
$("maxUploadsPerTorrentValue").value = 4;
} }
else { else {
$("max_uploads_per_torrent_checkbox").checked = true; $("maxUploadsPerTorrentCheckbox").checked = true;
$("max_uploads_per_torrent_value").value = max_uploads_per_torrent; $("maxUploadsPerTorrentValue").value = maxUploadsPerTorrent;
} }
updateMaxUploadsPerTorrentEnabled(); updateMaxUploadsPerTorrentEnabled();
@ -2404,11 +2407,11 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
// Speed tab // Speed tab
// Global Rate Limits // Global Rate Limits
$("up_limit_value").value = (Number(pref.up_limit) / 1024); $("upLimitValue").value = (Number(pref.up_limit) / 1024);
$("dl_limit_value").value = (Number(pref.dl_limit) / 1024); $("dlLimitValue").value = (Number(pref.dl_limit) / 1024);
// Alternative Global Rate Limits // Alternative Global Rate Limits
$("alt_up_limit_value").value = (Number(pref.alt_up_limit) / 1024); $("altUpLimitValue").value = (Number(pref.alt_up_limit) / 1024);
$("alt_dl_limit_value").value = (Number(pref.alt_dl_limit) / 1024); $("altDlLimitValue").value = (Number(pref.alt_dl_limit) / 1024);
$("enable_protocol_combobox").value = pref.bittorrent_protocol; $("enable_protocol_combobox").value = pref.bittorrent_protocol;
$("limit_utp_rate_checkbox").checked = pref.limit_utp_rate; $("limit_utp_rate_checkbox").checked = pref.limit_utp_rate;
@ -2436,23 +2439,23 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
$("maxActiveCheckingTorrents").value = pref.max_active_checking_torrents; $("maxActiveCheckingTorrents").value = pref.max_active_checking_torrents;
// Torrent Queueing // Torrent Queueing
$("queueing_checkbox").checked = pref.queueing_enabled; $("queueingCheckbox").checked = pref.queueing_enabled;
$("max_active_dl_value").value = Number(pref.max_active_downloads); $("maxActiveDlValue").value = Number(pref.max_active_downloads);
$("max_active_up_value").value = Number(pref.max_active_uploads); $("maxActiveUpValue").value = Number(pref.max_active_uploads);
$("max_active_to_value").value = Number(pref.max_active_torrents); $("maxActiveToValue").value = Number(pref.max_active_torrents);
$("dont_count_slow_torrents_checkbox").checked = pref.dont_count_slow_torrents; $("dontCountSlowTorrentsCheckbox").checked = pref.dont_count_slow_torrents;
$("dl_rate_threshold").value = Number(pref.slow_torrent_dl_rate_threshold); $("dlRateThresholdValue").value = Number(pref.slow_torrent_dl_rate_threshold);
$("ul_rate_threshold").value = Number(pref.slow_torrent_ul_rate_threshold); $("ulRateThresholdValue").value = Number(pref.slow_torrent_ul_rate_threshold);
$("torrent_inactive_timer").value = Number(pref.slow_torrent_inactive_timer); $("torrentInactiveTimerValue").value = Number(pref.slow_torrent_inactive_timer);
updateQueueingSystem(); updateQueueingSystem();
// Share Limiting // Share Limiting
$("max_ratio_checkbox").checked = pref.max_ratio_enabled; $("maxRatioCheckbox").checked = pref.max_ratio_enabled;
$("max_ratio_value").value = (pref.max_ratio_enabled ? pref.max_ratio : 1); $("maxRatioValue").value = (pref.max_ratio_enabled ? pref.max_ratio : 1);
$("max_seeding_time_checkbox").checked = pref.max_seeding_time_enabled; $("maxSeedingTimeCheckbox").checked = pref.max_seeding_time_enabled;
$("max_seeding_time_value").value = (pref.max_seeding_time_enabled ? Number(pref.max_seeding_time) : 1440); $("maxSeedingTimeValue").value = (pref.max_seeding_time_enabled ? Number(pref.max_seeding_time) : 1440);
$("max_inactive_seeding_time_checkbox").checked = pref.max_inactive_seeding_time_enabled; $("maxInactiveSeedingTimeCheckbox").checked = pref.max_inactive_seeding_time_enabled;
$("max_inactive_seeding_time_value").value = (pref.max_inactive_seeding_time_enabled ? Number(pref.max_inactive_seeding_time) : 1440); $("maxInactiveSeedingTimeValue").value = (pref.max_inactive_seeding_time_enabled ? Number(pref.max_inactive_seeding_time) : 1440);
let maxRatioAct = 0; let maxRatioAct = 0;
switch (Number(pref.max_ratio_act)) { switch (Number(pref.max_ratio_act)) {
case 0: // Stop case 0: // Stop
@ -2469,7 +2472,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
maxRatioAct = 2; maxRatioAct = 2;
break; break;
} }
$("max_ratio_act").getChildren("option")[maxRatioAct].selected = true; $("maxRatioSelect").getChildren("option")[maxRatioAct].selected = true;
updateMaxRatioTimeEnabled(); updateMaxRatioTimeEnabled();
// Add trackers // Add trackers
@ -2492,10 +2495,10 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
// WebUI tab // WebUI tab
// HTTP Server // HTTP Server
$("webui_domain_textarea").value = pref.web_ui_domain_list; $("webuiDomainTextarea").value = pref.web_ui_domain_list;
$("webui_address_value").value = pref.web_ui_address; $("webuiAddressValue").value = pref.web_ui_address;
$("webui_port_value").value = pref.web_ui_port; $("webuiPortValue").value = pref.web_ui_port;
$("webui_upnp_checkbox").checked = pref.web_ui_upnp; $("webuiUpnpCheckbox").checked = pref.web_ui_upnp;
$("use_https_checkbox").checked = pref.use_https; $("use_https_checkbox").checked = pref.use_https;
$("ssl_cert_text").value = pref.web_ui_https_cert_path; $("ssl_cert_text").value = pref.web_ui_https_cert_path;
$("ssl_key_text").value = pref.web_ui_https_key_path; $("ssl_key_text").value = pref.web_ui_https_key_path;
@ -2705,51 +2708,54 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
// Connection tab // Connection tab
// Listening Port // Listening Port
const listen_port = Number($("port_value").value); const listenPort = Number($("portValue").value);
if (isNaN(listen_port) || (listen_port < 0) || (listen_port > 65535)) { if (Number.isNaN(listenPort) || (listenPort < 0) || (listenPort > 65535)) {
alert("QBT_TR(The port used for incoming connections must be between 0 and 65535.)QBT_TR[CONTEXT=HttpServer]"); alert("QBT_TR(The port used for incoming connections must be between 0 and 65535.)QBT_TR[CONTEXT=HttpServer]");
return; return;
} }
settings["listen_port"] = listen_port; settings["listen_port"] = listenPort;
settings["upnp"] = $("upnp_checkbox").checked; settings["upnp"] = $("upnpCheckbox").checked;
// Connections Limits // Connections Limits
let max_connec = -1; let maxConnec = -1;
if ($("max_connec_checkbox").checked) { if ($("maxConnectionsCheckbox").checked) {
max_connec = Number($("max_connec_value").value); maxConnec = Number($("maxConnectionsValue").value);
if (isNaN(max_connec) || (max_connec <= 0)) { if (Number.isNaN(maxConnec) || (maxConnec <= 0)) {
alert("QBT_TR(Maximum number of connections limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]"); alert("QBT_TR(Maximum number of connections limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
return; return;
} }
} }
settings["max_connec"] = max_connec; settings["max_connec"] = maxConnec;
let max_connec_per_torrent = -1;
if ($("max_connec_per_torrent_checkbox").checked) { let maxConnecPerTorrent = -1;
max_connec_per_torrent = Number($("max_connec_per_torrent_value").value); if ($("maxConnectionsPerTorrentCheckbox").checked) {
if (isNaN(max_connec_per_torrent) || (max_connec_per_torrent <= 0)) { maxConnecPerTorrent = Number($("maxConnectionsPerTorrentValue").value);
if (Number.isNaN(maxConnecPerTorrent) || (maxConnecPerTorrent <= 0)) {
alert("QBT_TR(Maximum number of connections per torrent limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]"); alert("QBT_TR(Maximum number of connections per torrent limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
return; return;
} }
} }
settings["max_connec_per_torrent"] = max_connec_per_torrent; settings["max_connec_per_torrent"] = maxConnecPerTorrent;
let max_uploads = -1;
if ($("max_uploads_checkbox").checked) { let maxUploads = -1;
max_uploads = Number($("max_uploads_value").value); if ($("maxUploadsCheckbox").checked) {
if (isNaN(max_uploads) || (max_uploads <= 0)) { maxUploads = Number($("max_uploads_value").value);
if (Number.isNaN(maxUploads) || (maxUploads <= 0)) {
alert("QBT_TR(Global number of upload slots limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]"); alert("QBT_TR(Global number of upload slots limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
return; return;
} }
} }
settings["max_uploads"] = max_uploads; settings["max_uploads"] = maxUploads;
let max_uploads_per_torrent = -1;
if ($("max_uploads_per_torrent_checkbox").checked) { let maxUploadsPerTorrent = -1;
max_uploads_per_torrent = Number($("max_uploads_per_torrent_value").value); if ($("maxUploadsPerTorrentCheckbox").checked) {
if (isNaN(max_uploads_per_torrent) || (max_uploads_per_torrent <= 0)) { maxUploadsPerTorrent = Number($("maxUploadsPerTorrentValue").value);
if (Number.isNaN(maxUploadsPerTorrent) || (maxUploadsPerTorrent <= 0)) {
alert("QBT_TR(Maximum number of upload slots per torrent limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]"); alert("QBT_TR(Maximum number of upload slots per torrent limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
return; return;
} }
} }
settings["max_uploads_per_torrent"] = max_uploads_per_torrent; settings["max_uploads_per_torrent"] = maxUploadsPerTorrent;
// I2P // I2P
settings["i2p_enabled"] = $("i2pEnabledCheckbox").checked; settings["i2p_enabled"] = $("i2pEnabledCheckbox").checked;
@ -2778,34 +2784,34 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
// Speed tab // Speed tab
// Global Rate Limits // Global Rate Limits
const up_limit = Number($("up_limit_value").value) * 1024; const upLimit = Number($("upLimitValue").value) * 1024;
if (isNaN(up_limit) || (up_limit < 0)) { if (Number.isNaN(upLimit) || (upLimit < 0)) {
alert("QBT_TR(Global upload rate limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]"); alert("QBT_TR(Global upload rate limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
return; return;
} }
settings["up_limit"] = up_limit; settings["up_limit"] = upLimit;
const dl_limit = Number($("dl_limit_value").value) * 1024; const dlLimit = Number($("dlLimitValue").value) * 1024;
if (isNaN(dl_limit) || (dl_limit < 0)) { if (Number.isNaN(dlLimit) || (dlLimit < 0)) {
alert("QBT_TR(Global download rate limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]"); alert("QBT_TR(Global download rate limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
return; return;
} }
settings["dl_limit"] = dl_limit; settings["dl_limit"] = dlLimit;
// Alternative Global Rate Limits // Alternative Global Rate Limits
const alt_up_limit = Number($("alt_up_limit_value").value) * 1024; const altUpLimit = Number($("altUpLimitValue").value) * 1024;
if (isNaN(alt_up_limit) || (alt_up_limit < 0)) { if (Number.isNaN(altUpLimit) || (altUpLimit < 0)) {
alert("QBT_TR(Alternative upload rate limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]"); alert("QBT_TR(Alternative upload rate limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
return; return;
} }
settings["alt_up_limit"] = alt_up_limit; settings["alt_up_limit"] = altUpLimit;
const alt_dl_limit = Number($("alt_dl_limit_value").value) * 1024; const altDlLimit = Number($("altDlLimitValue").value) * 1024;
if (isNaN(alt_dl_limit) || (alt_dl_limit < 0)) { if (Number.isNaN(altDlLimit) || (altDlLimit < 0)) {
alert("QBT_TR(Alternative download rate limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]"); alert("QBT_TR(Alternative download rate limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
return; return;
} }
settings["alt_dl_limit"] = alt_dl_limit; settings["alt_dl_limit"] = altDlLimit;
settings["bittorrent_protocol"] = Number($("enable_protocol_combobox").value); settings["bittorrent_protocol"] = Number($("enable_protocol_combobox").value);
settings["limit_utp_rate"] = $("limit_utp_rate_checkbox").checked; settings["limit_utp_rate"] = $("limit_utp_rate_checkbox").checked;
@ -2813,9 +2819,9 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
settings["limit_lan_peers"] = $("limit_lan_peers_checkbox").checked; settings["limit_lan_peers"] = $("limit_lan_peers_checkbox").checked;
// Scheduler // Scheduler
const scheduling_enabled = $("limitSchedulingCheckbox").checked; const schedulingEnabled = $("limitSchedulingCheckbox").checked;
settings["scheduler_enabled"] = scheduling_enabled; settings["scheduler_enabled"] = schedulingEnabled;
if (scheduling_enabled) { if (schedulingEnabled) {
settings["schedule_from_hour"] = Number($("schedule_from_hour").value); settings["schedule_from_hour"] = Number($("schedule_from_hour").value);
settings["schedule_from_min"] = Number($("schedule_from_min").value); settings["schedule_from_min"] = Number($("schedule_from_min").value);
settings["schedule_to_hour"] = Number($("schedule_to_hour").value); settings["schedule_to_hour"] = Number($("schedule_to_hour").value);
@ -2834,82 +2840,86 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
settings["max_active_checking_torrents"] = Number($("maxActiveCheckingTorrents").value); settings["max_active_checking_torrents"] = Number($("maxActiveCheckingTorrents").value);
// Torrent Queueing // Torrent Queueing
settings["queueing_enabled"] = $("queueing_checkbox").checked; settings["queueing_enabled"] = $("queueingCheckbox").checked;
if ($("queueing_checkbox").checked) { if ($("queueingCheckbox").checked) {
const max_active_downloads = Number($("max_active_dl_value").value); const maxActiveDownloads = Number($("maxActiveDlValue").value);
if (isNaN(max_active_downloads) || (max_active_downloads < -1)) { if (Number.isNaN(maxActiveDownloads) || (maxActiveDownloads < -1)) {
alert("QBT_TR(Maximum active downloads must be greater than -1.)QBT_TR[CONTEXT=HttpServer]"); alert("QBT_TR(Maximum active downloads must be greater than -1.)QBT_TR[CONTEXT=HttpServer]");
return; return;
} }
settings["max_active_downloads"] = max_active_downloads; settings["max_active_downloads"] = maxActiveDownloads;
const max_active_uploads = Number($("max_active_up_value").value);
if (isNaN(max_active_uploads) || (max_active_uploads < -1)) { const maxActiveUploads = Number($("maxActiveUpValue").value);
if (Number.isNaN(maxActiveUploads) || (maxActiveUploads < -1)) {
alert("QBT_TR(Maximum active uploads must be greater than -1.)QBT_TR[CONTEXT=HttpServer]"); alert("QBT_TR(Maximum active uploads must be greater than -1.)QBT_TR[CONTEXT=HttpServer]");
return; return;
} }
settings["max_active_uploads"] = max_active_uploads; settings["max_active_uploads"] = maxActiveUploads;
const max_active_torrents = Number($("max_active_to_value").value);
if (isNaN(max_active_torrents) || (max_active_torrents < -1)) { const maxActiveTorrents = Number($("maxActiveToValue").value);
if (Number.isNaN(maxActiveTorrents) || (maxActiveTorrents < -1)) {
alert("QBT_TR(Maximum active torrents must be greater than -1.)QBT_TR[CONTEXT=HttpServer]"); alert("QBT_TR(Maximum active torrents must be greater than -1.)QBT_TR[CONTEXT=HttpServer]");
return; return;
} }
settings["max_active_torrents"] = max_active_torrents; settings["max_active_torrents"] = maxActiveTorrents;
settings["dont_count_slow_torrents"] = $("dont_count_slow_torrents_checkbox").checked; settings["dont_count_slow_torrents"] = $("dontCountSlowTorrentsCheckbox").checked;
const dl_rate_threshold = Number($("dl_rate_threshold").value);
if (isNaN(dl_rate_threshold) || (dl_rate_threshold < 1)) { const dlRateThreshold = Number($("dlRateThresholdValue").value);
if (Number.isNaN(dlRateThreshold) || (dlRateThreshold < 1)) {
alert("QBT_TR(Download rate threshold must be greater than 0.)QBT_TR[CONTEXT=HttpServer]"); alert("QBT_TR(Download rate threshold must be greater than 0.)QBT_TR[CONTEXT=HttpServer]");
return; return;
} }
settings["slow_torrent_dl_rate_threshold"] = dl_rate_threshold; settings["slow_torrent_dl_rate_threshold"] = dlRateThreshold;
const ul_rate_threshold = Number($("ul_rate_threshold").value);
if (isNaN(ul_rate_threshold) || (ul_rate_threshold < 1)) { const ulRateThreshold = Number($("ulRateThresholdValue").value);
if (Number.isNaN(ulRateThreshold) || (ulRateThreshold < 1)) {
alert("QBT_TR(Upload rate threshold must be greater than 0.)QBT_TR[CONTEXT=HttpServer]"); alert("QBT_TR(Upload rate threshold must be greater than 0.)QBT_TR[CONTEXT=HttpServer]");
return; return;
} }
settings["slow_torrent_ul_rate_threshold"] = ul_rate_threshold; settings["slow_torrent_ul_rate_threshold"] = ulRateThreshold;
const torrent_inactive_timer = Number($("torrent_inactive_timer").value);
if (isNaN(torrent_inactive_timer) || (torrent_inactive_timer < 1)) { const torrentInactiveTimer = Number($("torrentInactiveTimerValue").value);
if (Number.isNaN(torrentInactiveTimer) || (torrentInactiveTimer < 1)) {
alert("QBT_TR(Torrent inactivity timer must be greater than 0.)QBT_TR[CONTEXT=HttpServer]"); alert("QBT_TR(Torrent inactivity timer must be greater than 0.)QBT_TR[CONTEXT=HttpServer]");
return; return;
} }
settings["slow_torrent_inactive_timer"] = torrent_inactive_timer; settings["slow_torrent_inactive_timer"] = torrentInactiveTimer;
} }
// Share Ratio Limiting // Share Ratio Limiting
let max_ratio = -1; let maxRatio = -1;
if ($("max_ratio_checkbox").checked) { if ($("maxRatioCheckbox").checked) {
max_ratio = Number($("max_ratio_value").value); maxRatio = Number($("maxRatioValue").value);
if (isNaN(max_ratio) || (max_ratio < 0) || (max_ratio > 9998)) { if (isNaN(maxRatio) || (maxRatio < 0) || (maxRatio > 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;
} }
} }
settings["max_ratio_enabled"] = $("max_ratio_checkbox").checked; settings["max_ratio_enabled"] = $("maxRatioCheckbox").checked;
settings["max_ratio"] = max_ratio; settings["max_ratio"] = maxRatio;
let max_seeding_time = -1; let maxSeedingTime = -1;
if ($("max_seeding_time_checkbox").checked) { if ($("maxSeedingTimeCheckbox").checked) {
max_seeding_time = Number($("max_seeding_time_value").value); maxSeedingTime = Number($("maxSeedingTimeValue").value);
if (isNaN(max_seeding_time) || (max_seeding_time < 0) || (max_seeding_time > 525600)) { if (Number.isNaN(maxSeedingTime) || (maxSeedingTime < 0) || (maxSeedingTime > 525600)) {
alert("QBT_TR(Seeding time limit must be between 0 and 525600 minutes.)QBT_TR[CONTEXT=HttpServer]"); alert("QBT_TR(Seeding time limit must be between 0 and 525600 minutes.)QBT_TR[CONTEXT=HttpServer]");
return; return;
} }
} }
settings["max_seeding_time_enabled"] = $("max_seeding_time_checkbox").checked; settings["max_seeding_time_enabled"] = $("maxSeedingTimeCheckbox").checked;
settings["max_seeding_time"] = max_seeding_time; settings["max_seeding_time"] = maxSeedingTime;
settings["max_ratio_act"] = Number($("max_ratio_act").value);
let max_inactive_seeding_time = -1; let maxInactiveSeedingTime = -1;
if ($("max_inactive_seeding_time_checkbox").checked) { if ($("maxInactiveSeedingTimeCheckbox").checked) {
max_inactive_seeding_time = Number($("max_inactive_seeding_time_value").value); maxInactiveSeedingTime = Number($("maxInactiveSeedingTimeValue").value);
if (isNaN(max_inactive_seeding_time) || (max_inactive_seeding_time < 0) || (max_inactive_seeding_time > 525600)) { if (Number.isNaN(maxInactiveSeedingTime) || (maxInactiveSeedingTime < 0) || (maxInactiveSeedingTime > 525600)) {
alert("QBT_TR(Seeding time limit must be between 0 and 525600 minutes.)QBT_TR[CONTEXT=HttpServer]"); alert("QBT_TR(Seeding time limit must be between 0 and 525600 minutes.)QBT_TR[CONTEXT=HttpServer]");
return; return;
} }
} }
settings["max_inactive_seeding_time_enabled"] = $("max_inactive_seeding_time_checkbox").checked; settings["max_inactive_seeding_time_enabled"] = $("maxInactiveSeedingTimeCheckbox").checked;
settings["max_inactive_seeding_time"] = max_inactive_seeding_time; settings["max_inactive_seeding_time"] = maxInactiveSeedingTime;
settings["max_ratio_act"] = Number($("max_ratio_act").value); settings["max_ratio_act"] = Number($("maxRatioSelect").value);
// Add trackers // Add trackers
settings["add_trackers_enabled"] = $("add_trackers_checkbox").checked; settings["add_trackers_enabled"] = $("add_trackers_checkbox").checked;
@ -2928,16 +2938,16 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
// WebUI tab // WebUI tab
// HTTP Server // HTTP Server
settings["web_ui_domain_list"] = $("webui_domain_textarea").value; settings["web_ui_domain_list"] = $("webuiDomainTextarea").value;
const web_ui_address = $("webui_address_value").value.toString(); const webUIAddress = $("webuiAddressValue").value.toString();
const web_ui_port = Number($("webui_port_value").value); const webUIPort = Number($("webuiPortValue").value);
if (isNaN(web_ui_port) || (web_ui_port < 1) || (web_ui_port > 65535)) { if (Number.isNaN(webUIPort) || (webUIPort < 1) || (webUIPort > 65535)) {
alert("QBT_TR(The port used for the WebUI must be between 1 and 65535.)QBT_TR[CONTEXT=HttpServer]"); alert("QBT_TR(The port used for the WebUI must be between 1 and 65535.)QBT_TR[CONTEXT=HttpServer]");
return; return;
} }
settings["web_ui_address"] = web_ui_address; settings["web_ui_address"] = webUIAddress;
settings["web_ui_port"] = web_ui_port; settings["web_ui_port"] = webUIPort;
settings["web_ui_upnp"] = $("webui_upnp_checkbox").checked; settings["web_ui_upnp"] = $("webuiUpnpCheckbox").checked;
const useHTTPS = $("use_https_checkbox").checked; const useHTTPS = $("use_https_checkbox").checked;
settings["use_https"] = useHTTPS; settings["use_https"] = useHTTPS;