diff --git a/src/webui/www/eslint.config.mjs b/src/webui/www/eslint.config.mjs index 95881a303dbe..6aafb8d64496 100644 --- a/src/webui/www/eslint.config.mjs +++ b/src/webui/www/eslint.config.mjs @@ -37,6 +37,7 @@ export default [ "operator-assignment": "error", "prefer-arrow-callback": "error", "prefer-const": "error", + "prefer-template": "error", "radix": "error", "PreferArrowFunctions/prefer-arrow-functions": "error", "Stylistic/no-mixed-operators": [ diff --git a/src/webui/www/package.json b/src/webui/www/package.json index 760dbecae154..818d487385ff 100644 --- a/src/webui/www/package.json +++ b/src/webui/www/package.json @@ -13,7 +13,7 @@ "@stylistic/eslint-plugin": "*", "eslint": "*", "eslint-plugin-html": "*", - "eslint-plugin-prefer-arrow-functions": "3.4.2", + "eslint-plugin-prefer-arrow-functions": "*", "eslint-plugin-regexp": "*", "html-validate": "*", "js-beautify": "*", diff --git a/src/webui/www/private/newcategory.html b/src/webui/www/private/newcategory.html index 116e12bfcfd7..b2ec949fa66f 100644 --- a/src/webui/www/private/newcategory.html +++ b/src/webui/www/private/newcategory.html @@ -82,7 +82,7 @@ }) .then((response) => { if (!response.ok) { - alert("QBT_TR(Unable to create category)QBT_TR[CONTEXT=Category] " + window.qBittorrent.Misc.escapeHtml(categoryName)); + alert(`QBT_TR(Unable to create category)QBT_TR[CONTEXT=Category] ${window.qBittorrent.Misc.escapeHtml(categoryName)}`); return; } diff --git a/src/webui/www/private/rename_files.html b/src/webui/www/private/rename_files.html index 1815719727b6..8701b545d6b9 100644 --- a/src/webui/www/private/rename_files.html +++ b/src/webui/www/private/rename_files.html @@ -172,7 +172,7 @@ // Update renamed column for matched rows for (let i = 0; i < matchedRows.length; ++i) { const row = matchedRows[i]; - $("filesTablefileRenamed" + row.rowId).textContent = row.renamed; + $(`filesTablefileRenamed${row.rowId}`).textContent = row.renamed; } }; fileRenamer.onInvalidRegex = (err) => { diff --git a/src/webui/www/private/scripts/client.js b/src/webui/www/private/scripts/client.js index 36b5568b7b55..102517a74abf 100644 --- a/src/webui/www/private/scripts/client.js +++ b/src/webui/www/private/scripts/client.js @@ -88,9 +88,10 @@ window.qBittorrent.Client ??= (() => { const mainTitle = () => { const emDash = "\u2014"; const qbtVersion = window.qBittorrent.Cache.qbtVersion.get(); - const suffix = window.qBittorrent.Cache.preferences.get()["app_instance_name"] || ""; - const title = `qBittorrent ${qbtVersion} QBT_TR(WebUI)QBT_TR[CONTEXT=OptionsDialog]` - + ((suffix.length > 0) ? ` ${emDash} ${suffix}` : ""); + let suffix = window.qBittorrent.Cache.preferences.get()["app_instance_name"] || ""; + if (suffix.length > 0) + suffix = ` ${emDash} ${suffix}`; + const title = `qBittorrent ${qbtVersion} QBT_TR(WebUI)QBT_TR[CONTEXT=OptionsDialog]${suffix}`; return title; }; @@ -952,13 +953,13 @@ window.addEventListener("DOMContentLoaded", () => { const processServerState = () => { let transfer_info = window.qBittorrent.Misc.friendlyUnit(serverState.dl_info_speed, true); if (serverState.dl_rate_limit > 0) - transfer_info += " [" + window.qBittorrent.Misc.friendlyUnit(serverState.dl_rate_limit, true) + "]"; - transfer_info += " (" + window.qBittorrent.Misc.friendlyUnit(serverState.dl_info_data, false) + ")"; + transfer_info += ` [${window.qBittorrent.Misc.friendlyUnit(serverState.dl_rate_limit, true)}]`; + transfer_info += ` (${window.qBittorrent.Misc.friendlyUnit(serverState.dl_info_data, false)})`; $("DlInfos").textContent = transfer_info; transfer_info = window.qBittorrent.Misc.friendlyUnit(serverState.up_info_speed, true); if (serverState.up_rate_limit > 0) - transfer_info += " [" + window.qBittorrent.Misc.friendlyUnit(serverState.up_rate_limit, true) + "]"; - transfer_info += " (" + window.qBittorrent.Misc.friendlyUnit(serverState.up_info_data, false) + ")"; + transfer_info += ` [${window.qBittorrent.Misc.friendlyUnit(serverState.up_rate_limit, true)}]`; + transfer_info += ` (${window.qBittorrent.Misc.friendlyUnit(serverState.up_info_data, false)})`; $("UpInfos").textContent = transfer_info; document.title = (speedInTitle @@ -1010,12 +1011,12 @@ window.addEventListener("DOMContentLoaded", () => { $("TotalWastedSession").textContent = window.qBittorrent.Misc.friendlyUnit(serverState.total_wasted_session, false); $("GlobalRatio").textContent = serverState.global_ratio; $("TotalPeerConnections").textContent = serverState.total_peer_connections; - $("ReadCacheHits").textContent = serverState.read_cache_hits + "%"; + $("ReadCacheHits").textContent = `${serverState.read_cache_hits}%`; $("TotalBuffersSize").textContent = window.qBittorrent.Misc.friendlyUnit(serverState.total_buffers_size, false); - $("WriteCacheOverload").textContent = serverState.write_cache_overload + "%"; - $("ReadCacheOverload").textContent = serverState.read_cache_overload + "%"; + $("WriteCacheOverload").textContent = `${serverState.write_cache_overload}%`; + $("ReadCacheOverload").textContent = `${serverState.read_cache_overload}%`; $("QueuedIOJobs").textContent = serverState.queued_io_jobs; - $("AverageTimeInQueue").textContent = serverState.average_time_queue + " ms"; + $("AverageTimeInQueue").textContent = `${serverState.average_time_queue} ms`; $("TotalQueuedSize").textContent = window.qBittorrent.Misc.friendlyUnit(serverState.total_queued_size, false); } @@ -1149,8 +1150,7 @@ window.addEventListener("DOMContentLoaded", () => { hashParams.set("download", ""); const templateHashString = hashParams.toString().replace("download=", "download=%s"); - const templateUrl = location.origin + location.pathname - + location.search + "#" + templateHashString; + const templateUrl = `${location.origin}${location.pathname}${location.search}#${templateHashString}`; navigator.registerProtocolHandler("magnet", templateUrl, "qBittorrent WebUI magnet handler"); diff --git a/src/webui/www/private/scripts/dynamicTable.js b/src/webui/www/private/scripts/dynamicTable.js index b9b36466b0e6..dc3ca57dbcd8 100644 --- a/src/webui/www/private/scripts/dynamicTable.js +++ b/src/webui/www/private/scripts/dynamicTable.js @@ -81,8 +81,8 @@ window.qBittorrent.DynamicTable ??= (() => { this.selectedRows = []; this.columns = []; this.contextMenu = contextMenu; - this.sortedColumn = LocalPreferences.get("sorted_column_" + this.dynamicTableDivId, 0); - this.reverseSort = LocalPreferences.get("reverse_sort_" + this.dynamicTableDivId, "0"); + this.sortedColumn = LocalPreferences.get(`sorted_column_${this.dynamicTableDivId}`, 0); + this.reverseSort = LocalPreferences.get(`reverse_sort_${this.dynamicTableDivId}`, "0"); this.initColumns(); this.loadColumnsOrder(); this.updateTableHeaders(); @@ -283,13 +283,13 @@ window.qBittorrent.DynamicTable ??= (() => { this.saveColumnWidth(this.resizeTh.columnName); if ((this.currentHeaderAction === "drag") && (el !== this.lastHoverTh)) { this.saveColumnsOrder(); - const val = LocalPreferences.get("columns_order_" + this.dynamicTableDivId).split(","); + const val = LocalPreferences.get(`columns_order_${this.dynamicTableDivId}`).split(","); val.erase(el.columnName); let pos = val.indexOf(this.lastHoverTh.columnName); if (this.dropSide === "right") ++pos; val.splice(pos, 0, el.columnName); - LocalPreferences.set("columns_order_" + this.dynamicTableDivId, val.join(",")); + LocalPreferences.set(`columns_order_${this.dynamicTableDivId}`, val.join(",")); this.loadColumnsOrder(); this.updateTableHeaders(); this.tableBody.replaceChildren(); @@ -369,7 +369,7 @@ window.qBittorrent.DynamicTable ??= (() => { showColumn: function(columnName, show) { this.columns[columnName].visible = show ? "1" : "0"; - LocalPreferences.set("column_" + columnName + "_visible_" + this.dynamicTableDivId, show ? "1" : "0"); + LocalPreferences.set(`column_${columnName}_visible_${this.dynamicTableDivId}`, show ? "1" : "0"); this.updateColumn(columnName); }, @@ -430,7 +430,7 @@ window.qBittorrent.DynamicTable ??= (() => { setupHeaderMenu: function() { this.setupDynamicTableHeaderContextMenuClass(); - const menuId = this.dynamicTableDivId + "_headerMenu"; + const menuId = `${this.dynamicTableDivId}_headerMenu`; // reuse menu if already exists let ul = document.getElementById(menuId); @@ -504,7 +504,7 @@ window.qBittorrent.DynamicTable ??= (() => { document.body.append(ul); this.headerContextMenu = new DynamicTableHeaderContextMenuClass({ - targets: "#" + this.dynamicTableFixedHeaderDivId + " tr th", + targets: `#${this.dynamicTableFixedHeaderDivId} tr th`, actions: actions, menu: menuId, offsets: { @@ -522,11 +522,11 @@ window.qBittorrent.DynamicTable ??= (() => { const column = {}; column["name"] = name; column["title"] = name; - column["visible"] = LocalPreferences.get("column_" + name + "_visible_" + this.dynamicTableDivId, defaultVisible ? "1" : "0"); + column["visible"] = LocalPreferences.get(`column_${name}_visible_${this.dynamicTableDivId}`, (defaultVisible ? "1" : "0")); column["force_hide"] = false; column["caption"] = caption; column["style"] = style; - column["width"] = LocalPreferences.get("column_" + name + "_width_" + this.dynamicTableDivId, defaultWidth); + column["width"] = LocalPreferences.get(`column_${name}_width_${this.dynamicTableDivId}`, defaultWidth); column["dataProperties"] = [name]; column["getRowValue"] = function(row, pos) { if (pos === undefined) @@ -557,7 +557,7 @@ window.qBittorrent.DynamicTable ??= (() => { loadColumnsOrder: function() { const columnsOrder = []; - const val = LocalPreferences.get("columns_order_" + this.dynamicTableDivId); + const val = LocalPreferences.get(`columns_order_${this.dynamicTableDivId}`); if ((val === null) || (val === undefined)) return; val.split(",").forEach((v) => { @@ -581,7 +581,7 @@ window.qBittorrent.DynamicTable ??= (() => { val += ","; val += this.columns[i].name; } - LocalPreferences.set("columns_order_" + this.dynamicTableDivId, val); + LocalPreferences.set(`columns_order_${this.dynamicTableDivId}`, val); }, updateTableHeaders: function() { @@ -597,9 +597,9 @@ window.qBittorrent.DynamicTable ??= (() => { th._this = this; th.title = this.columns[i].caption; th.textContent = this.columns[i].caption; - th.setAttribute("style", "width: " + this.columns[i].width + "px;" + this.columns[i].style); + th.style.cssText = `width: ${this.columns[i].width}px; ${this.columns[i].style}`; th.columnName = this.columns[i].name; - th.classList.add("column_" + th.columnName); + th.classList.add(`column_${th.columnName}`); th.classList.toggle("invisible", ((this.columns[i].visible === "0") || this.columns[i].force_hide)); } }, @@ -618,10 +618,10 @@ window.qBittorrent.DynamicTable ??= (() => { const ths = this.hiddenTableHeader.getElements("th"); const fths = this.fixedTableHeader.getElements("th"); const trs = this.tableBody.getElements("tr"); - const style = "width: " + this.columns[pos].width + "px;" + this.columns[pos].style; + const style = `width: ${this.columns[pos].width}px; ${this.columns[pos].style}`; - ths[pos].setAttribute("style", style); - fths[pos].setAttribute("style", style); + ths[pos].style.cssText = style; + fths[pos].style.cssText = style; if (visible) { ths[pos].classList.remove("invisible"); @@ -640,7 +640,7 @@ window.qBittorrent.DynamicTable ??= (() => { }, getSortedColumn: function() { - return LocalPreferences.get("sorted_column_" + this.dynamicTableDivId); + return LocalPreferences.get(`sorted_column_${this.dynamicTableDivId}`); }, /** @@ -659,14 +659,14 @@ window.qBittorrent.DynamicTable ??= (() => { this.reverseSort = reverse ?? (this.reverseSort === "0" ? "1" : "0"); this.setSortedColumnIcon(column, null, (this.reverseSort === "1")); } - LocalPreferences.set("sorted_column_" + this.dynamicTableDivId, column); - LocalPreferences.set("reverse_sort_" + this.dynamicTableDivId, this.reverseSort); + LocalPreferences.set(`sorted_column_${this.dynamicTableDivId}`, column); + LocalPreferences.set(`reverse_sort_${this.dynamicTableDivId}`, this.reverseSort); this.updateTable(false); }, setSortedColumnIcon: function(newColumn, oldColumn, isReverse) { const getCol = (headerDivId, colName) => { - const colElem = $$("#" + headerDivId + " .column_" + colName); + const colElem = $$(`#${headerDivId} .column_${colName}`); if (colElem.length === 1) return colElem[0]; return null; @@ -1265,7 +1265,7 @@ window.qBittorrent.DynamicTable ??= (() => { const num_complete = this.getRowValue(row, 1); let value = num_seeds; if (num_complete !== -1) - value += " (" + num_complete + ")"; + value += ` (${num_complete})`; td.textContent = value; td.title = value; }; @@ -2125,9 +2125,9 @@ window.qBittorrent.DynamicTable ??= (() => { initColumns: function() { // Blocks saving header width (because window width isn't saved) - LocalPreferences.remove("column_" + "checked" + "_width_" + this.dynamicTableDivId); - LocalPreferences.remove("column_" + "original" + "_width_" + this.dynamicTableDivId); - LocalPreferences.remove("column_" + "renamed" + "_width_" + this.dynamicTableDivId); + LocalPreferences.remove(`column_checked_width_${this.dynamicTableDivId}`); + LocalPreferences.remove(`column_original_width_${this.dynamicTableDivId}`); + LocalPreferences.remove(`column_renamed_width_${this.dynamicTableDivId}`); this.newColumn("checked", "", "", 50, true); this.newColumn("original", "", "QBT_TR(Original)QBT_TR[CONTEXT=TrackerListWidget]", 270, true); this.newColumn("renamed", "", "QBT_TR(Renamed)QBT_TR[CONTEXT=TrackerListWidget]", 220, true); @@ -2226,7 +2226,7 @@ window.qBittorrent.DynamicTable ??= (() => { const checkbox = document.createElement("input"); checkbox.type = "checkbox"; - checkbox.id = "cbRename" + id; + checkbox.id = `cbRename${id}`; checkbox.setAttribute("data-id", id); checkbox.className = "RenamingCB"; checkbox.addEventListener("click", (e) => { @@ -2247,12 +2247,12 @@ window.qBittorrent.DynamicTable ??= (() => { // original this.columns["original"].updateTd = function(td, row) { const id = row.rowId; - const fileNameId = "filesTablefileName" + id; + const fileNameId = `filesTablefileName${id}`; const node = that.getNode(id); if (node.isFolder) { const value = this.getRowValue(row); - const dirImgId = "renameTableDirImg" + id; + const dirImgId = `renameTableDirImg${id}`; if ($(dirImgId)) { // just update file name $(fileNameId).textContent = value; @@ -2285,7 +2285,7 @@ window.qBittorrent.DynamicTable ??= (() => { // renamed this.columns["renamed"].updateTd = function(td, row) { const id = row.rowId; - const fileNameRenamedId = "filesTablefileRenamed" + id; + const fileNameRenamedId = `filesTablefileRenamed${id}`; const value = this.getRowValue(row); const span = document.createElement("span"); @@ -2549,13 +2549,13 @@ window.qBittorrent.DynamicTable ??= (() => { // name this.columns["name"].updateTd = function(td, row) { const id = row.rowId; - const fileNameId = "filesTablefileName" + id; + const fileNameId = `filesTablefileName${id}`; const node = that.getNode(id); if (node.isFolder) { const value = this.getRowValue(row); - const collapseIconId = "filesTableCollapseIcon" + id; - const dirImgId = "filesTableDirImg" + id; + const collapseIconId = `filesTableCollapseIcon${id}`; + const dirImgId = `filesTableDirImg${id}`; if ($(dirImgId)) { // just update file name $(fileNameId).textContent = value; @@ -2607,10 +2607,10 @@ window.qBittorrent.DynamicTable ??= (() => { const id = row.rowId; const value = this.getRowValue(row); - const progressBar = $("pbf_" + id); + const progressBar = $(`pbf_${id}`); if (progressBar === null) { td.append(new window.qBittorrent.ProgressBar.ProgressBar(value.toFloat(), { - id: "pbf_" + id, + id: `pbf_${id}`, width: 80 })); } @@ -2790,7 +2790,7 @@ window.qBittorrent.DynamicTable ??= (() => { this.columns["name"].updateTd = function(td, row) { const name = this.getRowValue(row, 0); const unreadCount = this.getRowValue(row, 1); - const value = name + " (" + unreadCount + ")"; + const value = `${name} (${unreadCount})`; td.textContent = value; td.title = value; }; @@ -2836,8 +2836,8 @@ window.qBittorrent.DynamicTable ??= (() => { row["data"] = {}; tds[0].style.overflow = "visible"; const indentation = row.full_data.indentation; - tds[0].style.paddingLeft = (indentation * 32 + 4) + "px"; - tds[1].style.paddingLeft = (indentation * 32 + 4) + "px"; + tds[0].style.paddingLeft = `${indentation * 32 + 4}px`; + tds[1].style.paddingLeft = `${indentation * 32 + 4}px`; }, updateIcons: function() { // state_icon @@ -3017,10 +3017,10 @@ window.qBittorrent.DynamicTable ??= (() => { this.newColumn("name", "", "", -1, true); this.columns["checked"].updateTd = function(td, row) { - if ($("cbRssDlRule" + row.rowId) === null) { + if ($(`cbRssDlRule${row.rowId}`) === null) { const checkbox = document.createElement("input"); checkbox.type = "checkbox"; - checkbox.id = "cbRssDlRule" + row.rowId; + checkbox.id = `cbRssDlRule${row.rowId}`; checkbox.checked = row.full_data.checked; checkbox.addEventListener("click", function(e) { @@ -3035,7 +3035,7 @@ window.qBittorrent.DynamicTable ??= (() => { td.append(checkbox); } else { - $("cbRssDlRule" + row.rowId).checked = row.full_data.checked; + $(`cbRssDlRule${row.rowId}`).checked = row.full_data.checked; } }; this.columns["checked"].staticWidth = 50; @@ -3115,10 +3115,10 @@ window.qBittorrent.DynamicTable ??= (() => { this.newColumn("name", "", "", -1, true); this.columns["checked"].updateTd = function(td, row) { - if ($("cbRssDlFeed" + row.rowId) === null) { + if ($(`cbRssDlFeed${row.rowId}`) === null) { const checkbox = document.createElement("input"); checkbox.type = "checkbox"; - checkbox.id = "cbRssDlFeed" + row.rowId; + checkbox.id = `cbRssDlFeed${row.rowId}`; checkbox.checked = row.full_data.checked; checkbox.addEventListener("click", function(e) { @@ -3132,7 +3132,7 @@ window.qBittorrent.DynamicTable ??= (() => { td.append(checkbox); } else { - $("cbRssDlFeed" + row.rowId).checked = row.full_data.checked; + $(`cbRssDlFeed${row.rowId}`).checked = row.full_data.checked; } }; this.columns["checked"].staticWidth = 50; diff --git a/src/webui/www/private/scripts/misc.js b/src/webui/www/private/scripts/misc.js index 493ea41e0709..9f7d94a41fb3 100644 --- a/src/webui/www/private/scripts/misc.js +++ b/src/webui/www/private/scripts/misc.js @@ -123,13 +123,13 @@ window.qBittorrent.Misc ??= (() => { let ret; if (i === 0) { - ret = value + " " + units[i]; + ret = `${value} ${units[i]}`; } else { const precision = friendlyUnitPrecision(i); const offset = Math.pow(10, precision); // Don't round up - ret = (Math.floor(offset * value) / offset).toFixed(precision) + " " + units[i]; + ret = `${(Math.floor(offset * value) / offset).toFixed(precision)} ${units[i]}`; } if (isSpeed) @@ -169,7 +169,7 @@ window.qBittorrent.Misc ??= (() => { percentage = 0; if (percentage > 100) percentage = 100; - return percentage.toFixed(1) + "%"; + return `${percentage.toFixed(1)}%`; }; const friendlyFloat = (value, precision) => { diff --git a/src/webui/www/private/scripts/mocha-init.js b/src/webui/www/private/scripts/mocha-init.js index c0f34c2c5b60..288ad98639fe 100644 --- a/src/webui/www/private/scripts/mocha-init.js +++ b/src/webui/www/private/scripts/mocha-init.js @@ -152,16 +152,16 @@ let exportTorrentFN = () => {}; const initializeWindows = () => { saveWindowSize = (windowId) => { const size = $(windowId).getSize(); - LocalPreferences.set("window_" + windowId + "_width", size.x); - LocalPreferences.set("window_" + windowId + "_height", size.y); + LocalPreferences.set(`window_${windowId}_width`, size.x); + LocalPreferences.set(`window_${windowId}_height`, size.y); }; loadWindowWidth = (windowId, defaultValue) => { - return LocalPreferences.get("window_" + windowId + "_width", defaultValue); + return LocalPreferences.get(`window_${windowId}_width`, defaultValue); }; loadWindowHeight = (windowId, defaultValue) => { - return LocalPreferences.get("window_" + windowId + "_height", defaultValue); + return LocalPreferences.get(`window_${windowId}_height`, defaultValue); }; const addClickEvent = (el, fn) => { @@ -340,8 +340,8 @@ const initializeWindows = () => { for (let i = 0; i < hashes.length; ++i) { const hash = hashes[i]; const row = torrentsTable.getRow(hash).full_data; - const origValues = row.ratio_limit + "|" + row.seeding_time_limit + "|" + row.inactive_seeding_time_limit + "|" - + row.max_ratio + "|" + row.max_seeding_time + "|" + row.max_inactive_seeding_time; + const origValues = `${row.ratio_limit}|${row.seeding_time_limit}|${row.inactive_seeding_time_limit}|${row.max_ratio}` + + `|${row.max_seeding_time}|${row.max_inactive_seeding_time}`; // initialize value if (shareRatio === null) diff --git a/src/webui/www/private/scripts/pathAutofill.js b/src/webui/www/private/scripts/pathAutofill.js index d9bcd634318b..2e260f145f8a 100644 --- a/src/webui/www/private/scripts/pathAutofill.js +++ b/src/webui/www/private/scripts/pathAutofill.js @@ -42,7 +42,7 @@ window.qBittorrent.pathAutofill ??= (() => { const showInputSuggestions = (inputElement, names) => { const datalist = document.createElement("datalist"); - datalist.id = inputElement.id + "Suggestions"; + datalist.id = `${inputElement.id}Suggestions`; for (const name of names) { const option = document.createElement("option"); option.value = name; diff --git a/src/webui/www/private/scripts/piecesbar.js b/src/webui/www/private/scripts/piecesbar.js index eb2b588cc161..49d159cb143f 100644 --- a/src/webui/www/private/scripts/piecesbar.js +++ b/src/webui/www/private/scripts/piecesbar.js @@ -48,7 +48,7 @@ window.qBittorrent.PiecesBar ??= (() => { const PiecesBar = new Class({ initialize: (pieces, parameters) => { const vals = { - id: "piecesbar_" + (piecesBarUniqueId++), + id: `piecesbar_${piecesBarUniqueId++}`, width: 0, height: 0, downloadingColor: "hsl(110deg 94% 27%)", // @TODO palette vars not supported for this value, apply average diff --git a/src/webui/www/private/scripts/progressbar.js b/src/webui/www/private/scripts/progressbar.js index e1f9eced2cd9..5ec45904f703 100644 --- a/src/webui/www/private/scripts/progressbar.js +++ b/src/webui/www/private/scripts/progressbar.js @@ -40,7 +40,7 @@ window.qBittorrent.ProgressBar ??= (() => { const ProgressBar = new Class({ initialize: (value, parameters) => { const vals = { - id: "progressbar_" + (progressBars++), + id: `progressbar_${progressBars++}`, value: [value, 0].pick(), width: 0, height: 0, diff --git a/src/webui/www/private/scripts/prop-files.js b/src/webui/www/private/scripts/prop-files.js index c5b7d07206e7..88c97fec41eb 100644 --- a/src/webui/www/private/scripts/prop-files.js +++ b/src/webui/www/private/scripts/prop-files.js @@ -127,13 +127,13 @@ window.qBittorrent.PropFiles ??= (() => { }; const isDownloadCheckboxExists = (id) => { - return $("cbPrio" + id) !== null; + return $(`cbPrio${id}`) !== null; }; const createDownloadCheckbox = (id, fileId, checked) => { const checkbox = document.createElement("input"); checkbox.type = "checkbox"; - checkbox.id = "cbPrio" + id; + checkbox.id = `cbPrio${id}`; checkbox.setAttribute("data-id", id); checkbox.setAttribute("data-file-id", fileId); checkbox.className = "DownloadedCB"; @@ -144,7 +144,7 @@ window.qBittorrent.PropFiles ??= (() => { }; const updateDownloadCheckbox = (id, checked) => { - const checkbox = $("cbPrio" + id); + const checkbox = $(`cbPrio${id}`); updateCheckbox(checkbox, checked); }; @@ -163,7 +163,7 @@ window.qBittorrent.PropFiles ??= (() => { }; const isPriorityComboExists = (id) => { - return $("comboPrio" + id) !== null; + return $(`comboPrio${id}`) !== null; }; const createPriorityCombo = (id, fileId, selectedPriority) => { @@ -176,7 +176,7 @@ window.qBittorrent.PropFiles ??= (() => { }; const select = document.createElement("select"); - select.id = "comboPrio" + id; + select.id = `comboPrio${id}`; select.setAttribute("data-id", id); select.setAttribute("data-file-id", fileId); select.classList.add("combo_priority"); @@ -196,7 +196,7 @@ window.qBittorrent.PropFiles ??= (() => { }; const updatePriorityCombo = (id, selectedPriority) => { - const combobox = $("comboPrio" + id); + const combobox = $(`comboPrio${id}`); if (Number(combobox.value) !== selectedPriority) selectComboboxPriority(combobox, selectedPriority); }; @@ -324,10 +324,10 @@ window.qBittorrent.PropFiles ??= (() => { }); const ignore = (priority === FilePriority.Ignored); - ids.forEach((_id) => { - torrentFilesTable.setIgnored(_id, ignore); + ids.forEach((id) => { + torrentFilesTable.setIgnored(id, ignore); - const combobox = $("comboPrio" + _id); + const combobox = $(`comboPrio${id}`); if (combobox !== null) selectComboboxPriority(combobox, priority); }); @@ -522,7 +522,7 @@ window.qBittorrent.PropFiles ??= (() => { const rowIds = []; const fileIds = []; selectedRows.forEach((rowId) => { - const elem = $("comboPrio" + rowId); + const elem = $(`comboPrio${rowId}`); rowIds.push(rowId); fileIds.push(elem.getAttribute("data-file-id")); }); @@ -558,8 +558,7 @@ window.qBittorrent.PropFiles ??= (() => { icon: "images/qbittorrent-tray.svg", title: "QBT_TR(Renaming)QBT_TR[CONTEXT=TorrentContentTreeView]", loadMethod: "iframe", - contentURL: "rename_file.html?hash=" + hash + "&isFolder=" + node.isFolder - + "&path=" + encodeURIComponent(path), + contentURL: `rename_file.html?hash=${hash}&isFolder=${node.isFolder}&path=${encodeURIComponent(path)}`, scrollbars: false, resizable: true, maximizable: false, @@ -673,7 +672,7 @@ window.qBittorrent.PropFiles ??= (() => { * Show/hide a node's row */ const _hideNode = (node, shouldHide) => { - const span = $("filesTablefileName" + node.rowId); + const span = $(`filesTablefileName${node.rowId}`); // span won't exist if row has been filtered out if (span === null) return; @@ -685,7 +684,7 @@ window.qBittorrent.PropFiles ??= (() => { * Update a node's collapsed state and icon */ const _updateNodeState = (node, isCollapsed) => { - const span = $("filesTablefileName" + node.rowId); + const span = $(`filesTablefileName${node.rowId}`); // span won't exist if row has been filtered out if (span === null) return; @@ -700,7 +699,7 @@ window.qBittorrent.PropFiles ??= (() => { }; const _isCollapsed = (node) => { - const span = $("filesTablefileName" + node.rowId); + const span = $(`filesTablefileName${node.rowId}`); if (span === null) return true; diff --git a/src/webui/www/private/scripts/prop-peers.js b/src/webui/www/private/scripts/prop-peers.js index a3fd66f9064f..e7fa59ac25b9 100644 --- a/src/webui/www/private/scripts/prop-peers.js +++ b/src/webui/www/private/scripts/prop-peers.js @@ -137,7 +137,7 @@ window.qBittorrent.PropPeers ??= (() => { icon: "images/qbittorrent-tray.svg", title: "QBT_TR(Add Peers)QBT_TR[CONTEXT=PeersAdditionDialog]", loadMethod: "iframe", - contentURL: "addpeers.html?hash=" + hash, + contentURL: `addpeers.html?hash=${hash}`, scrollbars: false, resizable: false, maximizable: false, diff --git a/src/webui/www/private/scripts/prop-trackers.js b/src/webui/www/private/scripts/prop-trackers.js index fd5b7ec4b1f1..796b090c12ac 100644 --- a/src/webui/www/private/scripts/prop-trackers.js +++ b/src/webui/www/private/scripts/prop-trackers.js @@ -177,7 +177,7 @@ window.qBittorrent.PropTrackers ??= (() => { icon: "images/qbittorrent-tray.svg", title: "QBT_TR(Add trackers)QBT_TR[CONTEXT=TrackersAdditionDialog]", loadMethod: "iframe", - contentURL: "addtrackers.html?hash=" + current_hash, + contentURL: `addtrackers.html?hash=${current_hash}`, scrollbars: true, resizable: false, maximizable: false, @@ -202,7 +202,7 @@ window.qBittorrent.PropTrackers ??= (() => { icon: "images/qbittorrent-tray.svg", title: "QBT_TR(Tracker editing)QBT_TR[CONTEXT=TrackerListWidget]", loadMethod: "iframe", - contentURL: "edittracker.html?hash=" + current_hash + "&url=" + trackerUrl, + contentURL: `edittracker.html?hash=${current_hash}&url=${trackerUrl}`, scrollbars: true, resizable: false, maximizable: false, diff --git a/src/webui/www/private/scripts/prop-webseeds.js b/src/webui/www/private/scripts/prop-webseeds.js index ef3773620ea0..af674d6b41e9 100644 --- a/src/webui/www/private/scripts/prop-webseeds.js +++ b/src/webui/www/private/scripts/prop-webseeds.js @@ -150,7 +150,7 @@ window.qBittorrent.PropWebseeds ??= (() => { id: "webseedsPage", title: "QBT_TR(Add web seeds)QBT_TR[CONTEXT=HttpServer]", loadMethod: "iframe", - contentURL: "addwebseeds.html?hash=" + current_hash, + contentURL: `addwebseeds.html?hash=${current_hash}`, scrollbars: true, resizable: false, maximizable: false, @@ -179,7 +179,7 @@ window.qBittorrent.PropWebseeds ??= (() => { id: "webseedsPage", title: "QBT_TR(Web seed editing)QBT_TR[CONTEXT=PropertiesWidget]", loadMethod: "iframe", - contentURL: "editwebseed.html?hash=" + current_hash + "&url=" + encodeURIComponent(webseedUrl), + contentURL: `editwebseed.html?hash=${current_hash}&url=${encodeURIComponent(webseedUrl)}`, scrollbars: true, resizable: false, maximizable: false, diff --git a/src/webui/www/private/scripts/rename-files.js b/src/webui/www/private/scripts/rename-files.js index e6d6de6e39f8..f84a86acfb77 100644 --- a/src/webui/www/private/scripts/rename-files.js +++ b/src/webui/www/private/scripts/rename-files.js @@ -159,7 +159,7 @@ window.qBittorrent.MultiRename ??= (() => { // Get file extension and reappend the "." (only when the file has an extension) let fileExtension = window.qBittorrent.Filesystem.fileExtension(row.original); if (fileExtension) - fileExtension = "." + fileExtension; + fileExtension = `.${fileExtension}`; const fileNameWithoutExt = row.original.slice(0, row.original.lastIndexOf(fileExtension)); diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html index 816e6f2ac21c..df873927d029 100644 --- a/src/webui/www/private/views/preferences.html +++ b/src/webui/www/private/views/preferences.html @@ -1824,42 +1824,42 @@ const addWatchFolder = (folder = "", sel = "default_folder", other = "") => { const pos = $("watched_folders_tab").getChildren("tbody")[0].getChildren("tr").length; - const myinput = ""; + const myinput = ``; const disableInput = (sel !== "other"); - const mycb = "
" - + "" - + "" - + "Add" - + "
"; + const mycb = `
` + + `` + + `` + + `Add` + + `
`; watchedFoldersTable.push([myinput, mycb]); - $("cb_watch_" + pos).value = sel; + $(`cb_watch_${pos}`).value = sel; if (disableInput) { - const elt = $("cb_watch_" + pos); + const elt = $(`cb_watch_${pos}`); other = elt.options[elt.selectedIndex].textContent; } - $("cb_watch_txt_" + pos).value = other; + $(`cb_watch_txt_${pos}`).value = other; // hide previous img if (pos > 0) - $("addFolderImg_" + (pos - 1)).style.display = "none"; + $(`addFolderImg_${pos - 1}`).style.display = "none"; }; const getWatchedFolders = () => { const nb_folders = $("watched_folders_tab").getChildren("tbody")[0].getChildren("tr").length; const folders = new Hash(); for (let i = 0; i < nb_folders; ++i) { - const fpath = $("text_watch_" + i).value.trim(); + const fpath = $(`text_watch_${i}`).value.trim(); if (fpath.length > 0) { - const sel = $("cb_watch_" + i).value.trim(); + const sel = $(`cb_watch_${i}`).value.trim(); let other; if (sel === "other") - other = $("cb_watch_txt_" + i).value.trim(); + other = $(`cb_watch_txt_${i}`).value.trim(); else other = (sel === "watch_folder") ? 0 : 1; @@ -2096,7 +2096,7 @@ const time_padding = (val) => { let ret = val.toString(); if (ret.length === 1) - ret = "0" + ret; + ret = `0${ret}`; return ret; }; diff --git a/src/webui/www/private/views/rss.html b/src/webui/www/private/views/rss.html index ff7845b90e5f..0e69af988be5 100644 --- a/src/webui/www/private/views/rss.html +++ b/src/webui/www/private/views/rss.html @@ -343,7 +343,7 @@ icon: "images/qbittorrent-tray.svg", title: "QBT_TR(Please type a RSS feed URL)QBT_TR[CONTEXT=RSSWidget]", loadMethod: "iframe", - contentURL: "newfeed.html?path=" + encodeURIComponent(path), + contentURL: `newfeed.html?path=${encodeURIComponent(path)}`, scrollbars: false, resizable: false, maximizable: false, @@ -371,7 +371,7 @@ icon: "images/qbittorrent-tray.svg", title: "QBT_TR(Please choose a folder name)QBT_TR[CONTEXT=RSSWidget]", loadMethod: "iframe", - contentURL: "newfolder.html?path=" + encodeURIComponent(path), + contentURL: `newfolder.html?path=${encodeURIComponent(path)}`, scrollbars: false, resizable: false, maximizable: false, @@ -449,7 +449,7 @@ // Place in iframe with sandbox attribute to prevent js execution const torrentDescription = document.createRange().createContextualFragment(''); $("rssDetailsView").append(torrentDescription); - document.getElementById("rssDescription").srcdoc = '' + article.description + ""; + document.getElementById("rssDescription").srcdoc = `${article.description}`; } }; @@ -475,7 +475,7 @@ if (!Object.hasOwn(current, child)) continue; - const currentFullName = fullName ? (fullName + "\\" + child) : child; + const currentFullName = fullName ? `${fullName}\\${child}` : child; if (current[child].uid !== undefined) { current[child].name = child; current[child].isFolder = false; @@ -733,7 +733,7 @@ icon: "images/qbittorrent-tray.svg", title: "QBT_TR(Please choose a new name for this RSS feed)QBT_TR[CONTEXT=RSSWidget]", loadMethod: "iframe", - contentURL: "rename_feed.html?oldPath=" + encodeURIComponent(oldPath), + contentURL: `rename_feed.html?oldPath=${encodeURIComponent(oldPath)}`, scrollbars: false, resizable: false, maximizable: false, @@ -769,7 +769,7 @@ icon: "images/qbittorrent-tray.svg", title: "QBT_TR(Deletion confirmation)QBT_TR[CONTEXT=RSSWidget]", loadMethod: "iframe", - contentURL: "confirmfeeddeletion.html?paths=" + encodeURIComponent(encodedPaths.join("|")), + contentURL: `confirmfeeddeletion.html?paths=${encodeURIComponent(encodedPaths.join("|"))}`, scrollbars: false, resizable: false, maximizable: false, diff --git a/src/webui/www/private/views/rssDownloader.html b/src/webui/www/private/views/rssDownloader.html index 759e64a4cebc..4a0b8d6ce5d1 100644 --- a/src/webui/www/private/views/rssDownloader.html +++ b/src/webui/www/private/views/rssDownloader.html @@ -375,17 +375,17 @@ // recalculate height const warningHeight = $("rssDownloaderDisabled").getBoundingClientRect().height; - $("leftRssDownloaderColumn").style.height = "calc(100% - " + warningHeight + "px)"; - $("centerRssDownloaderColumn").style.height = "calc(100% - " + warningHeight + "px)"; - $("rightRssDownloaderColumn").style.height = "calc(100% - " + warningHeight + "px)"; + $("leftRssDownloaderColumn").style.height = `calc(100% - ${warningHeight}px)`; + $("centerRssDownloaderColumn").style.height = `calc(100% - ${warningHeight}px)`; + $("rightRssDownloaderColumn").style.height = `calc(100% - ${warningHeight}px)`; - $("rulesTable").style.height = "calc(100% - " + $("rulesTableDesc").getBoundingClientRect().height + "px)"; - $("rssDownloaderArticlesTable").style.height = "calc(100% - " + $("articleTableDesc").getBoundingClientRect().height + "px)"; + $("rulesTable").style.height = `calc(100% - ${$("rulesTableDesc").getBoundingClientRect().height}px)`; + $("rssDownloaderArticlesTable").style.height = `calc(100% - ${$("articleTableDesc").getBoundingClientRect().height}px)`; const centerRowNotTableHeight = $("saveButton").getBoundingClientRect().height + $("ruleSettings").getBoundingClientRect().height + 15; - $("rssDownloaderFeeds").style.height = "calc(100% - " + centerRowNotTableHeight + "px)"; + $("rssDownloaderFeeds").style.height = `calc(100% - ${centerRowNotTableHeight}px)`; // firefox calculates the height of the table inside fieldset differently and thus doesn't need the offset if (navigator.userAgent.toLowerCase().includes("firefox")) { @@ -393,7 +393,7 @@ } else { const outsideTableHeight = ($("rssDownloaderFeedsTable").getBoundingClientRect().top - $("rssDownloaderFeeds").getBoundingClientRect().top) - 10; - $("rssDownloaderFeedsTable").style.height = "calc(100% - " + outsideTableHeight + "px)"; + $("rssDownloaderFeedsTable").style.height = `calc(100% - ${outsideTableHeight}px)`; } const rssDownloaderRuleContextMenu = new window.qBittorrent.ContextMenu.RssDownloaderRuleContextMenu({ @@ -547,7 +547,7 @@ icon: "images/qbittorrent-tray.svg", title: "QBT_TR(Rule renaming)QBT_TR[CONTEXT=AutomatedRssDownloader]", loadMethod: "iframe", - contentURL: "rename_rule.html?rule=" + encodeURIComponent(rule), + contentURL: `rename_rule.html?rule=${encodeURIComponent(rule)}`, scrollbars: false, resizable: false, maximizable: false, @@ -570,7 +570,7 @@ icon: "images/qbittorrent-tray.svg", title: "QBT_TR(Rule deletion confirmation)QBT_TR[CONTEXT=AutomatedRssDownloader]", loadMethod: "iframe", - contentURL: "confirmruledeletion.html?rules=" + encodeURIComponent(encodedRules.join("|")), + contentURL: `confirmruledeletion.html?rules=${encodeURIComponent(encodedRules.join("|"))}`, scrollbars: false, resizable: false, maximizable: false, @@ -586,7 +586,7 @@ icon: "images/qbittorrent-tray.svg", title: "QBT_TR(New rule name)QBT_TR[CONTEXT=AutomatedRssDownloader]", loadMethod: "iframe", - contentURL: "confirmruleclear.html?rules=" + encodeURIComponent(encodedRules.join("|")), + contentURL: `confirmruleclear.html?rules=${encodeURIComponent(encodedRules.join("|"))}`, scrollbars: false, resizable: false, maximizable: false, @@ -818,8 +818,8 @@ const secondPart = "QBT_TR(An expression with an empty %1 clause (e.g. %2))QBT_TR[CONTEXT=AutomatedRssDownloader]" .replace("%1", "|").replace("%2", "expr|"); - $("mustContainText").title = mainPart + secondPart + "QBT_TR( will match all articles.)QBT_TR[CONTEXT=AutomatedRssDownloader]"; - $("mustNotContainText").title = mainPart + secondPart + "QBT_TR( will exclude all articles.)QBT_TR[CONTEXT=AutomatedRssDownloader]"; + $("mustContainText").title = `${mainPart}${secondPart}QBT_TR( will match all articles.)QBT_TR[CONTEXT=AutomatedRssDownloader]`; + $("mustNotContainText").title = `${mainPart}${secondPart}QBT_TR( will exclude all articles.)QBT_TR[CONTEXT=AutomatedRssDownloader]`; let episodeFilterTitle = "QBT_TR(Matches articles based on episode filter.)QBT_TR[CONTEXT=AutomatedRssDownloader]\n\n" + "QBT_TR(Example: )QBT_TR[CONTEXT=AutomatedRssDownloader]"