mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-10-22 10:46:04 +03:00
Merge pull request #20728 from Chocobo1/webui_state
WebUI: clean up code
This commit is contained in:
commit
d65d8558d6
21 changed files with 101 additions and 103 deletions
|
@ -8,6 +8,7 @@
|
|||
"html"
|
||||
],
|
||||
"rules": {
|
||||
"eqeqeq": "error",
|
||||
"no-mixed-operators": [
|
||||
"error",
|
||||
{
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
const hashes = new URI().getData('hashes').split('|');
|
||||
const setDlLimit = function() {
|
||||
const limit = $("dllimitUpdatevalue").value.toInt() * 1024;
|
||||
if (hashes[0] == "global") {
|
||||
if (hashes[0] === "global") {
|
||||
new Request({
|
||||
url: 'api/v2/transfer/setDownloadLimit',
|
||||
method: 'post',
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
const verifyTagName = function(name) {
|
||||
if ((name === null) || (name === ""))
|
||||
return false;
|
||||
if (name.indexOf(",") >= 0) {
|
||||
if (name.includes(",")) {
|
||||
alert("QBT_TR(Invalid tag name)QBT_TR[CONTEXT=TagFilterWidget]");
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
ToggleSelection: function(element, ref) {
|
||||
const rowId = parseInt(element.get('data-row-id'));
|
||||
const row = bulkRenameFilesTable.getNode(rowId);
|
||||
const checkState = row.checked == 1 ? 0 : 1;
|
||||
const checkState = (row.checked === 1) ? 0 : 1;
|
||||
bulkRenameFilesTable.toggleNodeTreeCheckbox(rowId, checkState);
|
||||
bulkRenameFilesTable.updateGlobalCheckbox();
|
||||
bulkRenameFilesTable.onRowSelectionChange(bulkRenameFilesTable.getSelectedRows());
|
||||
|
@ -285,10 +285,10 @@
|
|||
$('renameOptions').addEvent('change', function(e) {
|
||||
const combobox = e.target;
|
||||
const replaceOperation = combobox.value;
|
||||
if (replaceOperation == "Replace") {
|
||||
if (replaceOperation === "Replace") {
|
||||
fileRenamer.replaceAll = false;
|
||||
}
|
||||
else if (replaceOperation == "Replace All") {
|
||||
else if (replaceOperation === "Replace All") {
|
||||
fileRenamer.replaceAll = true;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -130,8 +130,8 @@ let toggleFilterDisplay = function() {};
|
|||
window.addEventListener("DOMContentLoaded", function() {
|
||||
const saveColumnSizes = function() {
|
||||
const filters_width = $('Filters').getSize().x;
|
||||
const properties_height_rel = $('propertiesPanel').getSize().y / Window.getSize().y;
|
||||
LocalPreferences.set('filters_width', filters_width);
|
||||
const properties_height_rel = $('propertiesPanel').getSize().y / Window.getSize().y;
|
||||
LocalPreferences.set('properties_height_rel', properties_height_rel);
|
||||
};
|
||||
|
||||
|
@ -149,11 +149,7 @@ window.addEventListener("DOMContentLoaded", function() {
|
|||
MochaUI.Desktop.initialize();
|
||||
|
||||
const buildTransfersTab = function() {
|
||||
let filt_w = LocalPreferences.get('filters_width');
|
||||
if ($defined(filt_w))
|
||||
filt_w = filt_w.toInt();
|
||||
else
|
||||
filt_w = 120;
|
||||
const filt_w = Number(LocalPreferences.get('filters_width', 120));
|
||||
new MochaUI.Column({
|
||||
id: 'filtersColumn',
|
||||
placement: 'left',
|
||||
|
@ -161,7 +157,6 @@ window.addEventListener("DOMContentLoaded", function() {
|
|||
width: filt_w,
|
||||
resizeLimit: [1, 300]
|
||||
});
|
||||
|
||||
new MochaUI.Column({
|
||||
id: 'mainColumn',
|
||||
placement: 'main'
|
||||
|
@ -211,7 +206,7 @@ window.addEventListener("DOMContentLoaded", function() {
|
|||
selected_category = hash;
|
||||
LocalPreferences.set('selected_category', selected_category);
|
||||
highlightSelectedCategory();
|
||||
if (typeof torrentsTable.tableBody != 'undefined')
|
||||
if (typeof torrentsTable.tableBody !== 'undefined')
|
||||
updateMainData();
|
||||
};
|
||||
|
||||
|
@ -251,7 +246,7 @@ window.addEventListener("DOMContentLoaded", function() {
|
|||
selected_filter = f;
|
||||
LocalPreferences.set('selected_filter', f);
|
||||
// Reload torrents
|
||||
if (typeof torrentsTable.tableBody != 'undefined')
|
||||
if (typeof torrentsTable.tableBody !== 'undefined')
|
||||
updateMainData();
|
||||
};
|
||||
|
||||
|
@ -927,7 +922,7 @@ window.addEventListener("DOMContentLoaded", function() {
|
|||
break;
|
||||
}
|
||||
|
||||
if (queueing_enabled != serverState.queueing) {
|
||||
if (queueing_enabled !== serverState.queueing) {
|
||||
queueing_enabled = serverState.queueing;
|
||||
torrentsTable.columns['priority'].force_hide = !queueing_enabled;
|
||||
torrentsTable.updateColumn('priority');
|
||||
|
@ -949,12 +944,12 @@ window.addEventListener("DOMContentLoaded", function() {
|
|||
}
|
||||
}
|
||||
|
||||
if (alternativeSpeedLimits != serverState.use_alt_speed_limits) {
|
||||
if (alternativeSpeedLimits !== serverState.use_alt_speed_limits) {
|
||||
alternativeSpeedLimits = serverState.use_alt_speed_limits;
|
||||
updateAltSpeedIcon(alternativeSpeedLimits);
|
||||
}
|
||||
|
||||
if (useSubcategories != serverState.use_subcategories) {
|
||||
if (useSubcategories !== serverState.use_subcategories) {
|
||||
useSubcategories = serverState.use_subcategories;
|
||||
updateCategoryList();
|
||||
}
|
||||
|
@ -1350,7 +1345,7 @@ window.addEventListener("DOMContentLoaded", function() {
|
|||
height: null
|
||||
});
|
||||
let prop_h = LocalPreferences.get('properties_height_rel');
|
||||
if ($defined(prop_h))
|
||||
if (prop_h !== null)
|
||||
prop_h = prop_h.toFloat() * Window.getSize().y;
|
||||
else
|
||||
prop_h = Window.getSize().y / 2.0;
|
||||
|
|
|
@ -240,7 +240,7 @@ window.qBittorrent.ContextMenu = (function() {
|
|||
|
||||
//show menu
|
||||
show: function(trigger) {
|
||||
if (lastShownContextMenu && (lastShownContextMenu != this))
|
||||
if (lastShownContextMenu && (lastShownContextMenu !== this))
|
||||
lastShownContextMenu.hide();
|
||||
this.fx.start(1);
|
||||
this.fireEvent('show');
|
||||
|
@ -265,7 +265,7 @@ window.qBittorrent.ContextMenu = (function() {
|
|||
},
|
||||
|
||||
getItemChecked: function(item) {
|
||||
return '0' != this.menu.getElement('a[href$=' + item + ']').firstChild.style.opacity;
|
||||
return this.menu.getElement('a[href$=' + item + ']').firstChild.style.opacity !== '0';
|
||||
},
|
||||
|
||||
//hide an item
|
||||
|
@ -333,12 +333,12 @@ window.qBittorrent.ContextMenu = (function() {
|
|||
else
|
||||
there_are_f_l_piece_prio = true;
|
||||
|
||||
if (data['progress'] != 1.0) // not downloaded
|
||||
if (data['progress'] !== 1.0) // not downloaded
|
||||
all_are_downloaded = false;
|
||||
else if (data['super_seeding'] !== true)
|
||||
all_are_super_seeding = false;
|
||||
|
||||
if ((data['state'] != 'stoppedUP') && (data['state'] != 'stoppedDL'))
|
||||
if ((data['state'] !== 'stoppedUP') && (data['state'] !== 'stoppedDL'))
|
||||
all_are_stopped = false;
|
||||
else
|
||||
there_are_stopped = true;
|
||||
|
@ -361,9 +361,9 @@ window.qBittorrent.ContextMenu = (function() {
|
|||
});
|
||||
|
||||
// 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;
|
||||
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
|
||||
metadata_downloaded
|
||||
|
|
|
@ -66,7 +66,7 @@ window.qBittorrent.Download = (function() {
|
|||
$('startTorrent').checked = !pref.add_stopped_enabled;
|
||||
$('addToTopOfQueue').checked = pref.add_to_top_of_queue;
|
||||
|
||||
if (pref.auto_tmm_enabled == 1) {
|
||||
if (pref.auto_tmm_enabled === 1) {
|
||||
$('autoTMM').selectedIndex = 1;
|
||||
$('savepath').disabled = true;
|
||||
}
|
||||
|
@ -96,12 +96,12 @@ window.qBittorrent.Download = (function() {
|
|||
};
|
||||
|
||||
const changeCategorySelect = function(item) {
|
||||
if (item.value == "\\other") {
|
||||
if (item.value === "\\other") {
|
||||
item.nextElementSibling.hidden = false;
|
||||
item.nextElementSibling.value = "";
|
||||
item.nextElementSibling.select();
|
||||
|
||||
if ($('autoTMM').selectedIndex == 1)
|
||||
if ($('autoTMM').selectedIndex === 1)
|
||||
$('savepath').value = defaultSavePath;
|
||||
}
|
||||
else {
|
||||
|
@ -109,7 +109,7 @@ window.qBittorrent.Download = (function() {
|
|||
const text = item.options[item.selectedIndex].textContent;
|
||||
item.nextElementSibling.value = text;
|
||||
|
||||
if ($('autoTMM').selectedIndex == 1) {
|
||||
if ($('autoTMM').selectedIndex === 1) {
|
||||
const categoryName = item.value;
|
||||
const category = categories[categoryName];
|
||||
let savePath = defaultSavePath;
|
||||
|
@ -121,7 +121,7 @@ window.qBittorrent.Download = (function() {
|
|||
};
|
||||
|
||||
const changeTMM = function(item) {
|
||||
if (item.selectedIndex == 1) {
|
||||
if (item.selectedIndex === 1) {
|
||||
$('savepath').disabled = true;
|
||||
|
||||
const categorySelect = $('categorySelect');
|
||||
|
|
|
@ -112,7 +112,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
let n = 2;
|
||||
|
||||
// is panel vertical scrollbar visible or does panel content not fit?
|
||||
while (((panel.clientWidth != panel.offsetWidth) || (panel.clientHeight != panel.scrollHeight)) && (n > 0)) {
|
||||
while (((panel.clientWidth !== panel.offsetWidth) || (panel.clientHeight !== panel.scrollHeight)) && (n > 0)) {
|
||||
--n;
|
||||
h -= 0.5;
|
||||
$(this.dynamicTableDivId).style.height = h + 'px';
|
||||
|
@ -136,7 +136,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
}
|
||||
|
||||
const panel = tableDiv.getParent('.panel');
|
||||
if (this.lastPanelHeight != panel.getBoundingClientRect().height) {
|
||||
if (this.lastPanelHeight !== panel.getBoundingClientRect().height) {
|
||||
this.lastPanelHeight = panel.getBoundingClientRect().height;
|
||||
panel.fireEvent('resize');
|
||||
}
|
||||
|
@ -470,7 +470,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
th.setAttribute('style', 'width: ' + this.columns[i].width + 'px;' + this.columns[i].style);
|
||||
th.columnName = this.columns[i].name;
|
||||
th.addClass('column_' + th.columnName);
|
||||
if ((this.columns[i].visible == '0') || this.columns[i].force_hide)
|
||||
if ((this.columns[i].visible === '0') || this.columns[i].force_hide)
|
||||
th.addClass('invisible');
|
||||
else
|
||||
th.removeClass('invisible');
|
||||
|
@ -479,14 +479,14 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
|
||||
getColumnPos: function(columnName) {
|
||||
for (let i = 0; i < this.columns.length; ++i)
|
||||
if (this.columns[i].name == columnName)
|
||||
if (this.columns[i].name === columnName)
|
||||
return i;
|
||||
return -1;
|
||||
},
|
||||
|
||||
updateColumn: function(columnName) {
|
||||
const pos = this.getColumnPos(columnName);
|
||||
const visible = ((this.columns[pos].visible != '0') && !this.columns[pos].force_hide);
|
||||
const visible = ((this.columns[pos].visible !== '0') && !this.columns[pos].force_hide);
|
||||
const ths = this.hiddenTableHeader.getElements('th');
|
||||
const fths = this.fixedTableHeader.getElements('th');
|
||||
const trs = this.tableBody.getElements('tr');
|
||||
|
@ -521,7 +521,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
* @param {string|null} reverse defaults to implementation-specific behavior when not specified. Should only be passed when restoring previous state.
|
||||
*/
|
||||
setSortedColumn: function(column, reverse = null) {
|
||||
if (column != this.sortedColumn) {
|
||||
if (column !== this.sortedColumn) {
|
||||
const oldColumn = this.sortedColumn;
|
||||
this.sortedColumn = column;
|
||||
this.reverseSort = reverse ?? '0';
|
||||
|
@ -540,7 +540,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
setSortedColumnIcon: function(newColumn, oldColumn, isReverse) {
|
||||
const getCol = function(headerDivId, colName) {
|
||||
const colElem = $$("#" + headerDivId + " .column_" + colName);
|
||||
if (colElem.length == 1)
|
||||
if (colElem.length === 1)
|
||||
return colElem[0];
|
||||
return null;
|
||||
};
|
||||
|
@ -623,7 +623,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
let select = false;
|
||||
const that = this;
|
||||
this.tableBody.getElements('tr').each(function(tr) {
|
||||
if ((tr.rowId == rowId1) || (tr.rowId == rowId2)) {
|
||||
if ((tr.rowId === rowId1) || (tr.rowId === rowId2)) {
|
||||
select = !select;
|
||||
that.selectedRows.push(tr.rowId);
|
||||
}
|
||||
|
@ -639,7 +639,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
this.deselectAll();
|
||||
this.selectedRows = rowIds.slice();
|
||||
this.tableBody.getElements('tr').each(function(tr) {
|
||||
if (rowIds.indexOf(tr.rowId) > -1)
|
||||
if (rowIds.includes(tr.rowId))
|
||||
tr.addClass('selected');
|
||||
});
|
||||
},
|
||||
|
@ -700,7 +700,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
getTrByRowId: function(rowId) {
|
||||
const trs = this.tableBody.getElements('tr');
|
||||
for (let i = 0; i < trs.length; ++i)
|
||||
if (trs[i].rowId == rowId)
|
||||
if (trs[i].rowId === rowId)
|
||||
return trs[i];
|
||||
return null;
|
||||
},
|
||||
|
@ -720,9 +720,9 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
const rowId = rows[rowPos]['rowId'];
|
||||
let tr_found = false;
|
||||
for (let j = rowPos; j < trs.length; ++j)
|
||||
if (trs[j]['rowId'] == rowId) {
|
||||
if (trs[j]['rowId'] === rowId) {
|
||||
tr_found = true;
|
||||
if (rowPos == j)
|
||||
if (rowPos === j)
|
||||
break;
|
||||
trs[j].inject(trs[rowPos], 'before');
|
||||
const tmpTr = trs[j];
|
||||
|
@ -759,7 +759,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
else
|
||||
this._this.selectRow(this.rowId);
|
||||
}
|
||||
else if (e.shift && (this._this.selectedRows.length == 1)) {
|
||||
else if (e.shift && (this._this.selectedRows.length === 1)) {
|
||||
// Shift key was pressed
|
||||
this._this.selectRows(this._this.getSelectedRowId(), this.rowId);
|
||||
}
|
||||
|
@ -791,7 +791,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
|
||||
for (let k = 0; k < this.columns.length; ++k) {
|
||||
const td = new Element('td');
|
||||
if ((this.columns[k].visible == '0') || this.columns[k].force_hide)
|
||||
if ((this.columns[k].visible === '0') || this.columns[k].force_hide)
|
||||
td.addClass('invisible');
|
||||
td.injectInside(tr);
|
||||
}
|
||||
|
@ -1021,7 +1021,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
|
||||
if (td.getChildren('img').length > 0) {
|
||||
const img = td.getChildren('img')[0];
|
||||
if (img.src.indexOf(img_path) < 0) {
|
||||
if (!img.src.includes(img_path)) {
|
||||
img.set('src', img_path);
|
||||
img.set('title', state);
|
||||
}
|
||||
|
@ -1141,7 +1141,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
this.columns['progress'].updateTd = function(td, row) {
|
||||
const progress = this.getRowValue(row);
|
||||
let progressFormatted = (progress * 100).round(1);
|
||||
if ((progressFormatted == 100.0) && (progress != 1.0))
|
||||
if ((progressFormatted === 100.0) && (progress !== 1.0))
|
||||
progressFormatted = 99.9;
|
||||
|
||||
if (td.getChildren('div').length > 0) {
|
||||
|
@ -1150,7 +1150,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
td.resized = false;
|
||||
div.setWidth(ProgressColumnWidth - 5);
|
||||
}
|
||||
if (div.getValue() != progressFormatted)
|
||||
if (div.getValue() !== progressFormatted)
|
||||
div.setValue(progressFormatted);
|
||||
}
|
||||
else {
|
||||
|
@ -1181,7 +1181,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
const num_seeds = this.getRowValue(row, 0);
|
||||
const num_complete = this.getRowValue(row, 1);
|
||||
let value = num_seeds;
|
||||
if (num_complete != -1)
|
||||
if (num_complete !== -1)
|
||||
value += ' (' + num_complete + ')';
|
||||
td.set('text', value);
|
||||
td.set('title', value);
|
||||
|
@ -1335,52 +1335,53 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
const state = row['full_data'].state;
|
||||
const name = row['full_data'].name.toLowerCase();
|
||||
let inactive = false;
|
||||
let r;
|
||||
|
||||
switch (filterName) {
|
||||
case 'downloading':
|
||||
if ((state != 'downloading') && (state.indexOf('DL') === -1))
|
||||
if ((state !== 'downloading') && !state.includes('DL'))
|
||||
return false;
|
||||
break;
|
||||
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;
|
||||
break;
|
||||
case 'completed':
|
||||
if ((state != 'uploading') && (state.indexOf('UP') === -1))
|
||||
if ((state !== 'uploading') && !state.includes('UP'))
|
||||
return false;
|
||||
break;
|
||||
case 'stopped':
|
||||
if (state.indexOf('stopped') === -1)
|
||||
if (!state.includes('stopped'))
|
||||
return false;
|
||||
break;
|
||||
case 'running':
|
||||
if (state.indexOf('stopped') > -1)
|
||||
if (state.includes('stopped'))
|
||||
return false;
|
||||
break;
|
||||
case 'stalled':
|
||||
if ((state != 'stalledUP') && (state != 'stalledDL'))
|
||||
if ((state !== 'stalledUP') && (state !== 'stalledDL'))
|
||||
return false;
|
||||
break;
|
||||
case 'stalled_uploading':
|
||||
if (state != 'stalledUP')
|
||||
if (state !== 'stalledUP')
|
||||
return false;
|
||||
break;
|
||||
case 'stalled_downloading':
|
||||
if (state != 'stalledDL')
|
||||
if (state !== 'stalledDL')
|
||||
return false;
|
||||
break;
|
||||
case 'inactive':
|
||||
inactive = true;
|
||||
// fallthrough
|
||||
case 'active':
|
||||
if (state == 'stalledDL')
|
||||
case 'active': {
|
||||
let r;
|
||||
if (state === 'stalledDL')
|
||||
r = (row['full_data'].upspeed > 0);
|
||||
else
|
||||
r = (state == 'metaDL') || (state == 'forcedMetaDL') || (state == 'downloading') || (state == 'forcedDL') || (state == 'uploading') || (state == 'forcedUP');
|
||||
if (r == inactive)
|
||||
r = (state === 'metaDL') || (state === 'forcedMetaDL') || (state === 'downloading') || (state === 'forcedDL') || (state === 'uploading') || (state === 'forcedUP');
|
||||
if (r === inactive)
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
case 'checking':
|
||||
if ((state !== 'checkingUP') && (state !== 'checkingDL') && (state !== 'checkingResumeData'))
|
||||
return false;
|
||||
|
@ -1390,7 +1391,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
return false;
|
||||
break;
|
||||
case 'errored':
|
||||
if ((state != 'error') && (state != 'unknown') && (state != 'missingFiles'))
|
||||
if ((state !== 'error') && (state !== 'unknown') && (state !== 'missingFiles'))
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
@ -1533,7 +1534,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
this._this.selectRow(this.rowId);
|
||||
const row = this._this.rows.get(this.rowId);
|
||||
const state = row['full_data'].state;
|
||||
if (state.indexOf('stopped') > -1)
|
||||
if (state.includes('stopped'))
|
||||
startFN();
|
||||
else
|
||||
stopFN();
|
||||
|
@ -1615,7 +1616,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
const b = ip2.split(".");
|
||||
|
||||
for (let i = 0; i < 4; ++i) {
|
||||
if (a[i] != b[i])
|
||||
if (a[i] !== b[i])
|
||||
return a[i] - b[i];
|
||||
}
|
||||
|
||||
|
@ -1632,7 +1633,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
this.columns['progress'].updateTd = function(td, row) {
|
||||
const progress = this.getRowValue(row);
|
||||
let progressFormatted = (progress * 100).round(1);
|
||||
if ((progressFormatted == 100.0) && (progress != 1.0))
|
||||
if ((progressFormatted === 100.0) && (progress !== 1.0))
|
||||
progressFormatted = 99.9;
|
||||
progressFormatted += "%";
|
||||
td.set('text', progressFormatted);
|
||||
|
@ -1900,7 +1901,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
getSelectedRows: function() {
|
||||
const nodes = this.fileTree.toArray();
|
||||
|
||||
return nodes.filter(x => x.checked == 0);
|
||||
return nodes.filter(x => x.checked === 0);
|
||||
},
|
||||
|
||||
initColumns: function() {
|
||||
|
@ -1951,7 +1952,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
node.checked = checkState;
|
||||
node.full_data.checked = checkState;
|
||||
const checkbox = $(`cbRename${rowId}`);
|
||||
checkbox.checked = node.checked == 0;
|
||||
checkbox.checked = node.checked === 0;
|
||||
checkbox.state = checkbox.checked ? "checked" : "unchecked";
|
||||
|
||||
for (let i = 0; i < node.children.length; ++i) {
|
||||
|
@ -2020,7 +2021,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
that.onRowSelectionChange(node);
|
||||
e.stopPropagation();
|
||||
});
|
||||
checkbox.checked = value == 0;
|
||||
checkbox.checked = (value === 0);
|
||||
checkbox.state = checkbox.checked ? "checked" : "unchecked";
|
||||
checkbox.indeterminate = false;
|
||||
td.adopt(treeImg, checkbox);
|
||||
|
@ -2095,7 +2096,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
const that = this;
|
||||
this.deselectAll();
|
||||
this.tableBody.getElements('tr').each(function(tr) {
|
||||
if (rowIds.indexOf(tr.rowId) > -1) {
|
||||
if (rowIds.includes(tr.rowId)) {
|
||||
const node = that.getNode(tr.rowId);
|
||||
node.checked = 0;
|
||||
node.full_data.checked = 0;
|
||||
|
@ -2704,7 +2705,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
}
|
||||
if (td.getChildren('img').length > 0) {
|
||||
const img = td.getChildren('img')[0];
|
||||
if (img.src.indexOf(img_path) < 0) {
|
||||
if (!img.src.includes(img_path)) {
|
||||
img.set('src', img_path);
|
||||
img.set('title', status);
|
||||
}
|
||||
|
@ -3159,7 +3160,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
const logLevels = window.qBittorrent.Log.getSelectedLevels();
|
||||
if ((filterTerms.length > 0) || (logLevels.length < 4)) {
|
||||
for (let i = 0; i < rows.length; ++i) {
|
||||
if (logLevels.indexOf(rows[i].full_data.type.toString()) == -1)
|
||||
if (!logLevels.includes(rows[i].full_data.type.toString()))
|
||||
continue;
|
||||
|
||||
if ((filterTerms.length > 0) && !window.qBittorrent.Misc.containsAllTerms(rows[i].full_data.message, filterTerms))
|
||||
|
@ -3175,7 +3176,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
filteredRows.sort(function(row1, row2) {
|
||||
const column = this.columns[this.sortedColumn];
|
||||
const res = column.compareRows(row1, row2);
|
||||
return (this.reverseSort == '0') ? res : -res;
|
||||
return (this.reverseSort === '0') ? res : -res;
|
||||
}.bind(this));
|
||||
|
||||
return filteredRows;
|
||||
|
@ -3238,7 +3239,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
filteredRows.sort(function(row1, row2) {
|
||||
const column = this.columns[this.sortedColumn];
|
||||
const res = column.compareRows(row1, row2);
|
||||
return (this.reverseSort == '0') ? res : -res;
|
||||
return (this.reverseSort === '0') ? res : -res;
|
||||
}.bind(this));
|
||||
|
||||
return filteredRows;
|
||||
|
|
|
@ -506,7 +506,7 @@ const initializeWindows = function() {
|
|||
|
||||
renameFN = function() {
|
||||
const hashes = torrentsTable.selectedRowsIds();
|
||||
if (hashes.length == 1) {
|
||||
if (hashes.length === 1) {
|
||||
const hash = hashes[0];
|
||||
const row = torrentsTable.rows[hash];
|
||||
if (row) {
|
||||
|
@ -529,7 +529,7 @@ const initializeWindows = function() {
|
|||
|
||||
renameFilesFN = function() {
|
||||
const hashes = torrentsTable.selectedRowsIds();
|
||||
if (hashes.length == 1) {
|
||||
if (hashes.length === 1) {
|
||||
const hash = hashes[0];
|
||||
const row = torrentsTable.rows[hash];
|
||||
if (row) {
|
||||
|
|
|
@ -60,8 +60,8 @@ window.qBittorrent.PiecesBar = (() => {
|
|||
'borderColor': 'var(--color-border-default)'
|
||||
};
|
||||
|
||||
if (parameters && ($type(parameters) === 'object'))
|
||||
$extend(vals, parameters);
|
||||
if (parameters && (typeOf(parameters) === 'object'))
|
||||
Object.append(vals, parameters);
|
||||
vals.height = Math.max(vals.height, 12);
|
||||
|
||||
const obj = new Element('div', {
|
||||
|
@ -73,7 +73,7 @@ window.qBittorrent.PiecesBar = (() => {
|
|||
}
|
||||
});
|
||||
obj.vals = vals;
|
||||
obj.vals.pieces = $pick(pieces, []);
|
||||
obj.vals.pieces = [pieces, []].pick();
|
||||
|
||||
obj.vals.canvas = new Element('canvas', {
|
||||
'id': vals.id + '_canvas',
|
||||
|
|
|
@ -44,7 +44,7 @@ window.qBittorrent.ProgressBar = (function() {
|
|||
initialize: function(value, parameters) {
|
||||
const vals = {
|
||||
'id': 'progressbar_' + (ProgressBars++),
|
||||
'value': $pick(value, 0),
|
||||
'value': [value, 0].pick(),
|
||||
'width': 0,
|
||||
'height': 0,
|
||||
'darkbg': 'var(--color-background-blue)',
|
||||
|
@ -52,8 +52,8 @@ window.qBittorrent.ProgressBar = (function() {
|
|||
'lightbg': 'var(--color-background-default)',
|
||||
'lightfg': 'var(--color-text-default)'
|
||||
};
|
||||
if (parameters && ($type(parameters) == 'object'))
|
||||
$extend(vals, parameters);
|
||||
if (parameters && (typeOf(parameters) === 'object'))
|
||||
Object.append(vals, parameters);
|
||||
if (vals.height < 12)
|
||||
vals.height = 12;
|
||||
const obj = new Element('div', {
|
||||
|
@ -68,7 +68,7 @@ window.qBittorrent.ProgressBar = (function() {
|
|||
}
|
||||
});
|
||||
obj.vals = vals;
|
||||
obj.vals.value = $pick(value, 0); // Fix by Chris
|
||||
obj.vals.value = [value, 0].pick();
|
||||
obj.vals.dark = new Element('div', {
|
||||
'id': vals.id + '_dark',
|
||||
'class': 'progressbar_dark',
|
||||
|
|
|
@ -350,7 +350,7 @@ window.qBittorrent.PropFiles = (function() {
|
|||
return;
|
||||
}
|
||||
let loadedNewTorrent = false;
|
||||
if (new_hash != current_hash) {
|
||||
if (new_hash !== current_hash) {
|
||||
torrentFilesTable.clear();
|
||||
current_hash = new_hash;
|
||||
loadedNewTorrent = true;
|
||||
|
|
|
@ -94,7 +94,7 @@ window.qBittorrent.PropPeers = (function() {
|
|||
torrentPeersTable.altRow();
|
||||
|
||||
if (response['show_flags']) {
|
||||
if (show_flags != response['show_flags']) {
|
||||
if (show_flags !== response['show_flags']) {
|
||||
show_flags = response['show_flags'];
|
||||
torrentPeersTable.columns['country'].force_hide = !show_flags;
|
||||
torrentPeersTable.updateColumn('country');
|
||||
|
|
|
@ -57,7 +57,7 @@ window.qBittorrent.PropTrackers = (function() {
|
|||
loadTrackersDataTimer = loadTrackersData.delay(10000);
|
||||
return;
|
||||
}
|
||||
if (new_hash != current_hash) {
|
||||
if (new_hash !== current_hash) {
|
||||
torrentTrackersTable.clear();
|
||||
current_hash = new_hash;
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ window.qBittorrent.PropWebseeds = (function() {
|
|||
loadWebSeedsDataTimer = loadWebSeedsData.delay(10000);
|
||||
return;
|
||||
}
|
||||
if (new_hash != current_hash) {
|
||||
if (new_hash !== current_hash) {
|
||||
wsTable.removeAllRows();
|
||||
current_hash = new_hash;
|
||||
}
|
||||
|
|
|
@ -61,13 +61,14 @@ window.qBittorrent.MultiRename = (function() {
|
|||
let matches = [];
|
||||
do {
|
||||
result = regex.exec(str);
|
||||
if (result === null)
|
||||
break;
|
||||
|
||||
if (result == null) { break; }
|
||||
matches.push(result);
|
||||
|
||||
// regex assertions don't modify lastIndex,
|
||||
// so we need to explicitly break out to prevent infinite loop
|
||||
if (lastIndex == regex.lastIndex) {
|
||||
if (lastIndex === regex.lastIndex) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -44,7 +44,7 @@ MochaUI.extend({
|
|||
maximum = tmp / 1024.0;
|
||||
}
|
||||
else {
|
||||
if (hashes[0] == "global")
|
||||
if (hashes[0] === "global")
|
||||
maximum = 10000;
|
||||
else
|
||||
maximum = 1000;
|
||||
|
@ -52,7 +52,7 @@ MochaUI.extend({
|
|||
}
|
||||
// Get torrents upload limit
|
||||
// And create slider
|
||||
if (hashes[0] == 'global') {
|
||||
if (hashes[0] === 'global') {
|
||||
let up_limit = maximum;
|
||||
if (up_limit < 0)
|
||||
up_limit = 0;
|
||||
|
@ -93,7 +93,7 @@ MochaUI.extend({
|
|||
if (data) {
|
||||
let up_limit = data[hashes[0]];
|
||||
for (const key in data)
|
||||
if (up_limit != data[key]) {
|
||||
if (up_limit !== data[key]) {
|
||||
up_limit = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ MochaUI.extend({
|
|||
maximum = tmp / 1024.0;
|
||||
}
|
||||
else {
|
||||
if (hashes[0] == "global")
|
||||
if (hashes[0] === "global")
|
||||
maximum = 10000;
|
||||
else
|
||||
maximum = 1000;
|
||||
|
@ -155,7 +155,7 @@ MochaUI.extend({
|
|||
}
|
||||
// Get torrents download limit
|
||||
// And create slider
|
||||
if (hashes[0] == 'global') {
|
||||
if (hashes[0] === 'global') {
|
||||
let dl_limit = maximum;
|
||||
if (dl_limit < 0)
|
||||
dl_limit = 0;
|
||||
|
@ -196,7 +196,7 @@ MochaUI.extend({
|
|||
if (data) {
|
||||
let dl_limit = data[hashes[0]];
|
||||
for (const key in data)
|
||||
if (dl_limit != data[key]) {
|
||||
if (dl_limit !== data[key]) {
|
||||
dl_limit = 0;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -47,13 +47,13 @@
|
|||
|
||||
// select default when orig values not passed. using double equals to compare string and int
|
||||
if ((origValues[0] === "")
|
||||
|| ((values.ratioLimit == UseGlobalLimit)
|
||||
&& (values.seedingTimeLimit == UseGlobalLimit)
|
||||
&& (values.inactiveSeedingTimeLimit == UseGlobalLimit))) {
|
||||
|| ((values.ratioLimit === UseGlobalLimit)
|
||||
&& (values.seedingTimeLimit === UseGlobalLimit)
|
||||
&& (values.inactiveSeedingTimeLimit === UseGlobalLimit))) {
|
||||
// use default option
|
||||
setSelectedRadioValue('shareLimit', 'default');
|
||||
}
|
||||
else if ((values.maxRatio == NoLimit) && (values.maxSeedingTime == NoLimit) && (values.maxInactiveSeedingTime == NoLimit)) {
|
||||
else if ((values.maxRatio === NoLimit) && (values.maxSeedingTime === NoLimit) && (values.maxInactiveSeedingTime === NoLimit)) {
|
||||
setSelectedRadioValue('shareLimit', 'none');
|
||||
// TODO set input boxes to *global* max ratio and seeding time
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
const hashes = new URI().getData('hashes').split('|');
|
||||
const setUpLimit = function() {
|
||||
const limit = $("uplimitUpdatevalue").value.toInt() * 1024;
|
||||
if (hashes[0] == "global") {
|
||||
if (hashes[0] === "global") {
|
||||
new Request({
|
||||
url: 'api/v2/transfer/setUploadLimit',
|
||||
method: 'post',
|
||||
|
|
|
@ -1893,7 +1893,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
|
|||
};
|
||||
|
||||
const registerDynDns = function() {
|
||||
if ($('dyndns_select').getProperty('value').toInt() == 1) {
|
||||
if ($('dyndns_select').getProperty('value').toInt() === 1) {
|
||||
window.open("http://www.no-ip.com/services/managed_dns/free_dynamic_dns.html", "NO-IP Registration");
|
||||
}
|
||||
else {
|
||||
|
@ -1910,7 +1910,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
|
|||
|
||||
const time_padding = function(val) {
|
||||
let ret = val.toString();
|
||||
if (ret.length == 1)
|
||||
if (ret.length === 1)
|
||||
ret = '0' + ret;
|
||||
return ret;
|
||||
};
|
||||
|
@ -2041,7 +2041,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
|
|||
$('temppath_checkbox').setProperty('checked', pref.temp_path_enabled);
|
||||
$('temppath_text').setProperty('value', pref.temp_path);
|
||||
updateTempDirEnabled();
|
||||
if (pref.export_dir != '') {
|
||||
if (pref.export_dir !== '') {
|
||||
$('exportdir_checkbox').setProperty('checked', true);
|
||||
$('exportdir_text').setProperty('value', pref.export_dir);
|
||||
}
|
||||
|
@ -2050,7 +2050,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
|
|||
$('exportdir_text').setProperty('value', '');
|
||||
}
|
||||
updateExportDirEnabled();
|
||||
if (pref.export_dir_fin != '') {
|
||||
if (pref.export_dir_fin !== '') {
|
||||
$('exportdirfin_checkbox').setProperty('checked', true);
|
||||
$('exportdirfin_text').setProperty('value', pref.export_dir_fin);
|
||||
}
|
||||
|
|
|
@ -913,7 +913,7 @@
|
|||
};
|
||||
|
||||
const searchSizeFilterPrefixChanged = function() {
|
||||
if (($('searchMinSizeFilter').get('value') != 0) || ($('searchMaxSizeFilter').get('value') != 0))
|
||||
if ((Number($('searchMinSizeFilter').get('value')) !== 0) || (Number($('searchMaxSizeFilter').get('value')) !== 0))
|
||||
searchSizeFilterChanged();
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue