WebUI: enforce parentheses around operators

PR #20696.
This commit is contained in:
Chocobo1 2024-04-15 12:50:07 +08:00 committed by GitHub
parent 6c82d5e305
commit d7cded54e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 67 additions and 57 deletions

View File

@ -8,6 +8,14 @@
"html" "html"
], ],
"rules": { "rules": {
"no-mixed-operators": [
"error",
{
"groups": [
["&", "|", "^", "~", "<<", ">>", ">>>", "==", "!=", "===", "!==", ">", ">=", "<", "<=", "&&", "||", "in", "instanceof"]
]
}
],
"no-undef": "off", "no-undef": "off",
"no-unused-vars": "off", "no-unused-vars": "off",
"nonblock-statement-body-position": ["error", "below"], "nonblock-statement-body-position": ["error", "below"],

View File

@ -40,7 +40,7 @@
new Event(e).stop(); new Event(e).stop();
// check field // check field
const name = $('rename').value.trim(); const name = $('rename').value.trim();
if (name === null || name === "") if ((name === null) || (name === ""))
return false; return false;
const hash = new URI().getData('hash'); const hash = new URI().getData('hash');

View File

@ -1567,7 +1567,7 @@ window.addEventListener("DOMContentLoaded", function() {
defaultEventType: 'keydown', defaultEventType: 'keydown',
events: { events: {
'ctrl+a': function(event) { 'ctrl+a': function(event) {
if (event.target.nodeName == "INPUT" || event.target.nodeName == "TEXTAREA") if ((event.target.nodeName === "INPUT") || (event.target.nodeName === "TEXTAREA"))
return; return;
if (event.target.isContentEditable) if (event.target.isContentEditable)
return; return;
@ -1575,7 +1575,7 @@ window.addEventListener("DOMContentLoaded", function() {
event.preventDefault(); event.preventDefault();
}, },
'delete': function(event) { 'delete': function(event) {
if (event.target.nodeName == "INPUT" || event.target.nodeName == "TEXTAREA") if ((event.target.nodeName === "INPUT") || (event.target.nodeName === "TEXTAREA"))
return; return;
if (event.target.isContentEditable) if (event.target.isContentEditable)
return; return;
@ -1583,7 +1583,7 @@ window.addEventListener("DOMContentLoaded", function() {
event.preventDefault(); event.preventDefault();
}, },
'shift+delete': (event) => { 'shift+delete': (event) => {
if (event.target.nodeName == "INPUT" || event.target.nodeName == "TEXTAREA") if ((event.target.nodeName === "INPUT") || (event.target.nodeName === "TEXTAREA"))
return; return;
if (event.target.isContentEditable) if (event.target.isContentEditable)
return; return;

View File

@ -119,9 +119,9 @@ window.qBittorrent.ContextMenu = (function() {
// position the menu // position the menu
let xPosMenu = e.page.x + this.options.offsets.x; let xPosMenu = e.page.x + this.options.offsets.x;
let yPosMenu = e.page.y + this.options.offsets.y; let yPosMenu = e.page.y + this.options.offsets.y;
if (xPosMenu + this.menu.offsetWidth > document.documentElement.clientWidth) if ((xPosMenu + this.menu.offsetWidth) > document.documentElement.clientWidth)
xPosMenu -= this.menu.offsetWidth; xPosMenu -= this.menu.offsetWidth;
if (yPosMenu + this.menu.offsetHeight > document.documentElement.clientHeight) if ((yPosMenu + this.menu.offsetHeight) > document.documentElement.clientHeight)
yPosMenu = document.documentElement.clientHeight - this.menu.offsetHeight; yPosMenu = document.documentElement.clientHeight - this.menu.offsetHeight;
if (xPosMenu < 0) if (xPosMenu < 0)
xPosMenu = 0; xPosMenu = 0;
@ -145,9 +145,9 @@ window.qBittorrent.ContextMenu = (function() {
const yPosOrigin = rectParent.bottom; const yPosOrigin = rectParent.bottom;
let xPos = xPosOrigin + rectParent.width - 1; let xPos = xPosOrigin + rectParent.width - 1;
let yPos = yPosOrigin - rectParent.height - 1; let yPos = yPosOrigin - rectParent.height - 1;
if (xPos + ul.offsetWidth > document.documentElement.clientWidth) if ((xPos + ul.offsetWidth) > document.documentElement.clientWidth)
xPos -= (ul.offsetWidth + rectParent.width - 2); xPos -= (ul.offsetWidth + rectParent.width - 2);
if (yPos + ul.offsetHeight > document.documentElement.clientHeight) if ((yPos + ul.offsetHeight) > document.documentElement.clientHeight)
yPos = document.documentElement.clientHeight - ul.offsetHeight; yPos = document.documentElement.clientHeight - ul.offsetHeight;
if (xPos < 0) if (xPos < 0)
xPos = 0; xPos = 0;
@ -240,7 +240,7 @@ window.qBittorrent.ContextMenu = (function() {
//show menu //show menu
show: function(trigger) { show: function(trigger) {
if (lastShownContextMenu && lastShownContextMenu != this) if (lastShownContextMenu && (lastShownContextMenu != this))
lastShownContextMenu.hide(); lastShownContextMenu.hide();
this.fx.start(1); this.fx.start(1);
this.fireEvent('show'); this.fireEvent('show');
@ -338,7 +338,7 @@ window.qBittorrent.ContextMenu = (function() {
else if (data['super_seeding'] !== true) else if (data['super_seeding'] !== true)
all_are_super_seeding = false; all_are_super_seeding = false;
if (data['state'] != 'stoppedUP' && data['state'] != 'stoppedDL') if ((data['state'] != 'stoppedUP') && (data['state'] != 'stoppedDL'))
all_are_stopped = false; all_are_stopped = false;
else else
there_are_stopped = true; there_are_stopped = true;
@ -363,7 +363,7 @@ window.qBittorrent.ContextMenu = (function() {
// hide renameFiles when more than 1 torrent is selected // hide renameFiles when more than 1 torrent is selected
if (selectedRows.length == 1) { if (selectedRows.length == 1) {
const data = torrentsTable.rows.get(selectedRows[0]).full_data; const data = torrentsTable.rows.get(selectedRows[0]).full_data;
let metadata_downloaded = !(data['state'] == 'metaDL' || data['state'] == 'forcedMetaDL' || data['total_size'] == -1); let metadata_downloaded = !((data['state'] == 'metaDL') || (data['state'] == 'forcedMetaDL') || (data['total_size'] == -1));
// hide renameFiles when metadata hasn't been downloaded yet // hide renameFiles when metadata hasn't been downloaded yet
metadata_downloaded metadata_downloaded

View File

@ -151,12 +151,12 @@ window.qBittorrent.DynamicTable = (function() {
this.canResize = false; this.canResize = false;
const resetElementBorderStyle = function(el, side) { const resetElementBorderStyle = function(el, side) {
if (side === 'left' || side !== 'right') { if ((side === 'left') || (side !== 'right')) {
el.setStyle('border-left-style', ''); el.setStyle('border-left-style', '');
el.setStyle('border-left-color', ''); el.setStyle('border-left-color', '');
el.setStyle('border-left-width', ''); el.setStyle('border-left-width', '');
} }
if (side === 'right' || side !== 'left') { if ((side === 'right') || (side !== 'left')) {
el.setStyle('border-right-style', ''); el.setStyle('border-right-style', '');
el.setStyle('border-right-color', ''); el.setStyle('border-right-color', '');
el.setStyle('border-right-width', ''); el.setStyle('border-right-width', '');
@ -167,7 +167,7 @@ window.qBittorrent.DynamicTable = (function() {
const brect = e.target.getBoundingClientRect(); const brect = e.target.getBoundingClientRect();
const mouseXRelative = e.event.clientX - brect.left; const mouseXRelative = e.event.clientX - brect.left;
if (this.currentHeaderAction === '') { if (this.currentHeaderAction === '') {
if (brect.width - mouseXRelative < 5) { if ((brect.width - mouseXRelative) < 5) {
this.resizeTh = e.target; this.resizeTh = e.target;
this.canResize = true; this.canResize = true;
e.target.getParent("tr").style.cursor = 'col-resize'; e.target.getParent("tr").style.cursor = 'col-resize';
@ -187,7 +187,7 @@ window.qBittorrent.DynamicTable = (function() {
let borderChangeElement = previousVisibleSibling; let borderChangeElement = previousVisibleSibling;
let changeBorderSide = 'right'; let changeBorderSide = 'right';
if (mouseXRelative > brect.width / 2) { if (mouseXRelative > (brect.width / 2)) {
borderChangeElement = e.target; borderChangeElement = e.target;
this.dropSide = 'right'; this.dropSide = 'right';
} }
@ -200,7 +200,7 @@ window.qBittorrent.DynamicTable = (function() {
if (!previousVisibleSibling) { // right most column if (!previousVisibleSibling) { // right most column
borderChangeElement = e.target; borderChangeElement = e.target;
if (mouseXRelative <= brect.width / 2) if (mouseXRelative <= (brect.width / 2))
changeBorderSide = 'left'; changeBorderSide = 'left';
} }
@ -429,7 +429,7 @@ window.qBittorrent.DynamicTable = (function() {
loadColumnsOrder: function() { loadColumnsOrder: function() {
const columnsOrder = []; const columnsOrder = [];
const val = LocalPreferences.get('columns_order_' + this.dynamicTableDivId); const val = LocalPreferences.get('columns_order_' + this.dynamicTableDivId);
if (val === null || val === undefined) if ((val === null) || (val === undefined))
return; return;
val.split(',').forEach(function(v) { val.split(',').forEach(function(v) {
if ((v in this.columns) && (!columnsOrder.contains(v))) if ((v in this.columns) && (!columnsOrder.contains(v)))
@ -1141,7 +1141,7 @@ window.qBittorrent.DynamicTable = (function() {
this.columns['progress'].updateTd = function(td, row) { this.columns['progress'].updateTd = function(td, row) {
const progress = this.getRowValue(row); const progress = this.getRowValue(row);
let progressFormatted = (progress * 100).round(1); let progressFormatted = (progress * 100).round(1);
if (progressFormatted == 100.0 && progress != 1.0) if ((progressFormatted == 100.0) && (progress != 1.0))
progressFormatted = 99.9; progressFormatted = 99.9;
if (td.getChildren('div').length > 0) { if (td.getChildren('div').length > 0) {
@ -1310,7 +1310,7 @@ window.qBittorrent.DynamicTable = (function() {
td.set('title', '∞'); td.set('title', '∞');
} }
else { else {
const formattedVal = 'QBT_TR(%1 ago)QBT_TR[CONTEXT=TransferListDelegate]'.replace('%1', window.qBittorrent.Misc.friendlyDuration((new Date()) / 1000 - val)); const formattedVal = 'QBT_TR(%1 ago)QBT_TR[CONTEXT=TransferListDelegate]'.replace('%1', window.qBittorrent.Misc.friendlyDuration((new Date() / 1000) - val));
td.set('text', formattedVal); td.set('text', formattedVal);
td.set('title', formattedVal); td.set('title', formattedVal);
} }
@ -1343,7 +1343,7 @@ window.qBittorrent.DynamicTable = (function() {
return false; return false;
break; break;
case 'seeding': case 'seeding':
if (state != 'uploading' && state != 'forcedUP' && state != 'stalledUP' && state != 'queuedUP' && state != 'checkingUP') if ((state != 'uploading') && (state != 'forcedUP') && (state != 'stalledUP') && (state != 'queuedUP') && (state != 'checkingUP'))
return false; return false;
break; break;
case 'completed': case 'completed':
@ -1377,12 +1377,12 @@ window.qBittorrent.DynamicTable = (function() {
if (state == 'stalledDL') if (state == 'stalledDL')
r = (row['full_data'].upspeed > 0); r = (row['full_data'].upspeed > 0);
else else
r = state == 'metaDL' || state == 'forcedMetaDL' || state == 'downloading' || state == 'forcedDL' || state == 'uploading' || state == 'forcedUP'; r = (state == 'metaDL') || (state == 'forcedMetaDL') || (state == 'downloading') || (state == 'forcedDL') || (state == 'uploading') || (state == 'forcedUP');
if (r == inactive) if (r == inactive)
return false; return false;
break; break;
case 'checking': case 'checking':
if (state !== 'checkingUP' && state !== 'checkingDL' && state !== 'checkingResumeData') if ((state !== 'checkingUP') && (state !== 'checkingDL') && (state !== 'checkingResumeData'))
return false; return false;
break; break;
case 'moving': case 'moving':
@ -1390,7 +1390,7 @@ window.qBittorrent.DynamicTable = (function() {
return false; return false;
break; break;
case 'errored': case 'errored':
if (state != 'error' && state != "unknown" && state != "missingFiles") if ((state != 'error') && (state != 'unknown') && (state != 'missingFiles'))
return false; return false;
break; break;
} }
@ -1632,7 +1632,7 @@ window.qBittorrent.DynamicTable = (function() {
this.columns['progress'].updateTd = function(td, row) { this.columns['progress'].updateTd = function(td, row) {
const progress = this.getRowValue(row); const progress = this.getRowValue(row);
let progressFormatted = (progress * 100).round(1); let progressFormatted = (progress * 100).round(1);
if (progressFormatted == 100.0 && progress != 1.0) if ((progressFormatted == 100.0) && (progress != 1.0))
progressFormatted = 99.9; progressFormatted = 99.9;
progressFormatted += "%"; progressFormatted += "%";
td.set('text', progressFormatted); td.set('text', progressFormatted);
@ -3157,12 +3157,12 @@ window.qBittorrent.DynamicTable = (function() {
this.filterText = window.qBittorrent.Log.getFilterText(); this.filterText = window.qBittorrent.Log.getFilterText();
const filterTerms = (this.filterText.length > 0) ? this.filterText.toLowerCase().split(' ') : []; const filterTerms = (this.filterText.length > 0) ? this.filterText.toLowerCase().split(' ') : [];
const logLevels = window.qBittorrent.Log.getSelectedLevels(); const logLevels = window.qBittorrent.Log.getSelectedLevels();
if (filterTerms.length > 0 || logLevels.length < 4) { if ((filterTerms.length > 0) || (logLevels.length < 4)) {
for (let i = 0; i < rows.length; ++i) { for (let i = 0; i < rows.length; ++i) {
if (logLevels.indexOf(rows[i].full_data.type.toString()) == -1) if (logLevels.indexOf(rows[i].full_data.type.toString()) == -1)
continue; continue;
if (filterTerms.length > 0 && !window.qBittorrent.Misc.containsAllTerms(rows[i].full_data.message, filterTerms)) if ((filterTerms.length > 0) && !window.qBittorrent.Misc.containsAllTerms(rows[i].full_data.message, filterTerms))
continue; continue;
filteredRows.push(rows[i]); filteredRows.push(rows[i]);
@ -3225,7 +3225,7 @@ window.qBittorrent.DynamicTable = (function() {
const filterTerms = (this.filterText.length > 0) ? this.filterText.toLowerCase().split(' ') : []; const filterTerms = (this.filterText.length > 0) ? this.filterText.toLowerCase().split(' ') : [];
if (filterTerms.length > 0) { if (filterTerms.length > 0) {
for (let i = 0; i < rows.length; ++i) { for (let i = 0; i < rows.length; ++i) {
if (filterTerms.length > 0 && !window.qBittorrent.Misc.containsAllTerms(rows[i].full_data.ip, filterTerms)) if ((filterTerms.length > 0) && !window.qBittorrent.Misc.containsAllTerms(rows[i].full_data.ip, filterTerms))
continue; continue;
filteredRows.push(rows[i]); filteredRows.push(rows[i]);

View File

@ -71,7 +71,7 @@ window.qBittorrent.Misc = (function() {
return "QBT_TR(Unknown)QBT_TR[CONTEXT=misc]"; return "QBT_TR(Unknown)QBT_TR[CONTEXT=misc]";
let i = 0; let i = 0;
while (value >= 1024.0 && i < 6) { while ((value >= 1024.0) && (i < 6)) {
value /= 1024.0; value /= 1024.0;
++i; ++i;
} }
@ -104,7 +104,7 @@ window.qBittorrent.Misc = (function() {
* JS counterpart of the function in src/misc.cpp * JS counterpart of the function in src/misc.cpp
*/ */
const friendlyDuration = function(seconds, maxCap = -1) { const friendlyDuration = function(seconds, maxCap = -1) {
if (seconds < 0 || ((seconds >= maxCap) && (maxCap >= 0))) if ((seconds < 0) || ((seconds >= maxCap) && (maxCap >= 0)))
return "∞"; return "∞";
if (seconds === 0) if (seconds === 0)
return "0"; return "0";

View File

@ -52,7 +52,7 @@ window.qBittorrent.ProgressBar = (function() {
'lightbg': 'var(--color-background-default)', 'lightbg': 'var(--color-background-default)',
'lightfg': 'var(--color-text-default)' 'lightfg': 'var(--color-text-default)'
}; };
if (parameters && $type(parameters) == 'object') if (parameters && ($type(parameters) == 'object'))
$extend(vals, parameters); $extend(vals, parameters);
if (vals.height < 12) if (vals.height < 12)
vals.height = 12; vals.height = 12;

View File

@ -76,7 +76,7 @@ window.qBittorrent.MultiRename = (function() {
// Maximum of 250 matches per file // Maximum of 250 matches per file
++count; ++count;
} while (regex.global && count < 250); } while (regex.global && (count < 250));
return matches; return matches;
}; };
@ -182,7 +182,7 @@ window.qBittorrent.MultiRename = (function() {
break; break;
} }
// Ignore rows without a match // Ignore rows without a match
if (!matches || matches.length == 0) { if (!matches || (matches.length === 0)) {
continue; continue;
} }
@ -219,7 +219,7 @@ window.qBittorrent.MultiRename = (function() {
}, },
rename: async function() { rename: async function() {
if (!this.matchedFiles || this.matchedFiles.length === 0 || !this.hash) { if (!this.matchedFiles || (this.matchedFiles.length === 0) || !this.hash) {
this.onRenamed([]); this.onRenamed([]);
return; return;
} }

View File

@ -46,8 +46,10 @@
}; };
// select default when orig values not passed. using double equals to compare string and int // select default when orig values not passed. using double equals to compare string and int
if ((origValues[0] === "") || ((values.ratioLimit == UseGlobalLimit) && (values.seedingTimeLimit == UseGlobalLimit)) if ((origValues[0] === "")
&& (values.inactiveSeedingTimeLimit == UseGlobalLimit)) { || ((values.ratioLimit == UseGlobalLimit)
&& (values.seedingTimeLimit == UseGlobalLimit)
&& (values.inactiveSeedingTimeLimit == UseGlobalLimit))) {
// use default option // use default option
setSelectedRadioValue('shareLimit', 'default'); setSelectedRadioValue('shareLimit', 'default');
} }

View File

@ -1591,10 +1591,10 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
const min = input.getAttribute("min"); const min = input.getAttribute("min");
const max = input.getAttribute("max"); const max = input.getAttribute("max");
if (min && input.value.toInt() < min.toInt()) if (min && (input.value.toInt() < min.toInt()))
input.value = min; input.value = min;
if (max && input.value.toInt() > max.toInt()) if (max && (input.value.toInt() > max.toInt()))
input.value = max; input.value = max;
}; };
@ -2470,7 +2470,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
let max_connec = -1; let max_connec = -1;
if ($('max_connec_checkbox').getProperty('checked')) { if ($('max_connec_checkbox').getProperty('checked')) {
max_connec = $('max_connec_value').getProperty('value').toInt(); max_connec = $('max_connec_value').getProperty('value').toInt();
if (isNaN(max_connec) || max_connec <= 0) { if (isNaN(max_connec) || (max_connec <= 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;
} }
@ -2479,7 +2479,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
let max_connec_per_torrent = -1; let max_connec_per_torrent = -1;
if ($('max_connec_per_torrent_checkbox').getProperty('checked')) { if ($('max_connec_per_torrent_checkbox').getProperty('checked')) {
max_connec_per_torrent = $('max_connec_per_torrent_value').getProperty('value').toInt(); max_connec_per_torrent = $('max_connec_per_torrent_value').getProperty('value').toInt();
if (isNaN(max_connec_per_torrent) || max_connec_per_torrent <= 0) { if (isNaN(max_connec_per_torrent) || (max_connec_per_torrent <= 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;
} }
@ -2488,7 +2488,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
let max_uploads = -1; let max_uploads = -1;
if ($('max_uploads_checkbox').getProperty('checked')) { if ($('max_uploads_checkbox').getProperty('checked')) {
max_uploads = $('max_uploads_value').getProperty('value').toInt(); max_uploads = $('max_uploads_value').getProperty('value').toInt();
if (isNaN(max_uploads) || max_uploads <= 0) { if (isNaN(max_uploads) || (max_uploads <= 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;
} }
@ -2497,7 +2497,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
let max_uploads_per_torrent = -1; let max_uploads_per_torrent = -1;
if ($('max_uploads_per_torrent_checkbox').getProperty('checked')) { if ($('max_uploads_per_torrent_checkbox').getProperty('checked')) {
max_uploads_per_torrent = $('max_uploads_per_torrent_value').getProperty('value').toInt(); max_uploads_per_torrent = $('max_uploads_per_torrent_value').getProperty('value').toInt();
if (isNaN(max_uploads_per_torrent) || max_uploads_per_torrent <= 0) { if (isNaN(max_uploads_per_torrent) || (max_uploads_per_torrent <= 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;
} }
@ -2532,14 +2532,14 @@ 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 = $('up_limit_value').getProperty('value').toInt() * 1024; const up_limit = $('up_limit_value').getProperty('value').toInt() * 1024;
if (isNaN(up_limit) || up_limit < 0) { if (isNaN(up_limit) || (up_limit < 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'] = up_limit;
const dl_limit = $('dl_limit_value').getProperty('value').toInt() * 1024; const dl_limit = $('dl_limit_value').getProperty('value').toInt() * 1024;
if (isNaN(dl_limit) || dl_limit < 0) { if (isNaN(dl_limit) || (dl_limit < 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;
} }
@ -2547,14 +2547,14 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
// Alternative Global Rate Limits // Alternative Global Rate Limits
const alt_up_limit = $('alt_up_limit_value').getProperty('value').toInt() * 1024; const alt_up_limit = $('alt_up_limit_value').getProperty('value').toInt() * 1024;
if (isNaN(alt_up_limit) || alt_up_limit < 0) { if (isNaN(alt_up_limit) || (alt_up_limit < 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'] = alt_up_limit;
const alt_dl_limit = $('alt_dl_limit_value').getProperty('value').toInt() * 1024; const alt_dl_limit = $('alt_dl_limit_value').getProperty('value').toInt() * 1024;
if (isNaN(alt_dl_limit) || alt_dl_limit < 0) { if (isNaN(alt_dl_limit) || (alt_dl_limit < 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;
} }
@ -2590,19 +2590,19 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
settings['queueing_enabled'] = $('queueing_checkbox').getProperty('checked'); settings['queueing_enabled'] = $('queueing_checkbox').getProperty('checked');
if ($('queueing_checkbox').getProperty('checked')) { if ($('queueing_checkbox').getProperty('checked')) {
const max_active_downloads = $('max_active_dl_value').getProperty('value').toInt(); const max_active_downloads = $('max_active_dl_value').getProperty('value').toInt();
if (isNaN(max_active_downloads) || max_active_downloads < -1) { if (isNaN(max_active_downloads) || (max_active_downloads < -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'] = max_active_downloads;
const max_active_uploads = $('max_active_up_value').getProperty('value').toInt(); const max_active_uploads = $('max_active_up_value').getProperty('value').toInt();
if (isNaN(max_active_uploads) || max_active_uploads < -1) { if (isNaN(max_active_uploads) || (max_active_uploads < -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'] = max_active_uploads;
const max_active_torrents = $('max_active_to_value').getProperty('value').toInt(); const max_active_torrents = $('max_active_to_value').getProperty('value').toInt();
if (isNaN(max_active_torrents) || max_active_torrents < -1) { if (isNaN(max_active_torrents) || (max_active_torrents < -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;
} }
@ -2686,7 +2686,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
settings['web_ui_domain_list'] = $('webui_domain_textarea').getProperty('value'); settings['web_ui_domain_list'] = $('webui_domain_textarea').getProperty('value');
const web_ui_address = $('webui_address_value').getProperty('value').toString(); const web_ui_address = $('webui_address_value').getProperty('value').toString();
const web_ui_port = $('webui_port_value').getProperty('value').toInt(); const web_ui_port = $('webui_port_value').getProperty('value').toInt();
if (isNaN(web_ui_port) || web_ui_port < 1 || web_ui_port > 65535) { if (isNaN(web_ui_port) || (web_ui_port < 1) || (web_ui_port > 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;
} }

View File

@ -470,11 +470,11 @@
// check if rows matches flattened response // check if rows matches flattened response
let match = false; let match = false;
if (rssFeedTable.rows.getLength() - 1 === flattenedResp.length) { if ((rssFeedTable.rows.getLength() - 1) === flattenedResp.length) {
match = true; match = true;
for (let i = 0; i < flattenedResp.length; ++i) { for (let i = 0; i < flattenedResp.length; ++i) {
if ((flattenedResp[i].uid ? flattenedResp[i].uid : '') !== rssFeedTable.rows[i + 1].full_data.dataUid if (((flattenedResp[i].uid ? flattenedResp[i].uid : '') !== rssFeedTable.rows[i + 1].full_data.dataUid)
|| flattenedResp[i].fullName !== rssFeedTable.rows[i + 1].full_data.dataPath) { || (flattenedResp[i].fullName !== rssFeedTable.rows[i + 1].full_data.dataPath)) {
match = false; match = false;
break; break;
} }
@ -541,7 +541,7 @@
feedData[r.uid] = r.articles; feedData[r.uid] = r.articles;
// if feed that is open changed, reload // if feed that is open changed, reload
if (openedFeedPath !== undefined && r.fullName.slice(0, openedFeedPath.length) === openedFeedPath) if ((openedFeedPath !== undefined) && (r.fullName.slice(0, openedFeedPath.length) === openedFeedPath))
showRssFeed(r.fullName); showRssFeed(r.fullName);
} }
else { else {
@ -565,7 +565,7 @@
.each((row) => row.full_data.unread += readDifference); .each((row) => row.full_data.unread += readDifference);
// if feed that is opened changed update dynamically // if feed that is opened changed update dynamically
if (openedFeedPath !== undefined && r.fullName.slice(0, openedFeedPath.length) === openedFeedPath) { if ((openedFeedPath !== undefined) && (r.fullName.slice(0, openedFeedPath.length) === openedFeedPath)) {
for (let i = 0; i < r.articles.length; ++i) { for (let i = 0; i < r.articles.length; ++i) {
let matchingRow = rssArticleTable.rows.filter((row) => row.full_data.feedUid === r.uid) let matchingRow = rssArticleTable.rows.filter((row) => row.full_data.feedUid === r.uid)
.filter((row) => row.full_data.dataId === r.articles[i].id); .filter((row) => row.full_data.dataId === r.articles[i].id);
@ -714,7 +714,7 @@
rssArticleTable.rows.each((el) => el.full_data.isRead = true); rssArticleTable.rows.each((el) => el.full_data.isRead = true);
// find all children and set unread count to 0 // find all children and set unread count to 0
rssFeedTable.rows.filter((row) => row.full_data.dataPath.slice(0, path.length) === path && path !== row.full_data.dataPath) rssFeedTable.rows.filter((row) => (row.full_data.dataPath.slice(0, path.length) === path) && (path !== row.full_data.dataPath))
.each((row) => row.full_data.unread = 0); .each((row) => row.full_data.unread = 0);
// find selected row // find selected row

View File

@ -516,7 +516,7 @@
$('searchMaxSizePrefix').set('value', state.sizeFilter.maxUnit); $('searchMaxSizePrefix').set('value', state.sizeFilter.maxUnit);
const currentSearchPattern = $('searchPattern').getProperty('value').trim(); const currentSearchPattern = $('searchPattern').getProperty('value').trim();
if (state.running && state.searchPattern === currentSearchPattern) { if (state.running && (state.searchPattern === currentSearchPattern)) {
// allow search to be stopped // allow search to be stopped
$('startSearchButton').set('text', 'QBT_TR(Stop)QBT_TR[CONTEXT=SearchEngineWidget]'); $('startSearchButton').set('text', 'QBT_TR(Stop)QBT_TR[CONTEXT=SearchEngineWidget]');
searchPatternChanged = false; searchPatternChanged = false;
@ -708,7 +708,7 @@
const state = searchState.get(currentSearchId); const state = searchState.get(currentSearchId);
const currentSearchPattern = $('searchPattern').getProperty('value').trim(); const currentSearchPattern = $('searchPattern').getProperty('value').trim();
// start a new search if pattern has changed, otherwise allow the search to be stopped // start a new search if pattern has changed, otherwise allow the search to be stopped
if (state && state.searchPattern === currentSearchPattern) { if (state && (state.searchPattern === currentSearchPattern)) {
searchPatternChanged = false; searchPatternChanged = false;
$('startSearchButton').set('text', 'QBT_TR(Stop)QBT_TR[CONTEXT=SearchEngineWidget]'); $('startSearchButton').set('text', 'QBT_TR(Stop)QBT_TR[CONTEXT=SearchEngineWidget]');
} }