diff --git a/src/webui/www/private/scripts/dynamicTable.js b/src/webui/www/private/scripts/dynamicTable.js index 3b6cc19de..c23606140 100644 --- a/src/webui/www/private/scripts/dynamicTable.js +++ b/src/webui/www/private/scripts/dynamicTable.js @@ -67,11 +67,8 @@ window.qBittorrent.DynamicTable ??= (() => { let DynamicTableHeaderContextMenuClass = null; let progressColumnWidth = -1; - const DynamicTable = new Class({ - - initialize: () => {}, - - setup: function(dynamicTableDivId, dynamicTableFixedHeaderDivId, contextMenu, useVirtualList = false) { + class DynamicTable { + setup(dynamicTableDivId, dynamicTableFixedHeaderDivId, contextMenu, useVirtualList = false) { this.dynamicTableDivId = dynamicTableDivId; this.dynamicTableFixedHeaderDivId = dynamicTableFixedHeaderDivId; this.dynamicTableDiv = document.getElementById(dynamicTableDivId); @@ -96,9 +93,9 @@ window.qBittorrent.DynamicTable ??= (() => { this.setupHeaderMenu(); this.setupAltRow(); this.setupVirtualList(); - }, + } - setupVirtualList: function() { + setupVirtualList() { if (!this.useVirtualList) return; this.table.style.position = "relative"; @@ -112,9 +109,9 @@ window.qBittorrent.DynamicTable ??= (() => { this.rerender(); }); new ResizeObserver(resizeCallback).observe(this.dynamicTableDiv); - }, + } - setupCommonEvents: function() { + setupCommonEvents() { const tableFixedHeaderDiv = document.getElementById(this.dynamicTableFixedHeaderDivId); const tableElement = tableFixedHeaderDiv.querySelector("table"); @@ -194,9 +191,9 @@ window.qBittorrent.DynamicTable ??= (() => { } } }); - }, + } - setupHeaderEvents: function() { + setupHeaderEvents() { this.currentHeaderAction = ""; this.canResize = false; @@ -372,9 +369,9 @@ window.qBittorrent.DynamicTable ??= (() => { onCancel: onCancel }); } - }, + } - setupDynamicTableHeaderContextMenuClass: function() { + setupDynamicTableHeaderContextMenuClass() { DynamicTableHeaderContextMenuClass ??= class extends window.qBittorrent.ContextMenu.ContextMenu { updateMenuItems() { for (let i = 0; i < this.dynamicTable.columns.length; ++i) { @@ -387,16 +384,16 @@ window.qBittorrent.DynamicTable ??= (() => { } } }; - }, + } - showColumn: function(columnName, show) { + showColumn(columnName, show) { this.columns[columnName].visible = show ? "1" : "0"; LocalPreferences.set(`column_${columnName}_visible_${this.dynamicTableDivId}`, show ? "1" : "0"); this.updateColumn(columnName); this.columns[columnName].onVisibilityChange?.(columnName); - }, + } - _calculateColumnBodyWidth: function(column) { + _calculateColumnBodyWidth(column) { const columnIndex = this.getColumnPos(column.name); const bodyColumn = document.getElementById(this.dynamicTableDivId).querySelectorAll("tr>th")[columnIndex]; const canvas = document.createElement("canvas"); @@ -418,9 +415,9 @@ window.qBittorrent.DynamicTable ??= (() => { // slight buffer to prevent clipping return longestTd.width + 10; - }, + } - _setColumnWidth: function(columnName, width) { + _setColumnWidth(columnName, width) { const column = this.columns[columnName]; column.width = width; @@ -433,9 +430,9 @@ window.qBittorrent.DynamicTable ??= (() => { this.rerender(); column.onResize?.(column.name); - }, + } - autoResizeColumn: function(columnName) { + autoResizeColumn(columnName) { const column = this.columns[columnName]; let width = column.staticWidth ?? 0; @@ -458,13 +455,13 @@ window.qBittorrent.DynamicTable ??= (() => { this._setColumnWidth(column.name, width); this.saveColumnWidth(column.name); - }, + } - saveColumnWidth: function(columnName) { + saveColumnWidth(columnName) { LocalPreferences.set(`column_${columnName}_width_${this.dynamicTableDivId}`, this.columns[columnName].width); - }, + } - setupHeaderMenu: function() { + setupHeaderMenu() { this.setupDynamicTableHeaderContextMenuClass(); const menuId = `${this.dynamicTableDivId}_headerMenu`; @@ -551,11 +548,11 @@ window.qBittorrent.DynamicTable ??= (() => { }); this.headerContextMenu.dynamicTable = this; - }, + } - initColumns: () => {}, + initColumns() {} - newColumn: function(name, style, caption, defaultWidth, defaultVisible) { + newColumn(name, style, caption, defaultWidth, defaultVisible) { const column = {}; column["name"] = name; column["title"] = name; @@ -594,9 +591,9 @@ window.qBittorrent.DynamicTable ??= (() => { this.hiddenTableHeader.append(document.createElement("th")); this.fixedTableHeader.append(document.createElement("th")); - }, + } - loadColumnsOrder: function() { + loadColumnsOrder() { const columnsOrder = []; const val = LocalPreferences.get(`columns_order_${this.dynamicTableDivId}`); if ((val === null) || (val === undefined)) @@ -613,9 +610,9 @@ window.qBittorrent.DynamicTable ??= (() => { for (let i = 0; i < this.columns.length; ++i) this.columns[i] = this.columns[columnsOrder[i]]; - }, + } - saveColumnsOrder: function() { + saveColumnsOrder() { let val = ""; for (let i = 0; i < this.columns.length; ++i) { if (i > 0) @@ -623,15 +620,15 @@ window.qBittorrent.DynamicTable ??= (() => { val += this.columns[i].name; } LocalPreferences.set(`columns_order_${this.dynamicTableDivId}`, val); - }, + } - updateTableHeaders: function() { + updateTableHeaders() { this.updateHeader(this.hiddenTableHeader); this.updateHeader(this.fixedTableHeader); this.setSortedColumnIcon(this.sortedColumn, null, (this.reverseSort === "1")); - }, + } - updateHeader: function(header) { + updateHeader(header) { const ths = this.getRowCells(header); for (let i = 0; i < ths.length; ++i) { const th = ths[i]; @@ -644,17 +641,17 @@ window.qBittorrent.DynamicTable ??= (() => { th.classList.toggle("invisible", ((this.columns[i].visible === "0") || this.columns[i].force_hide)); } } - }, + } - getColumnPos: function(columnName) { + getColumnPos(columnName) { for (let i = 0; i < this.columns.length; ++i) { if (this.columns[i].name === columnName) return i; } return -1; - }, + } - updateColumn: function(columnName, updateCellData = false) { + updateColumn(columnName, updateCellData = false) { const column = this.columns[columnName]; const pos = this.getColumnPos(columnName); const ths = this.getRowCells(this.hiddenTableHeader); @@ -669,17 +666,17 @@ window.qBittorrent.DynamicTable ??= (() => { if (updateCellData) column.updateTd(td, this.rows.get(tr.rowId)); } - }, + } - getSortedColumn: function() { + getSortedColumn() { return LocalPreferences.get(`sorted_column_${this.dynamicTableDivId}`); - }, + } /** * @param {string} column name to sort by * @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) { + setSortedColumn(column, reverse = null) { if (column !== this.sortedColumn) { const oldColumn = this.sortedColumn; this.sortedColumn = column; @@ -694,9 +691,9 @@ window.qBittorrent.DynamicTable ??= (() => { LocalPreferences.set(`sorted_column_${this.dynamicTableDivId}`, column); LocalPreferences.set(`reverse_sort_${this.dynamicTableDivId}`, this.reverseSort); this.updateTable(false); - }, + } - setSortedColumnIcon: function(newColumn, oldColumn, isReverse) { + setSortedColumnIcon(newColumn, oldColumn, isReverse) { const getCol = (headerDivId, colName) => { const colElem = document.querySelectorAll(`#${headerDivId} .column_${colName}`); if (colElem.length === 1) @@ -714,48 +711,48 @@ window.qBittorrent.DynamicTable ??= (() => { oldColElem.classList.remove("sorted"); oldColElem.classList.remove("reverse"); } - }, + } - getSelectedRowId: function() { + getSelectedRowId() { if (this.selectedRows.length > 0) return this.selectedRows[0]; return ""; - }, + } - isRowSelected: function(rowId) { + isRowSelected(rowId) { return this.selectedRows.contains(rowId); - }, + } - setupAltRow: function() { + setupAltRow() { const useAltRowColors = (LocalPreferences.get("use_alt_row_colors", "true") === "true"); if (useAltRowColors) document.getElementById(this.dynamicTableDivId).classList.add("altRowColors"); - }, + } - selectAll: function() { + selectAll() { this.deselectAll(); for (const row of this.getFilteredAndSortedRows()) this.selectedRows.push(row.rowId); this.setRowClass(); - }, + } - deselectAll: function() { + deselectAll() { this.selectedRows.empty(); - }, + } - selectRow: function(rowId) { + selectRow(rowId) { this.selectedRows.push(rowId); this.setRowClass(); this.onSelectedRowChanged(); - }, + } - deselectRow: function(rowId) { + deselectRow(rowId) { this.selectedRows.erase(rowId); this.setRowClass(); this.onSelectedRowChanged(); - }, + } - selectRows: function(rowId1, rowId2) { + selectRows(rowId1, rowId2) { this.deselectAll(); if (rowId1 === rowId2) { this.selectRow(rowId1); @@ -774,22 +771,22 @@ window.qBittorrent.DynamicTable ??= (() => { } this.setRowClass(); this.onSelectedRowChanged(); - }, + } - reselectRows: function(rowIds) { + reselectRows(rowIds) { this.deselectAll(); this.selectedRows = rowIds.slice(); this.setRowClass(); - }, + } - setRowClass: function() { + setRowClass() { for (const tr of this.getTrs()) tr.classList.toggle("selected", this.isRowSelected(tr.rowId)); - }, + } - onSelectedRowChanged: () => {}, + onSelectedRowChanged() {} - updateRowData: function(data) { + updateRowData(data) { // ensure rowId is a string const rowId = `${data["rowId"]}`; let row; @@ -811,21 +808,21 @@ window.qBittorrent.DynamicTable ??= (() => { continue; row["full_data"][x] = data[x]; } - }, + } - getTrs: function() { + getTrs() { return this.tableBody.querySelectorAll("tr"); - }, + } - getRowCells: (tr) => { + getRowCells(tr) { return tr.querySelectorAll("td, th"); - }, + } - getRow: function(rowId) { + getRow(rowId) { return this.rows.get(rowId); - }, + } - getFilteredAndSortedRows: function() { + getFilteredAndSortedRows() { const filteredRows = []; for (const row of this.getRowValues()) { @@ -842,13 +839,13 @@ window.qBittorrent.DynamicTable ??= (() => { return -res; }); return filteredRows; - }, + } - getTrByRowId: function(rowId) { + getTrByRowId(rowId) { return Array.prototype.find.call(this.getTrs(), (tr => tr.rowId === rowId)); - }, + } - updateTable: function(fullUpdate = false) { + updateTable(fullUpdate = false) { const rows = this.getFilteredAndSortedRows(); for (let i = 0; i < this.selectedRows.length; ++i) { @@ -905,9 +902,9 @@ window.qBittorrent.DynamicTable ??= (() => { while ((rowPos < trs.length) && (trs.length > 0)) trs.pop().destroy(); } - }, + } - rerender: function(rows = this.getFilteredAndSortedRows()) { + rerender(rows = this.getFilteredAndSortedRows()) { // set the scrollable height this.table.style.height = `${rows.length * this.rowHeight}px`; @@ -966,9 +963,9 @@ window.qBittorrent.DynamicTable ??= (() => { else updateRowHeight(); } - }, + } - createRowElement: function(row, top = -1) { + createRowElement(row, top = -1) { const tr = document.createElement("tr"); // set tabindex so element receives keydown events // more info: https://developer.mozilla.org/en-US/docs/Web/API/Element/keydown_event @@ -986,9 +983,9 @@ window.qBittorrent.DynamicTable ??= (() => { // update context menu this.contextMenu?.addTarget(tr); return tr; - }, + } - updateRowElement: function(tr, rowId, top) { + updateRowElement(tr, rowId, top) { tr.dataset.rowId = rowId; tr.rowId = rowId; @@ -998,9 +995,9 @@ window.qBittorrent.DynamicTable ??= (() => { tr.style.position = "absolute"; tr.style.top = `${top}px`; } - }, + } - updateRow: function(tr, fullUpdate) { + updateRow(tr, fullUpdate) { const row = this.rows.get(tr.rowId); const data = row[fullUpdate ? "full_data" : "data"]; @@ -1015,9 +1012,9 @@ window.qBittorrent.DynamicTable ??= (() => { this.columns[i].updateTd(tds[i], row); } row["data"] = {}; - }, + } - removeRow: function(rowId) { + removeRow(rowId) { this.selectedRows.erase(rowId); this.rows.delete(rowId); if (this.useVirtualList) { @@ -1027,9 +1024,9 @@ window.qBittorrent.DynamicTable ??= (() => { const tr = this.getTrByRowId(rowId); tr?.destroy(); } - }, + } - clear: function() { + clear() { this.deselectAll(); this.rows.clear(); if (this.useVirtualList) { @@ -1039,29 +1036,29 @@ window.qBittorrent.DynamicTable ??= (() => { for (const tr of this.getTrs()) tr.destroy(); } - }, + } - selectedRowsIds: function() { + selectedRowsIds() { return this.selectedRows.slice(); - }, + } - getRowIds: function() { + getRowIds() { return this.rows.keys(); - }, + } - getRowValues: function() { + getRowValues() { return this.rows.values(); - }, + } - getRowItems: function() { + getRowItems() { return this.rows.entries(); - }, + } - getRowSize: function() { + getRowSize() { return this.rows.size; - }, + } - selectNextRow: function() { + selectNextRow() { const visibleRows = Array.prototype.filter.call(this.getTrs(), (tr => !tr.classList.contains("invisible") && (tr.style.display !== "none"))); const selectedRowId = this.getSelectedRowId(); @@ -1081,9 +1078,9 @@ window.qBittorrent.DynamicTable ??= (() => { const newRow = visibleRows[selectedIndex + 1]; this.selectRow(newRow.getAttribute("data-row-id")); } - }, + } - selectPreviousRow: function() { + selectPreviousRow() { const visibleRows = Array.prototype.filter.call(this.getTrs(), (tr => !tr.classList.contains("invisible") && (tr.style.display !== "none"))); const selectedRowId = this.getSelectedRowId(); @@ -1103,19 +1100,16 @@ window.qBittorrent.DynamicTable ??= (() => { const newRow = visibleRows[selectedIndex - 1]; this.selectRow(newRow.getAttribute("data-row-id")); } - }, - }); - - const TorrentsTable = new Class({ - Extends: DynamicTable, - - setupVirtualList: function() { - this.parent(); + } + } + class TorrentsTable extends DynamicTable { + setupVirtualList() { + super.setupVirtualList(); this.rowHeight = 22; - }, + } - initColumns: function() { + initColumns() { this.newColumn("priority", "", "#", 30, true); this.newColumn("state_icon", "", "QBT_TR(Status Icon)QBT_TR[CONTEXT=TransferListModel]", 30, false); this.newColumn("name", "", "QBT_TR(Name)QBT_TR[CONTEXT=TransferListModel]", 200, true); @@ -1162,9 +1156,9 @@ window.qBittorrent.DynamicTable ??= (() => { this.columns["time_active"].dataProperties.push("seeding_time"); this.initColumnsFunctions(); - }, + } - initColumnsFunctions: function() { + initColumnsFunctions() { const getStateIconClasses = (state) => { let stateClass = "stateUnknown"; // normalize states @@ -1583,9 +1577,9 @@ window.qBittorrent.DynamicTable ??= (() => { td.textContent = string; td.title = string; }; - }, + } - applyFilter: (row, filterName, category, tag, tracker, filterTerms) => { + applyFilter(row, filterName, category, tag, tracker, filterTerms) { const state = row["full_data"].state; let inactive = false; @@ -1733,9 +1727,9 @@ window.qBittorrent.DynamicTable ??= (() => { } return true; - }, + } - getFilteredTorrentsNumber: function(filterName, category, tag, tracker) { + getFilteredTorrentsNumber(filterName, category, tag, tracker) { let cnt = 0; for (const row of this.rows.values()) { @@ -1743,9 +1737,9 @@ window.qBittorrent.DynamicTable ??= (() => { ++cnt; } return cnt; - }, + } - getFilteredTorrentsHashes: function(filterName, category, tag, tracker) { + getFilteredTorrentsHashes(filterName, category, tag, tracker) { const rowsHashes = []; const useRegex = document.getElementById("torrentsFilterRegexBox").checked; const filterText = document.getElementById("torrentsFilterInput").value.trim().toLowerCase(); @@ -1765,9 +1759,9 @@ window.qBittorrent.DynamicTable ??= (() => { } return rowsHashes; - }, + } - getFilteredAndSortedRows: function() { + getFilteredAndSortedRows() { const filteredRows = []; const useRegex = document.getElementById("torrentsFilterRegexBox").checked; @@ -1798,10 +1792,10 @@ window.qBittorrent.DynamicTable ??= (() => { return -res; }); return filteredRows; - }, + } - setupCommonEvents: function() { - this.parent(); + setupCommonEvents() { + super.setupCommonEvents(); this.dynamicTableDiv.addEventListener("dblclick", (e) => { const tr = e.target.closest("tr"); if (!tr) @@ -1830,21 +1824,19 @@ window.qBittorrent.DynamicTable ??= (() => { else stopFN(); }); - }, + } - getCurrentTorrentID: function() { + getCurrentTorrentID() { return this.getSelectedRowId(); - }, + } - onSelectedRowChanged: () => { + onSelectedRowChanged() { updatePropertiesPanel(); } - }); + } - const TorrentPeersTable = new Class({ - Extends: DynamicTable, - - initColumns: function() { + class TorrentPeersTable extends DynamicTable { + initColumns() { this.newColumn("country", "", "QBT_TR(Country/Region)QBT_TR[CONTEXT=PeerListWidget]", 22, true); this.newColumn("ip", "", "QBT_TR(IP)QBT_TR[CONTEXT=PeerListWidget]", 80, true); this.newColumn("port", "", "QBT_TR(Port)QBT_TR[CONTEXT=PeerListWidget]", 35, true); @@ -1863,10 +1855,9 @@ window.qBittorrent.DynamicTable ??= (() => { this.columns["country"].dataProperties.push("country_code"); this.columns["flags"].dataProperties.push("flags_desc"); this.initColumnsFunctions(); - }, - - initColumnsFunctions: function() { + } + initColumnsFunctions() { // country this.columns["country"].updateTd = function(td, row) { const country = this.getRowValue(row, 0); @@ -1949,12 +1940,10 @@ window.qBittorrent.DynamicTable ??= (() => { }; } - }); + } - const SearchResultsTable = new Class({ - Extends: DynamicTable, - - initColumns: function() { + class SearchResultsTable extends DynamicTable { + initColumns() { this.newColumn("fileName", "", "QBT_TR(Name)QBT_TR[CONTEXT=SearchResultsTable]", 500, true); this.newColumn("fileSize", "", "QBT_TR(Size)QBT_TR[CONTEXT=SearchResultsTable]", 100, true); this.newColumn("nbSeeders", "", "QBT_TR(Seeders)QBT_TR[CONTEXT=SearchResultsTable]", 100, true); @@ -1964,9 +1953,9 @@ window.qBittorrent.DynamicTable ??= (() => { this.newColumn("pubDate", "", "QBT_TR(Published On)QBT_TR[CONTEXT=SearchResultsTable]", 200, true); this.initColumnsFunctions(); - }, + } - initColumnsFunctions: function() { + initColumnsFunctions() { const displaySize = function(td, row) { const size = window.qBittorrent.Misc.friendlyUnit(this.getRowValue(row), false); td.textContent = size; @@ -1989,9 +1978,9 @@ window.qBittorrent.DynamicTable ??= (() => { this.columns["nbSeeders"].updateTd = displayNum; this.columns["nbLeechers"].updateTd = displayNum; this.columns["pubDate"].updateTd = displayDate; - }, + } - getFilteredAndSortedRows: function() { + getFilteredAndSortedRows() { const getSizeFilters = () => { let minSize = (window.qBittorrent.Search.searchSizeFilter.min > 0.00) ? (window.qBittorrent.Search.searchSizeFilter.min * Math.pow(1024, window.qBittorrent.Search.searchSizeFilter.minUnit)) : 0.00; let maxSize = (window.qBittorrent.Search.searchSizeFilter.max > 0.00) ? (window.qBittorrent.Search.searchSizeFilter.max * Math.pow(1024, window.qBittorrent.Search.searchSizeFilter.maxUnit)) : 0.00; @@ -2064,22 +2053,20 @@ window.qBittorrent.DynamicTable ??= (() => { }); return filteredRows; - }, - }); + } + } - const SearchPluginsTable = new Class({ - Extends: DynamicTable, - - initColumns: function() { + class SearchPluginsTable extends DynamicTable { + initColumns() { this.newColumn("fullName", "", "QBT_TR(Name)QBT_TR[CONTEXT=SearchPluginsTable]", 175, true); this.newColumn("version", "", "QBT_TR(Version)QBT_TR[CONTEXT=SearchPluginsTable]", 100, true); this.newColumn("url", "", "QBT_TR(Url)QBT_TR[CONTEXT=SearchPluginsTable]", 175, true); this.newColumn("enabled", "", "QBT_TR(Enabled)QBT_TR[CONTEXT=SearchPluginsTable]", 100, true); this.initColumnsFunctions(); - }, + } - initColumnsFunctions: function() { + initColumnsFunctions() { this.columns["enabled"].updateTd = function(td, row) { const value = this.getRowValue(row); if (value) { @@ -2095,13 +2082,11 @@ window.qBittorrent.DynamicTable ??= (() => { td.closest("tr").classList.remove("green"); } }; - }, - }); + } + } - const TorrentTrackersTable = new Class({ - Extends: DynamicTable, - - initColumns: function() { + class TorrentTrackersTable extends DynamicTable { + initColumns() { this.newColumn("tier", "", "QBT_TR(Tier)QBT_TR[CONTEXT=TrackerListWidget]", 35, true); this.newColumn("url", "", "QBT_TR(URL)QBT_TR[CONTEXT=TrackerListWidget]", 250, true); this.newColumn("status", "", "QBT_TR(Status)QBT_TR[CONTEXT=TrackerListWidget]", 125, true); @@ -2112,9 +2097,9 @@ window.qBittorrent.DynamicTable ??= (() => { this.newColumn("message", "", "QBT_TR(Message)QBT_TR[CONTEXT=TrackerListWidget]", 250, true); this.initColumnsFunctions(); - }, + } - initColumnsFunctions: function() { + initColumnsFunctions() { const naturalSort = function(row1, row2) { if (!row1.full_data._sortable || !row2.full_data._sortable) return 0; @@ -2191,33 +2176,30 @@ window.qBittorrent.DynamicTable ??= (() => { td.title = status; }; } - }); + } - const BulkRenameTorrentFilesTable = new Class({ - Extends: DynamicTable, - - filterTerms: [], - prevFilterTerms: [], - prevRowsString: null, - prevFilteredRows: [], - prevSortedColumn: null, - prevReverseSort: null, - fileTree: new window.qBittorrent.FileTree.FileTree(), - - setupVirtualList: function() { - this.parent(); + class BulkRenameTorrentFilesTable extends DynamicTable { + filterTerms = []; + prevFilterTerms = []; + prevRowsString = null; + prevFilteredRows = []; + prevSortedColumn = null; + prevReverseSort = null; + fileTree = new window.qBittorrent.FileTree.FileTree(); + setupVirtualList() { + super.setupVirtualList(); this.rowHeight = 29; - }, + } - populateTable: function(root) { + populateTable(root) { this.fileTree.setRoot(root); root.children.each((node) => { this._addNodeToTable(node, 0); }); - }, + } - _addNodeToTable: function(node, depth) { + _addNodeToTable(node, depth) { node.depth = depth; if (node.isFolder) { @@ -2243,28 +2225,28 @@ window.qBittorrent.DynamicTable ??= (() => { node.children.each((child) => { this._addNodeToTable(child, depth + 1); }); - }, + } - getRoot: function() { + getRoot() { return this.fileTree.getRoot(); - }, + } - getNode: function(rowId) { + getNode(rowId) { return this.fileTree.getNode(rowId); - }, + } - getRow: function(node) { + getRow(node) { const rowId = this.fileTree.getRowId(node).toString(); return this.rows.get(rowId); - }, + } - getSelectedRows: function() { + getSelectedRows() { const nodes = this.fileTree.toArray(); return nodes.filter(x => x.checked === 0); - }, + } - initColumns: function() { + initColumns() { // Blocks saving header width (because window width isn't saved) LocalPreferences.remove(`column_checked_width_${this.dynamicTableDivId}`); LocalPreferences.remove(`column_original_width_${this.dynamicTableDivId}`); @@ -2274,12 +2256,12 @@ window.qBittorrent.DynamicTable ??= (() => { this.newColumn("renamed", "", "QBT_TR(Renamed)QBT_TR[CONTEXT=TrackerListWidget]", 220, true); this.initColumnsFunctions(); - }, + } /** * Toggles the global checkbox and all checkboxes underneath */ - toggleGlobalCheckbox: function() { + toggleGlobalCheckbox() { const checkbox = document.getElementById("rootMultiRename_cb"); const checkboxes = document.querySelectorAll("input.RenamingCB"); @@ -2305,9 +2287,9 @@ window.qBittorrent.DynamicTable ??= (() => { } this.updateGlobalCheckbox(); - }, + } - toggleNodeTreeCheckbox: function(rowId, checkState) { + toggleNodeTreeCheckbox(rowId, checkState) { const node = this.getNode(rowId); node.checked = checkState; node.full_data.checked = checkState; @@ -2317,9 +2299,9 @@ window.qBittorrent.DynamicTable ??= (() => { for (let i = 0; i < node.children.length; ++i) this.toggleNodeTreeCheckbox(node.children[i].rowId, checkState); - }, + } - updateGlobalCheckbox: function() { + updateGlobalCheckbox() { const checkbox = document.getElementById("rootMultiRename_cb"); const nodes = this.fileTree.toArray(); const isAllChecked = nodes.every((node) => node.checked === 0); @@ -2339,9 +2321,9 @@ window.qBittorrent.DynamicTable ??= (() => { checkbox.indeterminate = true; checkbox.checked = false; } - }, + } - initColumnsFunctions: function() { + initColumnsFunctions() { const that = this; // checked @@ -2426,15 +2408,13 @@ window.qBittorrent.DynamicTable ??= (() => { span.id = fileNameRenamedId; span.textContent = node.renamed; }; - }, + } - onRowSelectionChange: (row) => {}, + onRowSelectionChange(row) {} - selectRow: () => { - return; - }, + selectRow() {} - reselectRows: function(rowIds) { + reselectRows(rowIds) { this.deselectAll(); for (const tr of this.getTrs()) { if (rowIds.includes(tr.rowId)) { @@ -2449,9 +2429,9 @@ window.qBittorrent.DynamicTable ??= (() => { } } this.updateGlobalCheckbox(); - }, + } - _sortNodesByColumn: function(nodes, column) { + _sortNodesByColumn(nodes, column) { nodes.sort((row1, row2) => { // list folders before files when sorting by name if (column.name === "original") { @@ -2471,9 +2451,9 @@ window.qBittorrent.DynamicTable ??= (() => { if (node.children.length > 0) this._sortNodesByColumn(node.children, column); }); - }, + } - _filterNodes: function(node, filterTerms, filteredRows) { + _filterNodes(node, filterTerms, filteredRows) { if (node.isFolder) { const childAdded = node.children.reduce((acc, child) => { // we must execute the function before ORing w/ acc or we'll stop checking child nodes after the first successful match @@ -2494,17 +2474,17 @@ window.qBittorrent.DynamicTable ??= (() => { } return false; - }, + } - setFilter: function(text) { + setFilter(text) { const filterTerms = text.trim().toLowerCase().split(" "); if ((filterTerms.length === 1) && (filterTerms[0] === "")) this.filterTerms = []; else this.filterTerms = filterTerms; - }, + } - getFilteredAndSortedRows: function() { + getFilteredAndSortedRows() { if (this.getRoot() === null) return []; @@ -2560,17 +2540,17 @@ window.qBittorrent.DynamicTable ??= (() => { this.prevSortedColumn = this.sortedColumn; this.prevReverseSort = this.reverseSort; return filteredRows; - }, + } - setIgnored: function(rowId, ignore) { + setIgnored(rowId, ignore) { const row = this.rows.get(rowId); if (ignore) row.full_data.remaining = 0; else row.full_data.remaining = (row.full_data.size * (1.0 - (row.full_data.progress / 100))); - }, + } - setupCommonEvents: function() { + setupCommonEvents() { const headerDiv = document.getElementById("bulkRenameFilesTableFixedHeaderDiv"); this.dynamicTableDiv.addEventListener("scroll", (e) => { headerDiv.scrollLeft = this.dynamicTableDiv.scrollLeft; @@ -2579,64 +2559,59 @@ window.qBittorrent.DynamicTable ??= (() => { this.rerender(); }); } - }); + } - const TorrentFilesTable = new Class({ - Extends: DynamicTable, + class TorrentFilesTable extends DynamicTable { + filterTerms = []; + prevFilterTerms = []; + prevRowsString = null; + prevFilteredRows = []; + prevSortedColumn = null; + prevReverseSort = null; + fileTree = new window.qBittorrent.FileTree.FileTree(); + collapseState = new Map(); - filterTerms: [], - prevFilterTerms: [], - prevRowsString: null, - prevFilteredRows: [], - prevSortedColumn: null, - prevReverseSort: null, - fileTree: new window.qBittorrent.FileTree.FileTree(), - - initialize: function() { - this.collapseState = new Map(); - }, - - isCollapsed: function(id) { + isCollapsed(id) { return this.collapseState.get(id)?.collapsed ?? false; - }, + } - expandNode: function(id) { + expandNode(id) { const state = this.collapseState.get(id); if (state !== undefined) state.collapsed = false; this._updateNodeState(id, false); - }, + } - collapseNode: function(id) { + collapseNode(id) { const state = this.collapseState.get(id); if (state !== undefined) state.collapsed = true; this._updateNodeState(id, true); - }, + } - expandAllNodes: function() { + expandAllNodes() { for (const [key, _] of this.collapseState) this.expandNode(key); - }, + } - collapseAllNodes: function() { + collapseAllNodes() { for (const [key, state] of this.collapseState) { // collapse all nodes except root if (state.depth >= 1) this.collapseNode(key); } - }, + } - _updateNodeVisibility: (node, shouldHide) => { + _updateNodeVisibility(node, shouldHide) { const span = document.getElementById(`filesTablefileName${node.rowId}`); // span won't exist if row has been filtered out if (span === null) return; const tr = span.parentElement.parentElement; tr.classList.toggle("invisible", shouldHide); - }, + } - _updateNodeCollapseIcon: (node, isCollapsed) => { + _updateNodeCollapseIcon(node, isCollapsed) { const span = document.getElementById(`filesTablefileName${node.rowId}`); // span won't exist if row has been filtered out if (span === null) @@ -2646,9 +2621,9 @@ window.qBittorrent.DynamicTable ??= (() => { // rotate the collapse icon const collapseIcon = td.firstElementChild; collapseIcon.classList.toggle("rotate", isCollapsed); - }, + } - _updateNodeState: function(id, shouldCollapse) { + _updateNodeState(id, shouldCollapse) { // collapsed rows will be filtered out when using virtual list if (this.useVirtualList) return; @@ -2659,9 +2634,9 @@ window.qBittorrent.DynamicTable ??= (() => { this._updateNodeCollapseIcon(node, shouldCollapse); this._updateNodeChildVisibility(node, shouldCollapse); - }, + } - _updateNodeChildVisibility: function(root, shouldHide) { + _updateNodeChildVisibility(root, shouldHide) { const stack = [...root.children]; while (stack.length > 0) { const node = stack.pop(); @@ -2670,48 +2645,46 @@ window.qBittorrent.DynamicTable ??= (() => { stack.push(...node.children); } - }, - - clear: function() { - this.parent(); + } + clear() { + super.clear(); this.collapseState.clear(); - }, - - setupVirtualList: function() { - this.parent(); + } + setupVirtualList() { + super.setupVirtualList(); this.rowHeight = 29.5; - }, + } - expandFolder: function(id) { + expandFolder(id) { const node = this.getNode(id); if (node.isFolder) this.expandNode(node); - }, + } - collapseFolder: function(id) { + collapseFolder(id) { const node = this.getNode(id); if (node.isFolder) this.collapseNode(node); - }, + } - isAllCheckboxesChecked: function() { + isAllCheckboxesChecked() { return this.fileTree.toArray().every((node) => node.checked === 1); - }, + } - isAllCheckboxesUnchecked: function() { + isAllCheckboxesUnchecked() { return this.fileTree.toArray().every((node) => node.checked !== 1); - }, + } - populateTable: function(root) { + populateTable(root) { this.fileTree.setRoot(root); root.children.each((node) => { this._addNodeToTable(node, 0); }); - }, + } - _addNodeToTable: function(node, depth) { + _addNodeToTable(node, depth) { node.depth = depth; if (node.isFolder) { @@ -2742,27 +2715,27 @@ window.qBittorrent.DynamicTable ??= (() => { node.children.each((child) => { this._addNodeToTable(child, depth + 1); }); - }, + } - getRoot: function() { + getRoot() { return this.fileTree.getRoot(); - }, + } - getNode: function(rowId) { + getNode(rowId) { return this.fileTree.getNode(rowId); - }, + } - getRow: function(node) { + getRow(node) { const rowId = this.fileTree.getRowId(node).toString(); return this.rows.get(rowId); - }, + } - getRowFileId: function(rowId) { + getRowFileId(rowId) { const row = this.rows.get(rowId); return row?.full_data.fileId; - }, + } - initColumns: function() { + initColumns() { this.newColumn("checked", "", "", 50, true); this.newColumn("name", "", "QBT_TR(Name)QBT_TR[CONTEXT=TrackerListWidget]", 300, true); this.newColumn("size", "", "QBT_TR(Total Size)QBT_TR[CONTEXT=TrackerListWidget]", 75, true); @@ -2772,9 +2745,9 @@ window.qBittorrent.DynamicTable ??= (() => { this.newColumn("availability", "", "QBT_TR(Availability)QBT_TR[CONTEXT=TrackerListWidget]", 75, true); this.initColumnsFunctions(); - }, + } - initColumnsFunctions: function() { + initColumnsFunctions() { const that = this; const displaySize = function(td, row) { const size = window.qBittorrent.Misc.friendlyUnit(this.getRowValue(row), false); @@ -2906,9 +2879,9 @@ window.qBittorrent.DynamicTable ??= (() => { // remaining, availability this.columns["remaining"].updateTd = displaySize; this.columns["availability"].updateTd = displayPercentage; - }, + } - _sortNodesByColumn: function(nodes, column) { + _sortNodesByColumn(nodes, column) { nodes.sort((row1, row2) => { // list folders before files when sorting by name if (column.name === "name") { @@ -2928,9 +2901,9 @@ window.qBittorrent.DynamicTable ??= (() => { if (node.children.length > 0) this._sortNodesByColumn(node.children, column); }); - }, + } - _filterNodes: function(node, filterTerms, filteredRows) { + _filterNodes(node, filterTerms, filteredRows) { if (node.isFolder && (!this.useVirtualList || !this.isCollapsed(node.rowId))) { const childAdded = node.children.toReversed().reduce((acc, child) => { // we must execute the function before ORing w/ acc or we'll stop checking child nodes after the first successful match @@ -2951,17 +2924,17 @@ window.qBittorrent.DynamicTable ??= (() => { } return false; - }, + } - setFilter: function(text) { + setFilter(text) { const filterTerms = text.trim().toLowerCase().split(" "); if ((filterTerms.length === 1) && (filterTerms[0] === "")) this.filterTerms = []; else this.filterTerms = filterTerms; - }, + } - getFilteredAndSortedRows: function() { + getFilteredAndSortedRows() { if (this.getRoot() === null) return []; @@ -3009,18 +2982,18 @@ window.qBittorrent.DynamicTable ??= (() => { this.prevSortedColumn = this.sortedColumn; this.prevReverseSort = this.reverseSort; return filteredRows; - }, + } - setIgnored: function(rowId, ignore) { + setIgnored(rowId, ignore) { const row = this.rows.get(rowId.toString()); if (ignore) row.full_data.remaining = 0; else row.full_data.remaining = (row.full_data.size * (1.0 - (row.full_data.progress / 100))); - }, + } - setupCommonEvents: function() { - this.parent(); + setupCommonEvents() { + super.setupCommonEvents(); this.dynamicTableDiv.addEventListener("keydown", (e) => { const tr = e.target.closest("tr"); if (!tr) @@ -3038,11 +3011,10 @@ window.qBittorrent.DynamicTable ??= (() => { } }); } - }); + } - const RssFeedTable = new Class({ - Extends: DynamicTable, - initColumns: function() { + class RssFeedTable extends DynamicTable { + initColumns() { this.newColumn("state_icon", "", "", 30, true); this.newColumn("name", "", "QBT_TR(RSS feeds)QBT_TR[CONTEXT=FeedListWidget]", -1, true); @@ -3057,13 +3029,13 @@ window.qBittorrent.DynamicTable ??= (() => { td.textContent = value; td.title = value; }; - }, - setupHeaderMenu: () => {}, - setupHeaderEvents: () => {}, - getFilteredAndSortedRows: function() { + } + setupHeaderMenu() {} + setupHeaderEvents() {} + getFilteredAndSortedRows() { return [...this.getRowValues()]; - }, - selectRow: function(rowId) { + } + selectRow(rowId) { this.selectedRows.push(rowId); this.setRowClass(); this.onSelectedRowChanged(); @@ -3076,9 +3048,9 @@ window.qBittorrent.DynamicTable ??= (() => { } } window.qBittorrent.Rss.showRssFeed(path); - }, - setupCommonEvents: function() { - this.parent(); + } + setupCommonEvents() { + super.setupCommonEvents(); this.dynamicTableDiv.addEventListener("dblclick", (e) => { const tr = e.target.closest("tr"); if (!tr || (tr.rowId === "0")) @@ -3086,8 +3058,8 @@ window.qBittorrent.DynamicTable ??= (() => { window.qBittorrent.Rss.moveItem(this.getRow(tr.rowId).full_data.dataPath); }); - }, - updateRow: function(tr, fullUpdate) { + } + updateRow(tr, fullUpdate) { const row = this.rows.get(tr.rowId); const data = row[fullUpdate ? "full_data" : "data"]; @@ -3101,8 +3073,8 @@ window.qBittorrent.DynamicTable ??= (() => { const indentation = row.full_data.indentation; tds[0].style.paddingLeft = `${indentation * 32 + 4}px`; tds[1].style.paddingLeft = `${indentation * 32 + 4}px`; - }, - updateIcons: function() { + } + updateIcons() { // state_icon for (const row of this.getRowValues()) { let img_path; @@ -3146,8 +3118,8 @@ window.qBittorrent.DynamicTable ??= (() => { td.append(img); } } - }, - newColumn: function(name, style, caption, defaultWidth, defaultVisible) { + } + newColumn(name, style, caption, defaultWidth, defaultVisible) { const column = {}; column["name"] = name; column["title"] = name; @@ -3183,19 +3155,18 @@ window.qBittorrent.DynamicTable ??= (() => { this.hiddenTableHeader.append(document.createElement("th")); this.fixedTableHeader.append(document.createElement("th")); } - }); + } - const RssArticleTable = new Class({ - Extends: DynamicTable, - initColumns: function() { + class RssArticleTable extends DynamicTable { + initColumns() { this.newColumn("name", "", "QBT_TR(Torrents: (double-click to download))QBT_TR[CONTEXT=RSSWidget]", -1, true); - }, - setupHeaderMenu: () => {}, - setupHeaderEvents: () => {}, - getFilteredAndSortedRows: function() { + } + setupHeaderMenu() {} + setupHeaderEvents() {} + getFilteredAndSortedRows() { return [...this.getRowValues()]; - }, - selectRow: function(rowId) { + } + selectRow(rowId) { this.selectedRows.push(rowId); this.setRowClass(); this.onSelectedRowChanged(); @@ -3211,10 +3182,10 @@ window.qBittorrent.DynamicTable ??= (() => { } } window.qBittorrent.Rss.showDetails(feedUid, articleId); - }, + } - setupCommonEvents: function() { - this.parent(); + setupCommonEvents() { + super.setupCommonEvents(); this.dynamicTableDiv.addEventListener("dblclick", (e) => { const tr = e.target.closest("tr"); if (!tr) @@ -3222,8 +3193,8 @@ window.qBittorrent.DynamicTable ??= (() => { showDownloadPage([this.getRow(tr.rowId).full_data.torrentURL]); }); - }, - updateRow: function(tr, fullUpdate) { + } + updateRow(tr, fullUpdate) { const row = this.rows.get(tr.rowId); const data = row[fullUpdate ? "full_data" : "data"]; tr.classList.toggle("unreadArticle", !row.full_data.isRead); @@ -3234,8 +3205,8 @@ window.qBittorrent.DynamicTable ??= (() => { this.columns[i].updateTd(tds[i], row); } row["data"] = {}; - }, - newColumn: function(name, style, caption, defaultWidth, defaultVisible) { + } + newColumn(name, style, caption, defaultWidth, defaultVisible) { const column = {}; column["name"] = name; column["title"] = name; @@ -3271,11 +3242,10 @@ window.qBittorrent.DynamicTable ??= (() => { this.hiddenTableHeader.append(document.createElement("th")); this.fixedTableHeader.append(document.createElement("th")); } - }); + } - const RssDownloaderRulesTable = new Class({ - Extends: DynamicTable, - initColumns: function() { + class RssDownloaderRulesTable extends DynamicTable { + initColumns() { this.newColumn("checked", "", "", 30, true); this.newColumn("name", "", "", -1, true); @@ -3302,15 +3272,15 @@ window.qBittorrent.DynamicTable ??= (() => { } }; this.columns["checked"].staticWidth = 50; - }, - setupHeaderMenu: () => {}, - setupHeaderEvents: () => {}, - getFilteredAndSortedRows: function() { + } + setupHeaderMenu() {} + setupHeaderEvents() {} + getFilteredAndSortedRows() { return [...this.getRowValues()]; - }, + } - setupCommonEvents: function() { - this.parent(); + setupCommonEvents() { + super.setupCommonEvents(); this.dynamicTableDiv.addEventListener("dblclick", (e) => { const tr = e.target.closest("tr"); if (!tr) @@ -3318,8 +3288,8 @@ window.qBittorrent.DynamicTable ??= (() => { window.qBittorrent.RssDownloader.renameRule(this.getRow(tr.rowId).full_data.name); }); - }, - newColumn: function(name, style, caption, defaultWidth, defaultVisible) { + } + newColumn(name, style, caption, defaultWidth, defaultVisible) { const column = {}; column["name"] = name; column["title"] = name; @@ -3354,8 +3324,8 @@ window.qBittorrent.DynamicTable ??= (() => { this.hiddenTableHeader.append(document.createElement("th")); this.fixedTableHeader.append(document.createElement("th")); - }, - selectRow: function(rowId) { + } + selectRow(rowId) { this.selectedRows.push(rowId); this.setRowClass(); this.onSelectedRowChanged(); @@ -3369,11 +3339,10 @@ window.qBittorrent.DynamicTable ??= (() => { } window.qBittorrent.RssDownloader.showRule(name); } - }); + } - const RssDownloaderFeedSelectionTable = new Class({ - Extends: DynamicTable, - initColumns: function() { + class RssDownloaderFeedSelectionTable extends DynamicTable { + initColumns() { this.newColumn("checked", "", "", 30, true); this.newColumn("name", "", "", -1, true); @@ -3399,13 +3368,13 @@ window.qBittorrent.DynamicTable ??= (() => { } }; this.columns["checked"].staticWidth = 50; - }, - setupHeaderMenu: () => {}, - setupHeaderEvents: () => {}, - getFilteredAndSortedRows: function() { + } + setupHeaderMenu() {} + setupHeaderEvents() {} + getFilteredAndSortedRows() { return [...this.getRowValues()]; - }, - newColumn: function(name, style, caption, defaultWidth, defaultVisible) { + } + newColumn(name, style, caption, defaultWidth, defaultVisible) { const column = {}; column["name"] = name; column["title"] = name; @@ -3440,21 +3409,20 @@ window.qBittorrent.DynamicTable ??= (() => { this.hiddenTableHeader.append(document.createElement("th")); this.fixedTableHeader.append(document.createElement("th")); - }, - selectRow: () => {} - }); + } + selectRow() {} + } - const RssDownloaderArticlesTable = new Class({ - Extends: DynamicTable, - initColumns: function() { + class RssDownloaderArticlesTable extends DynamicTable { + initColumns() { this.newColumn("name", "", "", -1, true); - }, - setupHeaderMenu: () => {}, - setupHeaderEvents: () => {}, - getFilteredAndSortedRows: function() { + } + setupHeaderMenu() {} + setupHeaderEvents() {} + getFilteredAndSortedRows() { return [...this.getRowValues()]; - }, - newColumn: function(name, style, caption, defaultWidth, defaultVisible) { + } + newColumn(name, style, caption, defaultWidth, defaultVisible) { const column = {}; column["name"] = name; column["title"] = name; @@ -3489,9 +3457,9 @@ window.qBittorrent.DynamicTable ??= (() => { this.hiddenTableHeader.append(document.createElement("th")); this.fixedTableHeader.append(document.createElement("th")); - }, - selectRow: () => {}, - updateRow: function(tr, fullUpdate) { + } + selectRow() {} + updateRow(tr, fullUpdate) { const row = this.rows.get(tr.rowId); const data = row[fullUpdate ? "full_data" : "data"]; @@ -3511,22 +3479,20 @@ window.qBittorrent.DynamicTable ??= (() => { } row["data"] = {}; } - }); + } - const LogMessageTable = new Class({ - Extends: DynamicTable, + class LogMessageTable extends DynamicTable { + filterText = ""; - filterText: "", - - initColumns: function() { + initColumns() { this.newColumn("rowId", "", "QBT_TR(ID)QBT_TR[CONTEXT=ExecutionLogWidget]", 50, true); this.newColumn("message", "", "QBT_TR(Message)QBT_TR[CONTEXT=ExecutionLogWidget]", 350, true); this.newColumn("timestamp", "", "QBT_TR(Timestamp)QBT_TR[CONTEXT=ExecutionLogWidget]", 150, true); this.newColumn("type", "", "QBT_TR(Log Type)QBT_TR[CONTEXT=ExecutionLogWidget]", 100, true); this.initColumnsFunctions(); - }, + } - initColumnsFunctions: function() { + initColumnsFunctions() { this.columns["timestamp"].updateTd = function(td, row) { const date = new Date(this.getRowValue(row) * 1000).toLocaleString(); td.textContent = date; @@ -3562,9 +3528,9 @@ window.qBittorrent.DynamicTable ??= (() => { td.title = logLevel; td.closest("tr").classList.add(`logTableRow${addClass}`); }; - }, + } - getFilteredAndSortedRows: function() { + getFilteredAndSortedRows() { let filteredRows = []; this.filterText = window.qBittorrent.Log.getFilterText(); const filterTerms = (this.filterText.length > 0) ? this.filterText.toLowerCase().split(" ") : []; @@ -3593,13 +3559,11 @@ window.qBittorrent.DynamicTable ??= (() => { this.filteredLength = filteredRows.length; return filteredRows; - }, - }); + } + } - const LogPeerTable = new Class({ - Extends: LogMessageTable, - - initColumns: function() { + class LogPeerTable extends LogMessageTable { + initColumns() { this.newColumn("rowId", "", "QBT_TR(ID)QBT_TR[CONTEXT=ExecutionLogWidget]", 50, true); this.newColumn("ip", "", "QBT_TR(IP)QBT_TR[CONTEXT=ExecutionLogWidget]", 150, true); this.newColumn("timestamp", "", "QBT_TR(Timestamp)QBT_TR[CONTEXT=ExecutionLogWidget]", 150, true); @@ -3626,9 +3590,9 @@ window.qBittorrent.DynamicTable ??= (() => { td.title = status; td.closest("tr").classList.add(`logTableRow${addClass}`); }; - }, + } - getFilteredAndSortedRows: function() { + getFilteredAndSortedRows() { let filteredRows = []; this.filterText = window.qBittorrent.Log.getFilterText(); const filterTerms = (this.filterText.length > 0) ? this.filterText.toLowerCase().split(" ") : []; @@ -3652,20 +3616,16 @@ window.qBittorrent.DynamicTable ??= (() => { return filteredRows; } - }); + } - const TorrentWebseedsTable = new Class({ - Extends: DynamicTable, - - initColumns: function() { + class TorrentWebseedsTable extends DynamicTable { + initColumns() { this.newColumn("url", "", "QBT_TR(URL)QBT_TR[CONTEXT=HttpServer]", 500, true); - }, - }); + } + } - const TorrentCreationTasksTable = new Class({ - Extends: DynamicTable, - - initColumns: function() { + class TorrentCreationTasksTable extends DynamicTable { + initColumns() { this.newColumn("state_icon", "", "QBT_TR(Status Icon)QBT_TR[CONTEXT=TorrentCreator]", 30, false); this.newColumn("source_path", "", "QBT_TR(Source Path)QBT_TR[CONTEXT=TorrentCreator]", 200, true); this.newColumn("progress", "", "QBT_TR(Progress)QBT_TR[CONTEXT=TorrentCreator]", 85, true); @@ -3686,9 +3646,9 @@ window.qBittorrent.DynamicTable ??= (() => { this.columns["source_path"].dataProperties.push("status"); this.initColumnsFunctions(); - }, + } - initColumnsFunctions: function() { + initColumnsFunctions() { const getStateIconClasses = (state) => { let stateClass = "stateUnknown"; // normalize states @@ -3864,10 +3824,10 @@ window.qBittorrent.DynamicTable ??= (() => { this.columns["added_on"].updateTd = displayDate; this.columns["start_on"].updateTd = displayDate; this.columns["completion_on"].updateTd = displayDate; - }, + } - setupCommonEvents: function() { - this.parent(); + setupCommonEvents() { + super.setupCommonEvents(); this.dynamicTableDiv.addEventListener("dblclick", (e) => { const tr = e.target.closest("tr"); if (!tr) @@ -3878,8 +3838,8 @@ window.qBittorrent.DynamicTable ??= (() => { window.qBittorrent.TorrentCreator.exportTorrents(); }); - }, - }); + } + } return exports(); })();