mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-25 10:46:15 +03:00
WebUI: Use Map instead of Mootools Hash in all dynamic tables
PR #21358.
This commit is contained in:
parent
81def39d8c
commit
8b2d8f3afd
10 changed files with 176 additions and 181 deletions
|
@ -483,9 +483,8 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const all = torrentsTable.rows.size;
|
|
||||||
let uncategorized = 0;
|
let uncategorized = 0;
|
||||||
for (const { full_data: { category } } of torrentsTable.rows.values()) {
|
for (const { full_data: { category } } of torrentsTable.getRowValues()) {
|
||||||
if (category.length === 0)
|
if (category.length === 0)
|
||||||
uncategorized += 1;
|
uncategorized += 1;
|
||||||
}
|
}
|
||||||
|
@ -517,7 +516,7 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const categoriesFragment = new DocumentFragment();
|
const categoriesFragment = new DocumentFragment();
|
||||||
categoriesFragment.appendChild(createCategoryLink(CATEGORIES_ALL, "QBT_TR(All)QBT_TR[CONTEXT=CategoryFilterModel]", all));
|
categoriesFragment.appendChild(createCategoryLink(CATEGORIES_ALL, "QBT_TR(All)QBT_TR[CONTEXT=CategoryFilterModel]", torrentsTable.getRowSize()));
|
||||||
categoriesFragment.appendChild(createCategoryLink(CATEGORIES_UNCATEGORIZED, "QBT_TR(Uncategorized)QBT_TR[CONTEXT=CategoryFilterModel]", uncategorized));
|
categoriesFragment.appendChild(createCategoryLink(CATEGORIES_UNCATEGORIZED, "QBT_TR(Uncategorized)QBT_TR[CONTEXT=CategoryFilterModel]", uncategorized));
|
||||||
|
|
||||||
if (useSubcategories) {
|
if (useSubcategories) {
|
||||||
|
@ -581,14 +580,13 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||||
return tagFilterItem;
|
return tagFilterItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
const torrentsCount = torrentsTable.rows.size;
|
|
||||||
let untagged = 0;
|
let untagged = 0;
|
||||||
for (const { full_data: { tags } } of torrentsTable.rows.values()) {
|
for (const { full_data: { tags } } of torrentsTable.getRowValues()) {
|
||||||
if (tags.length === 0)
|
if (tags.length === 0)
|
||||||
untagged += 1;
|
untagged += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tagFilterList.appendChild(createLink(TAGS_ALL, "QBT_TR(All)QBT_TR[CONTEXT=TagFilterModel]", torrentsCount));
|
tagFilterList.appendChild(createLink(TAGS_ALL, "QBT_TR(All)QBT_TR[CONTEXT=TagFilterModel]", torrentsTable.getRowSize()));
|
||||||
tagFilterList.appendChild(createLink(TAGS_UNTAGGED, "QBT_TR(Untagged)QBT_TR[CONTEXT=TagFilterModel]", untagged));
|
tagFilterList.appendChild(createLink(TAGS_UNTAGGED, "QBT_TR(Untagged)QBT_TR[CONTEXT=TagFilterModel]", untagged));
|
||||||
|
|
||||||
const sortedTags = [];
|
const sortedTags = [];
|
||||||
|
@ -634,14 +632,13 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||||
return trackerFilterItem;
|
return trackerFilterItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
const torrentsCount = torrentsTable.rows.size;
|
|
||||||
let trackerlessTorrentsCount = 0;
|
let trackerlessTorrentsCount = 0;
|
||||||
for (const { full_data: { trackers_count: trackersCount } } of torrentsTable.rows.values()) {
|
for (const { full_data: { trackers_count: trackersCount } } of torrentsTable.getRowValues()) {
|
||||||
if (trackersCount === 0)
|
if (trackersCount === 0)
|
||||||
trackerlessTorrentsCount += 1;
|
trackerlessTorrentsCount += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
trackerFilterList.appendChild(createLink(TRACKERS_ALL, "QBT_TR(All (%1))QBT_TR[CONTEXT=TrackerFiltersList]", torrentsCount));
|
trackerFilterList.appendChild(createLink(TRACKERS_ALL, "QBT_TR(All (%1))QBT_TR[CONTEXT=TrackerFiltersList]", torrentsTable.getRowSize()));
|
||||||
trackerFilterList.appendChild(createLink(TRACKERS_TRACKERLESS, "QBT_TR(Trackerless (%1))QBT_TR[CONTEXT=TrackerFiltersList]", trackerlessTorrentsCount));
|
trackerFilterList.appendChild(createLink(TRACKERS_TRACKERLESS, "QBT_TR(Trackerless (%1))QBT_TR[CONTEXT=TrackerFiltersList]", trackerlessTorrentsCount));
|
||||||
|
|
||||||
// Remove unused trackers
|
// Remove unused trackers
|
||||||
|
|
|
@ -323,7 +323,7 @@ window.qBittorrent.ContextMenu ??= (() => {
|
||||||
|
|
||||||
const selectedRows = torrentsTable.selectedRowsIds();
|
const selectedRows = torrentsTable.selectedRowsIds();
|
||||||
selectedRows.forEach((item, index) => {
|
selectedRows.forEach((item, index) => {
|
||||||
const data = torrentsTable.rows.get(item).full_data;
|
const data = torrentsTable.getRow(item).full_data;
|
||||||
|
|
||||||
if (data["seq_dl"] !== true)
|
if (data["seq_dl"] !== true)
|
||||||
all_are_seq_dl = false;
|
all_are_seq_dl = false;
|
||||||
|
@ -374,7 +374,7 @@ window.qBittorrent.ContextMenu ??= (() => {
|
||||||
|
|
||||||
// hide renameFiles when more than 1 torrent is selected
|
// hide renameFiles when more than 1 torrent is selected
|
||||||
if (selectedRows.length === 1) {
|
if (selectedRows.length === 1) {
|
||||||
const data = torrentsTable.rows.get(selectedRows[0]).full_data;
|
const data = torrentsTable.getRow(selectedRows[0]).full_data;
|
||||||
const metadata_downloaded = !((data["state"] === "metaDL") || (data["state"] === "forcedMetaDL") || (data["total_size"] === -1));
|
const metadata_downloaded = !((data["state"] === "metaDL") || (data["state"] === "forcedMetaDL") || (data["total_size"] === -1));
|
||||||
|
|
||||||
// hide renameFiles when metadata hasn't been downloaded yet
|
// hide renameFiles when metadata hasn't been downloaded yet
|
||||||
|
@ -655,7 +655,7 @@ window.qBittorrent.ContextMenu ??= (() => {
|
||||||
this.hideItem("copyFeedURL");
|
this.hideItem("copyFeedURL");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (selectedRows[0] === 0) {
|
if (selectedRows[0] === "0") {
|
||||||
// menu when "unread" feed selected
|
// menu when "unread" feed selected
|
||||||
this.showItem("update");
|
this.showItem("update");
|
||||||
this.showItem("markRead");
|
this.showItem("markRead");
|
||||||
|
@ -666,7 +666,7 @@ window.qBittorrent.ContextMenu ??= (() => {
|
||||||
this.hideItem("updateAll");
|
this.hideItem("updateAll");
|
||||||
this.hideItem("copyFeedURL");
|
this.hideItem("copyFeedURL");
|
||||||
}
|
}
|
||||||
else if (window.qBittorrent.Rss.rssFeedTable.rows[selectedRows[0]].full_data.dataUid === "") {
|
else if (window.qBittorrent.Rss.rssFeedTable.getRow(selectedRows[0]).full_data.dataUid === "") {
|
||||||
// menu when single folder selected
|
// menu when single folder selected
|
||||||
this.showItem("update");
|
this.showItem("update");
|
||||||
this.showItem("markRead");
|
this.showItem("markRead");
|
||||||
|
|
|
@ -76,7 +76,7 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
this.fixedTableHeader = $(dynamicTableFixedHeaderDivId).getElements("tr")[0];
|
this.fixedTableHeader = $(dynamicTableFixedHeaderDivId).getElements("tr")[0];
|
||||||
this.hiddenTableHeader = $(dynamicTableDivId).getElements("tr")[0];
|
this.hiddenTableHeader = $(dynamicTableDivId).getElements("tr")[0];
|
||||||
this.tableBody = $(dynamicTableDivId).getElements("tbody")[0];
|
this.tableBody = $(dynamicTableDivId).getElements("tbody")[0];
|
||||||
this.rows = new Hash();
|
this.rows = new Map();
|
||||||
this.selectedRows = [];
|
this.selectedRows = [];
|
||||||
this.columns = [];
|
this.columns = [];
|
||||||
this.contextMenu = contextMenu;
|
this.contextMenu = contextMenu;
|
||||||
|
@ -665,11 +665,9 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
getFilteredAndSortedRows: function() {
|
getFilteredAndSortedRows: function() {
|
||||||
const filteredRows = [];
|
const filteredRows = [];
|
||||||
|
|
||||||
const rows = this.rows.getValues();
|
for (const row of this.getRowValues()) {
|
||||||
|
filteredRows.push(row);
|
||||||
for (let i = 0; i < rows.length; ++i) {
|
filteredRows[row.rowId] = row;
|
||||||
filteredRows.push(rows[i]);
|
|
||||||
filteredRows[rows[i].rowId] = rows[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
filteredRows.sort((row1, row2) => {
|
filteredRows.sort((row1, row2) => {
|
||||||
|
@ -828,16 +826,14 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
|
|
||||||
removeRow: function(rowId) {
|
removeRow: function(rowId) {
|
||||||
this.selectedRows.erase(rowId);
|
this.selectedRows.erase(rowId);
|
||||||
if (this.rows.has(rowId))
|
this.rows.delete(rowId);
|
||||||
this.rows.erase(rowId);
|
|
||||||
const tr = this.getTrByRowId(rowId);
|
const tr = this.getTrByRowId(rowId);
|
||||||
if (tr !== null)
|
tr?.destroy();
|
||||||
tr.destroy();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
clear: function() {
|
clear: function() {
|
||||||
this.deselectAll();
|
this.deselectAll();
|
||||||
this.rows.empty();
|
this.rows.clear();
|
||||||
const trs = this.tableBody.getElements("tr");
|
const trs = this.tableBody.getElements("tr");
|
||||||
while (trs.length > 0)
|
while (trs.length > 0)
|
||||||
trs.pop().destroy();
|
trs.pop().destroy();
|
||||||
|
@ -848,7 +844,19 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
},
|
},
|
||||||
|
|
||||||
getRowIds: function() {
|
getRowIds: function() {
|
||||||
return this.rows.getKeys();
|
return this.rows.keys();
|
||||||
|
},
|
||||||
|
|
||||||
|
getRowValues: function() {
|
||||||
|
return this.rows.values();
|
||||||
|
},
|
||||||
|
|
||||||
|
getRowItems: function() {
|
||||||
|
return this.rows.entries();
|
||||||
|
},
|
||||||
|
|
||||||
|
getRowSize: function() {
|
||||||
|
return this.rows.size;
|
||||||
},
|
},
|
||||||
|
|
||||||
selectNextRow: function() {
|
selectNextRow: function() {
|
||||||
|
@ -899,11 +907,6 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
const TorrentsTable = new Class({
|
const TorrentsTable = new Class({
|
||||||
Extends: DynamicTable,
|
Extends: DynamicTable,
|
||||||
|
|
||||||
setup: function(dynamicTableDivId, dynamicTableFixedHeaderDivId, contextMenu) {
|
|
||||||
this.parent(dynamicTableDivId, dynamicTableFixedHeaderDivId, contextMenu);
|
|
||||||
this.rows = new Map();
|
|
||||||
},
|
|
||||||
|
|
||||||
initColumns: function() {
|
initColumns: function() {
|
||||||
this.newColumn("priority", "", "#", 30, true);
|
this.newColumn("priority", "", "#", 30, true);
|
||||||
this.newColumn("state_icon", "cursor: default", "", 22, true);
|
this.newColumn("state_icon", "cursor: default", "", 22, true);
|
||||||
|
@ -1510,25 +1513,6 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
removeRow: function(rowId) {
|
|
||||||
this.selectedRows.erase(rowId);
|
|
||||||
this.rows.delete(rowId);
|
|
||||||
const tr = this.getTrByRowId(rowId);
|
|
||||||
tr?.destroy();
|
|
||||||
},
|
|
||||||
|
|
||||||
clear: function() {
|
|
||||||
this.deselectAll();
|
|
||||||
this.rows.clear();
|
|
||||||
const trs = this.tableBody.getElements("tr");
|
|
||||||
while (trs.length > 0)
|
|
||||||
trs.pop().destroy();
|
|
||||||
},
|
|
||||||
|
|
||||||
getRowIds: function() {
|
|
||||||
return this.rows.keys();
|
|
||||||
},
|
|
||||||
|
|
||||||
getFilteredTorrentsNumber: function(filterName, categoryHash, tagHash, trackerHash) {
|
getFilteredTorrentsNumber: function(filterName, categoryHash, tagHash, trackerHash) {
|
||||||
let cnt = 0;
|
let cnt = 0;
|
||||||
|
|
||||||
|
@ -1809,7 +1793,6 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
};
|
};
|
||||||
|
|
||||||
let filteredRows = [];
|
let filteredRows = [];
|
||||||
const rows = this.rows.getValues();
|
|
||||||
const searchTerms = window.qBittorrent.Search.searchText.pattern.toLowerCase().split(" ");
|
const searchTerms = window.qBittorrent.Search.searchText.pattern.toLowerCase().split(" ");
|
||||||
const filterTerms = window.qBittorrent.Search.searchText.filterPattern.toLowerCase().split(" ");
|
const filterTerms = window.qBittorrent.Search.searchText.filterPattern.toLowerCase().split(" ");
|
||||||
const sizeFilters = getSizeFilters();
|
const sizeFilters = getSizeFilters();
|
||||||
|
@ -1817,8 +1800,7 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
const searchInTorrentName = $("searchInTorrentName").value === "names";
|
const searchInTorrentName = $("searchInTorrentName").value === "names";
|
||||||
|
|
||||||
if (searchInTorrentName || (filterTerms.length > 0) || (window.qBittorrent.Search.searchSizeFilter.min > 0.00) || (window.qBittorrent.Search.searchSizeFilter.max > 0.00)) {
|
if (searchInTorrentName || (filterTerms.length > 0) || (window.qBittorrent.Search.searchSizeFilter.min > 0.00) || (window.qBittorrent.Search.searchSizeFilter.max > 0.00)) {
|
||||||
for (let i = 0; i < rows.length; ++i) {
|
for (const row of this.getRowValues()) {
|
||||||
const row = rows[i];
|
|
||||||
|
|
||||||
if (searchInTorrentName && !window.qBittorrent.Misc.containsAllTerms(row.full_data.fileName, searchTerms))
|
if (searchInTorrentName && !window.qBittorrent.Misc.containsAllTerms(row.full_data.fileName, searchTerms))
|
||||||
continue;
|
continue;
|
||||||
|
@ -1837,7 +1819,7 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
filteredRows = rows;
|
filteredRows = [...this.getRowValues()];
|
||||||
}
|
}
|
||||||
|
|
||||||
filteredRows.sort((row1, row2) => {
|
filteredRows.sort((row1, row2) => {
|
||||||
|
@ -1962,7 +1944,7 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
},
|
},
|
||||||
|
|
||||||
getRow: function(node) {
|
getRow: function(node) {
|
||||||
const rowId = this.fileTree.getRowId(node);
|
const rowId = this.fileTree.getRowId(node).toString();
|
||||||
return this.rows.get(rowId);
|
return this.rows.get(rowId);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -2234,10 +2216,10 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
if (this.getRoot() === null)
|
if (this.getRoot() === null)
|
||||||
return [];
|
return [];
|
||||||
|
|
||||||
const generateRowsSignature = function(rows) {
|
const generateRowsSignature = () => {
|
||||||
const rowsData = rows.map((row) => {
|
const rowsData = [];
|
||||||
return row.full_data;
|
for (const { full_data } of this.getRowValues())
|
||||||
});
|
rowsData.push(full_data);
|
||||||
return JSON.stringify(rowsData);
|
return JSON.stringify(rowsData);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2271,7 +2253,7 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
return (rowsChanged || isFilterChanged || isSortedColumnChanged || isReverseSortChanged);
|
return (rowsChanged || isFilterChanged || isSortedColumnChanged || isReverseSortChanged);
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
const rowsString = generateRowsSignature(this.rows);
|
const rowsString = generateRowsSignature();
|
||||||
if (!hasRowsChanged(rowsString, this.prevRowsString))
|
if (!hasRowsChanged(rowsString, this.prevRowsString))
|
||||||
return this.prevFilteredRows;
|
return this.prevFilteredRows;
|
||||||
|
|
||||||
|
@ -2368,7 +2350,7 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
},
|
},
|
||||||
|
|
||||||
getRow: function(node) {
|
getRow: function(node) {
|
||||||
const rowId = this.fileTree.getRowId(node);
|
const rowId = this.fileTree.getRowId(node).toString();
|
||||||
return this.rows.get(rowId);
|
return this.rows.get(rowId);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -2563,10 +2545,10 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
if (this.getRoot() === null)
|
if (this.getRoot() === null)
|
||||||
return [];
|
return [];
|
||||||
|
|
||||||
const generateRowsSignature = function(rows) {
|
const generateRowsSignature = () => {
|
||||||
const rowsData = rows.map((row) => {
|
const rowsData = [];
|
||||||
return row.full_data;
|
for (const { full_data } of this.getRowValues())
|
||||||
});
|
rowsData.push(full_data);
|
||||||
return JSON.stringify(rowsData);
|
return JSON.stringify(rowsData);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2600,7 +2582,7 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
return (rowsChanged || isFilterChanged || isSortedColumnChanged || isReverseSortChanged);
|
return (rowsChanged || isFilterChanged || isSortedColumnChanged || isReverseSortChanged);
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
const rowsString = generateRowsSignature(this.rows);
|
const rowsString = generateRowsSignature();
|
||||||
if (!hasRowsChanged(rowsString, this.prevRowsString))
|
if (!hasRowsChanged(rowsString, this.prevRowsString))
|
||||||
return this.prevFilteredRows;
|
return this.prevFilteredRows;
|
||||||
|
|
||||||
|
@ -2618,7 +2600,7 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
},
|
},
|
||||||
|
|
||||||
setIgnored: function(rowId, ignore) {
|
setIgnored: function(rowId, ignore) {
|
||||||
const row = this.rows.get(rowId);
|
const row = this.rows.get(rowId.toString());
|
||||||
if (ignore)
|
if (ignore)
|
||||||
row.full_data.remaining = 0;
|
row.full_data.remaining = 0;
|
||||||
else
|
else
|
||||||
|
@ -2660,18 +2642,17 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
setupHeaderMenu: function() {},
|
setupHeaderMenu: function() {},
|
||||||
setupHeaderEvents: function() {},
|
setupHeaderEvents: function() {},
|
||||||
getFilteredAndSortedRows: function() {
|
getFilteredAndSortedRows: function() {
|
||||||
return this.rows.getValues();
|
return [...this.getRowValues()];
|
||||||
},
|
},
|
||||||
selectRow: function(rowId) {
|
selectRow: function(rowId) {
|
||||||
this.selectedRows.push(rowId);
|
this.selectedRows.push(rowId);
|
||||||
this.setRowClass();
|
this.setRowClass();
|
||||||
this.onSelectedRowChanged();
|
this.onSelectedRowChanged();
|
||||||
|
|
||||||
const rows = this.rows.getValues();
|
|
||||||
let path = "";
|
let path = "";
|
||||||
for (let i = 0; i < rows.length; ++i) {
|
for (const row of this.getRowValues()) {
|
||||||
if (rows[i].rowId === rowId) {
|
if (row.rowId === rowId) {
|
||||||
path = rows[i].full_data.dataPath;
|
path = row.full_data.dataPath;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2702,7 +2683,7 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
},
|
},
|
||||||
updateIcons: function() {
|
updateIcons: function() {
|
||||||
// state_icon
|
// state_icon
|
||||||
this.rows.each(row => {
|
for (const row of this.getRowValues()) {
|
||||||
let img_path;
|
let img_path;
|
||||||
switch (row.full_data.status) {
|
switch (row.full_data.status) {
|
||||||
case "default":
|
case "default":
|
||||||
|
@ -2743,7 +2724,7 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
"width": "22px"
|
"width": "22px"
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
},
|
},
|
||||||
newColumn: function(name, style, caption, defaultWidth, defaultVisible) {
|
newColumn: function(name, style, caption, defaultWidth, defaultVisible) {
|
||||||
const column = {};
|
const column = {};
|
||||||
|
@ -2791,21 +2772,20 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
setupHeaderMenu: function() {},
|
setupHeaderMenu: function() {},
|
||||||
setupHeaderEvents: function() {},
|
setupHeaderEvents: function() {},
|
||||||
getFilteredAndSortedRows: function() {
|
getFilteredAndSortedRows: function() {
|
||||||
return this.rows.getValues();
|
return [...this.getRowValues()];
|
||||||
},
|
},
|
||||||
selectRow: function(rowId) {
|
selectRow: function(rowId) {
|
||||||
this.selectedRows.push(rowId);
|
this.selectedRows.push(rowId);
|
||||||
this.setRowClass();
|
this.setRowClass();
|
||||||
this.onSelectedRowChanged();
|
this.onSelectedRowChanged();
|
||||||
|
|
||||||
const rows = this.rows.getValues();
|
|
||||||
let articleId = "";
|
let articleId = "";
|
||||||
let feedUid = "";
|
let feedUid = "";
|
||||||
for (let i = 0; i < rows.length; ++i) {
|
for (const row of this.getRowValues()) {
|
||||||
if (rows[i].rowId === rowId) {
|
if (row.rowId === rowId) {
|
||||||
articleId = rows[i].full_data.dataId;
|
articleId = row.full_data.dataId;
|
||||||
feedUid = rows[i].full_data.feedUid;
|
feedUid = row.full_data.feedUid;
|
||||||
this.tableBody.rows[rows[i].rowId].removeClass("unreadArticle");
|
this.tableBody.rows[row.rowId].removeClass("unreadArticle");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2903,7 +2883,7 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
setupHeaderMenu: function() {},
|
setupHeaderMenu: function() {},
|
||||||
setupHeaderEvents: function() {},
|
setupHeaderEvents: function() {},
|
||||||
getFilteredAndSortedRows: function() {
|
getFilteredAndSortedRows: function() {
|
||||||
return this.rows.getValues();
|
return [...this.getRowValues()];
|
||||||
},
|
},
|
||||||
setupTr: function(tr) {
|
setupTr: function(tr) {
|
||||||
tr.addEventListener("dblclick", function(e) {
|
tr.addEventListener("dblclick", function(e) {
|
||||||
|
@ -2952,11 +2932,10 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
this.setRowClass();
|
this.setRowClass();
|
||||||
this.onSelectedRowChanged();
|
this.onSelectedRowChanged();
|
||||||
|
|
||||||
const rows = this.rows.getValues();
|
|
||||||
let name = "";
|
let name = "";
|
||||||
for (let i = 0; i < rows.length; ++i) {
|
for (const row of this.getRowValues()) {
|
||||||
if (rows[i].rowId === rowId) {
|
if (row.rowId === rowId) {
|
||||||
name = rows[i].full_data.name;
|
name = row.full_data.name;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2995,7 +2974,7 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
setupHeaderMenu: function() {},
|
setupHeaderMenu: function() {},
|
||||||
setupHeaderEvents: function() {},
|
setupHeaderEvents: function() {},
|
||||||
getFilteredAndSortedRows: function() {
|
getFilteredAndSortedRows: function() {
|
||||||
return this.rows.getValues();
|
return [...this.getRowValues()];
|
||||||
},
|
},
|
||||||
newColumn: function(name, style, caption, defaultWidth, defaultVisible) {
|
newColumn: function(name, style, caption, defaultWidth, defaultVisible) {
|
||||||
const column = {};
|
const column = {};
|
||||||
|
@ -3044,7 +3023,7 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
setupHeaderMenu: function() {},
|
setupHeaderMenu: function() {},
|
||||||
setupHeaderEvents: function() {},
|
setupHeaderEvents: function() {},
|
||||||
getFilteredAndSortedRows: function() {
|
getFilteredAndSortedRows: function() {
|
||||||
return this.rows.getValues();
|
return [...this.getRowValues()];
|
||||||
},
|
},
|
||||||
newColumn: function(name, style, caption, defaultWidth, defaultVisible) {
|
newColumn: function(name, style, caption, defaultWidth, defaultVisible) {
|
||||||
const column = {};
|
const column = {};
|
||||||
|
@ -3160,23 +3139,22 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
|
|
||||||
getFilteredAndSortedRows: function() {
|
getFilteredAndSortedRows: function() {
|
||||||
let filteredRows = [];
|
let filteredRows = [];
|
||||||
const rows = this.rows.getValues();
|
|
||||||
this.filterText = window.qBittorrent.Log.getFilterText();
|
this.filterText = window.qBittorrent.Log.getFilterText();
|
||||||
const filterTerms = (this.filterText.length > 0) ? this.filterText.toLowerCase().split(" ") : [];
|
const filterTerms = (this.filterText.length > 0) ? this.filterText.toLowerCase().split(" ") : [];
|
||||||
const logLevels = window.qBittorrent.Log.getSelectedLevels();
|
const logLevels = window.qBittorrent.Log.getSelectedLevels();
|
||||||
if ((filterTerms.length > 0) || (logLevels.length < 4)) {
|
if ((filterTerms.length > 0) || (logLevels.length < 4)) {
|
||||||
for (let i = 0; i < rows.length; ++i) {
|
for (const row of this.getRowValues()) {
|
||||||
if (!logLevels.includes(rows[i].full_data.type.toString()))
|
if (!logLevels.includes(row.full_data.type.toString()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((filterTerms.length > 0) && !window.qBittorrent.Misc.containsAllTerms(rows[i].full_data.message, filterTerms))
|
if ((filterTerms.length > 0) && !window.qBittorrent.Misc.containsAllTerms(row.full_data.message, filterTerms))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
filteredRows.push(rows[i]);
|
filteredRows.push(row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
filteredRows = rows;
|
filteredRows = [...this.getRowValues()];
|
||||||
}
|
}
|
||||||
|
|
||||||
filteredRows.sort((row1, row2) => {
|
filteredRows.sort((row1, row2) => {
|
||||||
|
@ -3227,19 +3205,18 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
|
|
||||||
getFilteredAndSortedRows: function() {
|
getFilteredAndSortedRows: function() {
|
||||||
let filteredRows = [];
|
let filteredRows = [];
|
||||||
const rows = this.rows.getValues();
|
|
||||||
this.filterText = window.qBittorrent.Log.getFilterText();
|
this.filterText = window.qBittorrent.Log.getFilterText();
|
||||||
const filterTerms = (this.filterText.length > 0) ? this.filterText.toLowerCase().split(" ") : [];
|
const filterTerms = (this.filterText.length > 0) ? this.filterText.toLowerCase().split(" ") : [];
|
||||||
if (filterTerms.length > 0) {
|
if (filterTerms.length > 0) {
|
||||||
for (let i = 0; i < rows.length; ++i) {
|
for (const row of this.getRowValues()) {
|
||||||
if ((filterTerms.length > 0) && !window.qBittorrent.Misc.containsAllTerms(rows[i].full_data.ip, filterTerms))
|
if ((filterTerms.length > 0) && !window.qBittorrent.Misc.containsAllTerms(row.full_data.ip, filterTerms))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
filteredRows.push(rows[i]);
|
filteredRows.push(row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
filteredRows = rows;
|
filteredRows = [...this.getRowValues()];
|
||||||
}
|
}
|
||||||
|
|
||||||
filteredRows.sort((row1, row2) => {
|
filteredRows.sort((row1, row2) => {
|
||||||
|
|
|
@ -310,7 +310,7 @@ const initializeWindows = function() {
|
||||||
// check if all selected torrents have same share ratio
|
// check if all selected torrents have same share ratio
|
||||||
for (let i = 0; i < hashes.length; ++i) {
|
for (let i = 0; i < hashes.length; ++i) {
|
||||||
const hash = hashes[i];
|
const hash = hashes[i];
|
||||||
const row = torrentsTable.rows.get(hash).full_data;
|
const row = torrentsTable.getRow(hash).full_data;
|
||||||
const origValues = row.ratio_limit + "|" + row.seeding_time_limit + "|" + row.inactive_seeding_time_limit + "|"
|
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;
|
+ row.max_ratio + "|" + row.max_seeding_time + "|" + row.max_inactive_seeding_time;
|
||||||
|
|
||||||
|
@ -537,7 +537,7 @@ const initializeWindows = function() {
|
||||||
if (hashes.length) {
|
if (hashes.length) {
|
||||||
let enable = false;
|
let enable = false;
|
||||||
hashes.each((hash, index) => {
|
hashes.each((hash, index) => {
|
||||||
const row = torrentsTable.rows.get(hash);
|
const row = torrentsTable.getRow(hash);
|
||||||
if (!row.full_data.auto_tmm)
|
if (!row.full_data.auto_tmm)
|
||||||
enable = true;
|
enable = true;
|
||||||
});
|
});
|
||||||
|
@ -601,7 +601,7 @@ const initializeWindows = function() {
|
||||||
const hashes = torrentsTable.selectedRowsIds();
|
const hashes = torrentsTable.selectedRowsIds();
|
||||||
if (hashes.length) {
|
if (hashes.length) {
|
||||||
const hash = hashes[0];
|
const hash = hashes[0];
|
||||||
const row = torrentsTable.rows.get(hash);
|
const row = torrentsTable.getRow(hash);
|
||||||
|
|
||||||
new MochaUI.Window({
|
new MochaUI.Window({
|
||||||
id: "setLocationPage",
|
id: "setLocationPage",
|
||||||
|
@ -624,7 +624,7 @@ const initializeWindows = function() {
|
||||||
const hashes = torrentsTable.selectedRowsIds();
|
const hashes = torrentsTable.selectedRowsIds();
|
||||||
if (hashes.length === 1) {
|
if (hashes.length === 1) {
|
||||||
const hash = hashes[0];
|
const hash = hashes[0];
|
||||||
const row = torrentsTable.rows.get(hash);
|
const row = torrentsTable.getRow(hash);
|
||||||
if (row) {
|
if (row) {
|
||||||
new MochaUI.Window({
|
new MochaUI.Window({
|
||||||
id: "renamePage",
|
id: "renamePage",
|
||||||
|
@ -648,7 +648,7 @@ const initializeWindows = function() {
|
||||||
const hashes = torrentsTable.selectedRowsIds();
|
const hashes = torrentsTable.selectedRowsIds();
|
||||||
if (hashes.length === 1) {
|
if (hashes.length === 1) {
|
||||||
const hash = hashes[0];
|
const hash = hashes[0];
|
||||||
const row = torrentsTable.rows.get(hash);
|
const row = torrentsTable.getRow(hash);
|
||||||
if (row) {
|
if (row) {
|
||||||
new MochaUI.Window({
|
new MochaUI.Window({
|
||||||
id: "multiRenamePage",
|
id: "multiRenamePage",
|
||||||
|
@ -1265,7 +1265,7 @@ const initializeWindows = function() {
|
||||||
exportTorrentFN = async function() {
|
exportTorrentFN = async function() {
|
||||||
const hashes = torrentsTable.selectedRowsIds();
|
const hashes = torrentsTable.selectedRowsIds();
|
||||||
for (const hash of hashes) {
|
for (const hash of hashes) {
|
||||||
const row = torrentsTable.rows.get(hash);
|
const row = torrentsTable.getRow(hash);
|
||||||
if (!row)
|
if (!row)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -536,7 +536,7 @@ window.qBittorrent.PropFiles ??= (() => {
|
||||||
const rowId = torrentFilesTable.selectedRowsIds()[0];
|
const rowId = torrentFilesTable.selectedRowsIds()[0];
|
||||||
if (rowId === undefined)
|
if (rowId === undefined)
|
||||||
return;
|
return;
|
||||||
const row = torrentFilesTable.rows[rowId];
|
const row = torrentFilesTable.rows.get(rowId);
|
||||||
if (!row)
|
if (!row)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -352,7 +352,7 @@ window.qBittorrent.Search ??= (() => {
|
||||||
searchResultsTable.reselectRows(rowsToSelect);
|
searchResultsTable.reselectRows(rowsToSelect);
|
||||||
|
|
||||||
$("numSearchResultsVisible").textContent = searchResultsTable.getFilteredAndSortedRows().length;
|
$("numSearchResultsVisible").textContent = searchResultsTable.getFilteredAndSortedRows().length;
|
||||||
$("numSearchResultsTotal").textContent = searchResultsTable.getRowIds().length;
|
$("numSearchResultsTotal").textContent = searchResultsTable.getRowSize();
|
||||||
|
|
||||||
setupSearchTableEvents(true);
|
setupSearchTableEvents(true);
|
||||||
};
|
};
|
||||||
|
@ -445,15 +445,14 @@ window.qBittorrent.Search ??= (() => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const openSearchTorrentDescriptionUrl = function() {
|
const openSearchTorrentDescriptionUrl = function() {
|
||||||
searchResultsTable.selectedRowsIds().each((rowId) => {
|
for (const rowID of searchResultsTable.selectedRowsIds())
|
||||||
window.open(searchResultsTable.rows.get(rowId).full_data.descrLink, "_blank");
|
window.open(searchResultsTable.getRow(rowID).full_data.descrLink, "_blank");
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const copySearchTorrentName = function() {
|
const copySearchTorrentName = function() {
|
||||||
const names = [];
|
const names = [];
|
||||||
searchResultsTable.selectedRowsIds().each((rowId) => {
|
searchResultsTable.selectedRowsIds().each((rowId) => {
|
||||||
names.push(searchResultsTable.rows.get(rowId).full_data.fileName);
|
names.push(searchResultsTable.getRow(rowId).full_data.fileName);
|
||||||
});
|
});
|
||||||
return names.join("\n");
|
return names.join("\n");
|
||||||
};
|
};
|
||||||
|
@ -461,7 +460,7 @@ window.qBittorrent.Search ??= (() => {
|
||||||
const copySearchTorrentDownloadLink = function() {
|
const copySearchTorrentDownloadLink = function() {
|
||||||
const urls = [];
|
const urls = [];
|
||||||
searchResultsTable.selectedRowsIds().each((rowId) => {
|
searchResultsTable.selectedRowsIds().each((rowId) => {
|
||||||
urls.push(searchResultsTable.rows.get(rowId).full_data.fileUrl);
|
urls.push(searchResultsTable.getRow(rowId).full_data.fileUrl);
|
||||||
});
|
});
|
||||||
return urls.join("\n");
|
return urls.join("\n");
|
||||||
};
|
};
|
||||||
|
@ -469,16 +468,15 @@ window.qBittorrent.Search ??= (() => {
|
||||||
const copySearchTorrentDescriptionUrl = function() {
|
const copySearchTorrentDescriptionUrl = function() {
|
||||||
const urls = [];
|
const urls = [];
|
||||||
searchResultsTable.selectedRowsIds().each((rowId) => {
|
searchResultsTable.selectedRowsIds().each((rowId) => {
|
||||||
urls.push(searchResultsTable.rows.get(rowId).full_data.descrLink);
|
urls.push(searchResultsTable.getRow(rowId).full_data.descrLink);
|
||||||
});
|
});
|
||||||
return urls.join("\n");
|
return urls.join("\n");
|
||||||
};
|
};
|
||||||
|
|
||||||
const downloadSearchTorrent = function() {
|
const downloadSearchTorrent = function() {
|
||||||
const urls = [];
|
const urls = [];
|
||||||
searchResultsTable.selectedRowsIds().each((rowId) => {
|
for (const rowID of searchResultsTable.selectedRowsIds())
|
||||||
urls.push(searchResultsTable.rows.get(rowId).full_data.fileUrl);
|
urls.push(searchResultsTable.getRow(rowID).full_data.fileUrl);
|
||||||
});
|
|
||||||
|
|
||||||
// only proceed if at least 1 row was selected
|
// only proceed if at least 1 row was selected
|
||||||
if (!urls.length)
|
if (!urls.length)
|
||||||
|
@ -836,7 +834,7 @@ window.qBittorrent.Search ??= (() => {
|
||||||
searchResultsTable.updateRowData(row);
|
searchResultsTable.updateRowData(row);
|
||||||
|
|
||||||
$("numSearchResultsVisible").textContent = searchResultsTable.getFilteredAndSortedRows().length;
|
$("numSearchResultsVisible").textContent = searchResultsTable.getFilteredAndSortedRows().length;
|
||||||
$("numSearchResultsTotal").textContent = searchResultsTable.getRowIds().length;
|
$("numSearchResultsTotal").textContent = searchResultsTable.getRowSize();
|
||||||
|
|
||||||
searchResultsTable.updateTable();
|
searchResultsTable.updateTable();
|
||||||
}
|
}
|
||||||
|
|
|
@ -332,7 +332,7 @@
|
||||||
curTab = currentSelectedTab;
|
curTab = currentSelectedTab;
|
||||||
|
|
||||||
$("numFilteredLogs").textContent = tableInfo[curTab].instance.filteredLength();
|
$("numFilteredLogs").textContent = tableInfo[curTab].instance.filteredLength();
|
||||||
$("numTotalLogs").textContent = tableInfo[curTab].instance.getRowIds().length;
|
$("numTotalLogs").textContent = tableInfo[curTab].instance.getRowSize();
|
||||||
};
|
};
|
||||||
|
|
||||||
const syncLogData = (curTab) => {
|
const syncLogData = (curTab) => {
|
||||||
|
@ -413,8 +413,8 @@
|
||||||
new ClipboardJS(".copyLogDataToClipboard", {
|
new ClipboardJS(".copyLogDataToClipboard", {
|
||||||
text: function() {
|
text: function() {
|
||||||
const msg = [];
|
const msg = [];
|
||||||
tableInfo[currentSelectedTab].instance.selectedRowsIds().each((rowId) => {
|
tableInfo[currentSelectedTab].instance.selectedRowsIds().forEach((rowId) => {
|
||||||
msg.push(tableInfo[currentSelectedTab].instance.rows.get(rowId).full_data[(currentSelectedTab === "main") ? "message" : "ip"]);
|
msg.push(tableInfo[currentSelectedTab].instance.getRow(rowId).full_data[(currentSelectedTab === "main") ? "message" : "ip"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
return msg.join("\n");
|
return msg.join("\n");
|
||||||
|
|
|
@ -223,22 +223,23 @@
|
||||||
actions: {
|
actions: {
|
||||||
update: (el) => {
|
update: (el) => {
|
||||||
const feedsToUpdate = new Set();
|
const feedsToUpdate = new Set();
|
||||||
rssFeedTable.selectedRows.each((rowId) => {
|
for (const rowId of rssFeedTable.selectedRows) {
|
||||||
const selectedPath = rssFeedTable.rows[rowId].full_data.dataPath;
|
const selectedPath = rssFeedTable.getRow(rowId).full_data.dataPath;
|
||||||
rssFeedTable.rows.filter((row) => row.full_data.dataPath.slice(0, selectedPath.length) === selectedPath)
|
for (const row of rssFeedTable.getRowValues()) {
|
||||||
.filter((row) => row.full_data.dataUid !== "")
|
if ((row.full_data.dataPath.slice(0, selectedPath.length) === selectedPath) && (row.full_data.dataUid !== ""))
|
||||||
.each((row) => feedsToUpdate.add(row));
|
feedsToUpdate.add(row);
|
||||||
});
|
}
|
||||||
|
};
|
||||||
feedsToUpdate.forEach((feed) => refreshFeed(feed.full_data.dataUid));
|
feedsToUpdate.forEach((feed) => refreshFeed(feed.full_data.dataUid));
|
||||||
},
|
},
|
||||||
markRead: markSelectedAsRead,
|
markRead: markSelectedAsRead,
|
||||||
rename: (el) => {
|
rename: (el) => {
|
||||||
moveItem(rssFeedTable.rows[rssFeedTable.selectedRows[0]].full_data.dataPath);
|
moveItem(rssFeedTable.getRow(rssFeedTable.selectedRows[0]).full_data.dataPath);
|
||||||
},
|
},
|
||||||
delete: (el) => {
|
delete: (el) => {
|
||||||
const selectedDatapaths = rssFeedTable.selectedRows
|
const selectedDatapaths = rssFeedTable.selectedRows
|
||||||
.filter((e) => e !== 0)
|
.filter((rowID) => rowID !== "0")
|
||||||
.map((sRow) => rssFeedTable.rows[sRow].full_data.dataPath);
|
.map((rowID) => rssFeedTable.getRow(rowID).full_data.dataPath);
|
||||||
// filter children
|
// filter children
|
||||||
const reducedDatapaths = selectedDatapaths.filter((path) =>
|
const reducedDatapaths = selectedDatapaths.filter((path) =>
|
||||||
selectedDatapaths.filter((innerPath) => path.slice(0, innerPath.length) === innerPath).length === 1
|
selectedDatapaths.filter((innerPath) => path.slice(0, innerPath.length) === innerPath).length === 1
|
||||||
|
@ -262,7 +263,7 @@
|
||||||
rssFeedTable.deselectRow();
|
rssFeedTable.deselectRow();
|
||||||
});
|
});
|
||||||
$("rssFeedTableDiv").addEventListener("contextmenu", (e) => {
|
$("rssFeedTableDiv").addEventListener("contextmenu", (e) => {
|
||||||
if (e.toElement.nodeName === "DIV") {
|
if (e.target.nodeName === "DIV") {
|
||||||
rssFeedTable.deselectAll();
|
rssFeedTable.deselectAll();
|
||||||
rssFeedTable.deselectRow();
|
rssFeedTable.deselectRow();
|
||||||
rssFeedContextMenu.updateMenuItems();
|
rssFeedContextMenu.updateMenuItems();
|
||||||
|
@ -272,9 +273,11 @@
|
||||||
new ClipboardJS("#CopyFeedURL", {
|
new ClipboardJS("#CopyFeedURL", {
|
||||||
text: () => {
|
text: () => {
|
||||||
let joined = "";
|
let joined = "";
|
||||||
rssFeedTable.selectedRows
|
for (const rowID of rssFeedTable.selectedRows) {
|
||||||
.filter((row) => rssFeedTable.rows[row].full_data.dataUid !== "")
|
const row = rssFeedTable.getRow(rowID);
|
||||||
.each((row) => joined += rssFeedTable.rows[row].full_data.dataUrl + "\n");
|
if (row.full_data.dataUid !== "")
|
||||||
|
joined += `${row.full_data.dataUrl}\n`;
|
||||||
|
}
|
||||||
return joined.slice(0, -1);
|
return joined.slice(0, -1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -286,15 +289,13 @@
|
||||||
actions: {
|
actions: {
|
||||||
Download: (el) => {
|
Download: (el) => {
|
||||||
let dlString = "";
|
let dlString = "";
|
||||||
rssArticleTable.selectedRows.each((row) => {
|
for (const rowID of rssArticleTable.selectedRows)
|
||||||
dlString += rssArticleTable.rows[row].full_data.torrentURL + "\n";
|
dlString += `${rssArticleTable.getRow(rowID).full_data.torrentURL}\n`;
|
||||||
});
|
|
||||||
showDownloadPage([dlString]);
|
showDownloadPage([dlString]);
|
||||||
},
|
},
|
||||||
OpenNews: (el) => {
|
OpenNews: (el) => {
|
||||||
rssArticleTable.selectedRows.each((row) => {
|
for (const rowID of rssArticleTable.selectedRows)
|
||||||
window.open(rssArticleTable.rows[row].full_data.link);
|
window.open(rssArticleTable.getRow(rowID).full_data.link);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offsets: {
|
offsets: {
|
||||||
|
@ -322,7 +323,7 @@
|
||||||
const addRSSFeed = () => {
|
const addRSSFeed = () => {
|
||||||
let path = "";
|
let path = "";
|
||||||
if (rssFeedTable.selectedRows.length !== 0) {
|
if (rssFeedTable.selectedRows.length !== 0) {
|
||||||
const row = rssFeedTable.rows[rssFeedTable.selectedRows[0]];
|
const row = rssFeedTable.getRow(rssFeedTable.selectedRows[0]);
|
||||||
if (row.full_data.dataUid === "") {
|
if (row.full_data.dataUid === "") {
|
||||||
path = row.full_data.dataPath;
|
path = row.full_data.dataPath;
|
||||||
}
|
}
|
||||||
|
@ -350,7 +351,7 @@
|
||||||
const addFolder = () => {
|
const addFolder = () => {
|
||||||
let path = "";
|
let path = "";
|
||||||
if (rssFeedTable.selectedRows.length !== 0) {
|
if (rssFeedTable.selectedRows.length !== 0) {
|
||||||
const row = rssFeedTable.rows[rssFeedTable.selectedRows[0]];
|
const row = rssFeedTable.getRow(rssFeedTable.selectedRows[0]);
|
||||||
if (row.full_data.dataUid === "") {
|
if (row.full_data.dataUid === "") {
|
||||||
path = row.full_data.dataPath;
|
path = row.full_data.dataPath;
|
||||||
}
|
}
|
||||||
|
@ -380,9 +381,10 @@
|
||||||
let rowCount = 0;
|
let rowCount = 0;
|
||||||
|
|
||||||
const childFeeds = new Set();
|
const childFeeds = new Set();
|
||||||
rssFeedTable.rows.filter((row) => row.full_data.dataPath.slice(0, path.length) === path)
|
for (const row of rssFeedTable.getRowValues()) {
|
||||||
.filter((row) => row.full_data.dataUid !== "")
|
if ((row.full_data.dataPath.slice(0, path.length) === path) && (row.full_data.dataUid !== ""))
|
||||||
.each((row) => childFeeds.add(row.full_data.dataUid));
|
childFeeds.add(row.full_data.dataUid);
|
||||||
|
}
|
||||||
|
|
||||||
let visibleArticles = [];
|
let visibleArticles = [];
|
||||||
for (const feedEntry in feedData) {
|
for (const feedEntry in feedData) {
|
||||||
|
@ -490,12 +492,14 @@
|
||||||
recFlatten(response);
|
recFlatten(response);
|
||||||
|
|
||||||
// check if rows matches flattened response
|
// check if rows matches flattened response
|
||||||
|
const rssFeedRows = [...rssFeedTable.getRowValues()];
|
||||||
let match = false;
|
let match = false;
|
||||||
if ((rssFeedTable.rows.getLength() - 1) === flattenedResp.length) {
|
// subtract 'unread' row
|
||||||
|
if ((rssFeedRows.length - 1) === flattenedResp.length) {
|
||||||
match = true;
|
match = true;
|
||||||
for (let i = 0; i < flattenedResp.length; ++i) {
|
for (let i = 0; i < flattenedResp.length; ++i) {
|
||||||
if (((flattenedResp[i].uid ? flattenedResp[i].uid : "") !== rssFeedTable.rows[i + 1].full_data.dataUid)
|
if (((flattenedResp[i].uid ? flattenedResp[i].uid : "") !== rssFeedRows[i + 1].full_data.dataUid)
|
||||||
|| (flattenedResp[i].fullName !== rssFeedTable.rows[i + 1].full_data.dataPath)) {
|
|| (flattenedResp[i].fullName !== rssFeedRows[i + 1].full_data.dataPath)) {
|
||||||
match = false;
|
match = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -507,7 +511,7 @@
|
||||||
// update status
|
// update status
|
||||||
let statusDiffers = false;
|
let statusDiffers = false;
|
||||||
for (let i = 0; i < flattenedResp.length; ++i) {
|
for (let i = 0; i < flattenedResp.length; ++i) {
|
||||||
const oldStatus = rssFeedTable.rows[i + 1].full_data.status;
|
const oldStatus = rssFeedRows[i + 1].full_data.status;
|
||||||
let status = "default";
|
let status = "default";
|
||||||
if (flattenedResp[i].hasError)
|
if (flattenedResp[i].hasError)
|
||||||
status = "hasError";
|
status = "hasError";
|
||||||
|
@ -530,8 +534,8 @@
|
||||||
// get currently opened feed
|
// get currently opened feed
|
||||||
let openedFeedPath = undefined;
|
let openedFeedPath = undefined;
|
||||||
if (rssFeedTable.selectedRows.length !== 0) {
|
if (rssFeedTable.selectedRows.length !== 0) {
|
||||||
const lastSelectedRow = rssFeedTable.selectedRows[rssFeedTable.selectedRows.length - 1];
|
const lastSelectedRow = rssFeedTable.selectedRows.at(-1);
|
||||||
openedFeedPath = rssFeedTable.rows[lastSelectedRow].full_data.dataPath;
|
openedFeedPath = rssFeedTable.getRow(lastSelectedRow).full_data.dataPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if list of articles differs
|
// check if list of articles differs
|
||||||
|
@ -554,8 +558,11 @@
|
||||||
const unreadDifference = newUnread - oldUnread;
|
const unreadDifference = newUnread - oldUnread;
|
||||||
|
|
||||||
// find all parents (and self) and add unread difference
|
// find all parents (and self) and add unread difference
|
||||||
rssFeedTable.rows.filter((row) => r.fullName.slice(0, row.full_data.dataPath.length) === row.full_data.dataPath)
|
for (const row of rssFeedTable.getRowValues()) {
|
||||||
.each((row) => row.full_data.unread += unreadDifference);
|
if (r.fullName.slice(0, row.full_data.dataPath.length) === row.full_data.dataPath)
|
||||||
|
row.full_data.unread += unreadDifference;
|
||||||
|
}
|
||||||
|
|
||||||
needsUpdate = true;
|
needsUpdate = true;
|
||||||
|
|
||||||
// update data
|
// update data
|
||||||
|
@ -582,15 +589,20 @@
|
||||||
if (readChanged) {
|
if (readChanged) {
|
||||||
needsUpdate = true;
|
needsUpdate = true;
|
||||||
// find all items that contain this rss feed and add read difference
|
// find all items that contain this rss feed and add read difference
|
||||||
rssFeedTable.rows.filter((row) => r.fullName.slice(0, row.full_data.dataPath.length) === row.full_data.dataPath)
|
for (const row of rssFeedTable.getRowValues()) {
|
||||||
.each((row) => row.full_data.unread += readDifference);
|
if (r.fullName.slice(0, row.full_data.dataPath.length) === row.full_data.dataPath)
|
||||||
|
row.full_data.unread += readDifference;
|
||||||
|
}
|
||||||
|
|
||||||
// if feed that is opened changed update dynamically
|
// if feed that is opened changed update dynamically
|
||||||
if ((openedFeedPath !== undefined) && (r.fullName.slice(0, openedFeedPath.length) === openedFeedPath)) {
|
if ((openedFeedPath !== undefined) && (r.fullName.slice(0, openedFeedPath.length) === openedFeedPath)) {
|
||||||
for (let i = 0; i < r.articles.length; ++i) {
|
for (let i = 0; i < r.articles.length; ++i) {
|
||||||
const matchingRow = rssArticleTable.rows.filter((row) => row.full_data.feedUid === r.uid)
|
for (const row of rssArticleTable.getRowValues()) {
|
||||||
.filter((row) => row.full_data.dataId === r.articles[i].id);
|
if ((row.full_data.feedUid === r.uid) && (row.full_data.dataId === r.articles[i].id)) {
|
||||||
matchingRow[Object.keys(matchingRow)[0]].full_data.isRead = r.articles[i].isRead;
|
row.full_data.isRead = r.articles[i].isRead;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -605,6 +617,7 @@
|
||||||
else {
|
else {
|
||||||
// full refresh
|
// full refresh
|
||||||
rssFeedTable.clear();
|
rssFeedTable.clear();
|
||||||
|
rssArticleTable.clear();
|
||||||
feedData = {};
|
feedData = {};
|
||||||
pathByFeedId = new Map();
|
pathByFeedId = new Map();
|
||||||
|
|
||||||
|
@ -655,8 +668,10 @@
|
||||||
// calculate number of unread
|
// calculate number of unread
|
||||||
const numberOfUnread = dataEntry.articles.map((art) => !art.isRead).filter((v) => v).length;
|
const numberOfUnread = dataEntry.articles.map((art) => !art.isRead).filter((v) => v).length;
|
||||||
// find all items that contain this rss feed and add unread count
|
// find all items that contain this rss feed and add unread count
|
||||||
rssFeedTable.rows.filter((row) => dataEntry.fullName.slice(0, row.full_data.dataPath.length) === row.full_data.dataPath)
|
for (const row of rssFeedTable.getRowValues()) {
|
||||||
.each((row) => row.full_data.unread += numberOfUnread);
|
if (dataEntry.fullName.slice(0, row.full_data.dataPath.length) === row.full_data.dataPath)
|
||||||
|
row.full_data.unread += numberOfUnread;
|
||||||
|
}
|
||||||
|
|
||||||
pathByFeedId.set(dataEntry.uid, dataEntry.fullName);
|
pathByFeedId.set(dataEntry.uid, dataEntry.fullName);
|
||||||
feedData[dataEntry.uid] = dataEntry.articles;
|
feedData[dataEntry.uid] = dataEntry.articles;
|
||||||
|
@ -672,10 +687,10 @@
|
||||||
|
|
||||||
const refreshFeed = (feedUid) => {
|
const refreshFeed = (feedUid) => {
|
||||||
// set icon to loading
|
// set icon to loading
|
||||||
rssFeedTable.rows.forEach((row) => {
|
for (const row of rssFeedTable.getRowValues()) {
|
||||||
if (row.full_data.dataUid === feedUid)
|
if (row.full_data.dataUid === feedUid)
|
||||||
row.full_data.status = "isLoading";
|
row.full_data.status = "isLoading";
|
||||||
});
|
}
|
||||||
rssFeedTable.updateIcons();
|
rssFeedTable.updateIcons();
|
||||||
|
|
||||||
new Request({
|
new Request({
|
||||||
|
@ -738,24 +753,29 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// mark rows as read
|
// mark rows as read
|
||||||
rssArticleTable.rows.each((el) => el.full_data.isRead = true);
|
for (const row of rssArticleTable.getRowValues())
|
||||||
|
row.full_data.isRead = true;
|
||||||
|
|
||||||
// find all children and set unread count to 0
|
// find all children and set unread count to 0
|
||||||
rssFeedTable.rows.filter((row) => (row.full_data.dataPath.slice(0, path.length) === path) && (path !== row.full_data.dataPath))
|
for (const row of rssFeedTable.getRowValues()) {
|
||||||
.each((row) => row.full_data.unread = 0);
|
if ((row.full_data.dataPath.slice(0, path.length) === path) && (path !== row.full_data.dataPath))
|
||||||
|
row.full_data.unread = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// find selected row
|
// find selected row
|
||||||
let rowId, prevUnreadCount;
|
let rowId, prevUnreadCount;
|
||||||
rssFeedTable.rows.forEach((row) => {
|
for (const row of rssFeedTable.getRowValues()) {
|
||||||
if (row.full_data.dataPath === path) {
|
if (row.full_data.dataPath === path) {
|
||||||
rowId = row.full_data.rowId;
|
rowId = row.full_data.rowId;
|
||||||
prevUnreadCount = row.full_data.unread;
|
prevUnreadCount = row.full_data.unread;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
// find all parents (and self) and subtract previous unread count
|
// find all parents (and self) and subtract previous unread count
|
||||||
rssFeedTable.rows.filter((row) => path.slice(0, row.full_data.dataPath.length) === row.full_data.dataPath)
|
for (const row of rssFeedTable.getRowValues()) {
|
||||||
.each((row) => row.full_data.unread -= prevUnreadCount);
|
if (path.slice(0, row.full_data.dataPath.length) === row.full_data.dataPath)
|
||||||
|
row.full_data.unread -= prevUnreadCount;
|
||||||
|
}
|
||||||
|
|
||||||
rssArticleTable.updateTable(false);
|
rssArticleTable.updateTable(false);
|
||||||
rssFeedTable.updateTable(true);
|
rssFeedTable.updateTable(true);
|
||||||
|
@ -777,14 +797,15 @@
|
||||||
const markArticleAsRead = (path, id) => {
|
const markArticleAsRead = (path, id) => {
|
||||||
// find row
|
// find row
|
||||||
let rowId, name, uid, unread;
|
let rowId, name, uid, unread;
|
||||||
rssFeedTable.rows.forEach((row) => {
|
for (const row of rssFeedTable.getRowValues()) {
|
||||||
if (row.full_data.dataPath === path) {
|
if (row.full_data.dataPath === path) {
|
||||||
rowId = row.full_data.rowId;
|
rowId = row.full_data.rowId;
|
||||||
name = row.full_data.dataPath;
|
name = row.full_data.dataPath;
|
||||||
uid = row.full_data.dataUid;
|
uid = row.full_data.dataUid;
|
||||||
unread = row.full_data.unread;
|
unread = row.full_data.unread;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
// update feed data
|
// update feed data
|
||||||
let prevReadState = true;
|
let prevReadState = true;
|
||||||
feedData[uid].each((article) => {
|
feedData[uid].each((article) => {
|
||||||
|
@ -796,8 +817,10 @@
|
||||||
|
|
||||||
if (!prevReadState) {
|
if (!prevReadState) {
|
||||||
// find all items that contain this feed and subtract 1
|
// find all items that contain this feed and subtract 1
|
||||||
rssFeedTable.rows.filter((row) => path.slice(0, row.full_data.dataPath.length) === row.full_data.dataPath)
|
for (const row of rssFeedTable.getRowValues()) {
|
||||||
.each((row) => row.full_data.unread -= 1);
|
if (path.slice(0, row.full_data.dataPath.length) === row.full_data.dataPath)
|
||||||
|
row.full_data.unread -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
rssFeedTable.updateTable(true);
|
rssFeedTable.updateTable(true);
|
||||||
|
|
||||||
|
@ -818,7 +841,7 @@
|
||||||
|
|
||||||
const markSelectedAsRead = () => {
|
const markSelectedAsRead = () => {
|
||||||
const selectedDatapaths = rssFeedTable.selectedRows
|
const selectedDatapaths = rssFeedTable.selectedRows
|
||||||
.map((sRow) => rssFeedTable.rows[sRow].full_data.dataPath);
|
.map((sRow) => rssFeedTable.getRow(sRow).full_data.dataPath);
|
||||||
// filter children
|
// filter children
|
||||||
const reducedDatapaths = selectedDatapaths.filter((path) =>
|
const reducedDatapaths = selectedDatapaths.filter((path) =>
|
||||||
selectedDatapaths.filter((innerPath) => path.slice(0, innerPath.length) === innerPath).length === 1
|
selectedDatapaths.filter((innerPath) => path.slice(0, innerPath.length) === innerPath).length === 1
|
||||||
|
|
|
@ -404,11 +404,11 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
|
||||||
addRule: addRule,
|
addRule: addRule,
|
||||||
deleteRule: removeSelectedRule,
|
deleteRule: removeSelectedRule,
|
||||||
renameRule: (el) => {
|
renameRule: (el) => {
|
||||||
renameRule(rssDownloaderRulesTable.rows[rssDownloaderRulesTable.selectedRows[0]].full_data.name);
|
renameRule(rssDownloaderRulesTable.getRow(rssDownloaderRulesTable.selectedRows[0]).full_data.name);
|
||||||
},
|
},
|
||||||
clearDownloadedEpisodes: (el) => {
|
clearDownloadedEpisodes: (el) => {
|
||||||
clearDownloadedEpisodes(rssDownloaderRulesTable.selectedRows
|
clearDownloadedEpisodes(rssDownloaderRulesTable.selectedRows
|
||||||
.map((sRow) => rssDownloaderRulesTable.rows[sRow].full_data.name));
|
.map((sRow) => rssDownloaderRulesTable.getRow(sRow).full_data.name));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offsets: {
|
offsets: {
|
||||||
|
@ -552,7 +552,7 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
|
||||||
if (rssDownloaderRulesTable.selectedRows.length === 0)
|
if (rssDownloaderRulesTable.selectedRows.length === 0)
|
||||||
return;
|
return;
|
||||||
removeRules(rssDownloaderRulesTable.selectedRows.map((sRow) =>
|
removeRules(rssDownloaderRulesTable.selectedRows.map((sRow) =>
|
||||||
rssDownloaderRulesTable.rows[sRow].full_data.name));
|
rssDownloaderRulesTable.getRow(sRow).full_data.name));
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeRules = (rules) => {
|
const removeRules = (rules) => {
|
||||||
|
@ -588,8 +588,8 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
|
||||||
};
|
};
|
||||||
|
|
||||||
const saveSettings = () => {
|
const saveSettings = () => {
|
||||||
const lastSelectedRow = rssDownloaderRulesTable.selectedRows[rssDownloaderRulesTable.selectedRows.length - 1];
|
const lastSelectedRow = rssDownloaderRulesTable.selectedRows.at(-1);
|
||||||
const rule = rssDownloaderRulesTable.rows[lastSelectedRow].full_data.name;
|
const rule = rssDownloaderRulesTable.getRow(lastSelectedRow).full_data.name;
|
||||||
|
|
||||||
rulesList[rule].useRegex = $("useRegEx").checked;
|
rulesList[rule].useRegex = $("useRegEx").checked;
|
||||||
rulesList[rule].mustContain = $("mustContainText").value;
|
rulesList[rule].mustContain = $("mustContainText").value;
|
||||||
|
@ -597,9 +597,9 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
|
||||||
rulesList[rule].episodeFilter = $("episodeFilterText").value;
|
rulesList[rule].episodeFilter = $("episodeFilterText").value;
|
||||||
rulesList[rule].smartFilter = $("useSmartFilter").checked;
|
rulesList[rule].smartFilter = $("useSmartFilter").checked;
|
||||||
rulesList[rule].ignoreDays = parseInt($("ignoreDaysValue").value, 10);
|
rulesList[rule].ignoreDays = parseInt($("ignoreDaysValue").value, 10);
|
||||||
rulesList[rule].affectedFeeds = rssDownloaderFeedSelectionTable.rows.filter((row) => row.full_data.checked)
|
rulesList[rule].affectedFeeds = [...rssDownloaderFeedSelectionTable.getRowValues()]
|
||||||
.map((row) => row.full_data.url)
|
.filter((row) => row.full_data.checked)
|
||||||
.getValues();
|
.map((row) => row.full_data.url);
|
||||||
|
|
||||||
rulesList[rule].torrentParams.category = $("assignCategoryCombobox").value;
|
rulesList[rule].torrentParams.category = $("assignCategoryCombobox").value;
|
||||||
rulesList[rule].torrentParams.tags = $("ruleAddTags").value.split(",");
|
rulesList[rule].torrentParams.tags = $("ruleAddTags").value.split(",");
|
||||||
|
|
|
@ -202,7 +202,7 @@
|
||||||
// clear event listeners
|
// clear event listeners
|
||||||
setupSearchPluginTableEvents(false);
|
setupSearchPluginTableEvents(false);
|
||||||
|
|
||||||
const oldPlugins = Object.keys(searchPluginsTable.rows);
|
const oldPlugins = [...searchPluginsTable.getRowIds()];
|
||||||
// remove old rows from the table
|
// remove old rows from the table
|
||||||
for (let i = 0; i < oldPlugins.length; ++i) {
|
for (let i = 0; i < oldPlugins.length; ++i) {
|
||||||
let found = false;
|
let found = false;
|
||||||
|
|
Loading…
Reference in a new issue