mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-12 08:16:16 -07:00
WebUI: enforce usage of const
whenever possible
This commit is contained in:
parent
cb90b6769c
commit
55bff4f07a
12 changed files with 102 additions and 100 deletions
|
@ -29,6 +29,8 @@ export default [
|
|||
"eqeqeq": "error",
|
||||
"no-undef": "off",
|
||||
"no-unused-vars": "off",
|
||||
"no-var": "error",
|
||||
"prefer-const": "error",
|
||||
"Stylistic/no-mixed-operators": [
|
||||
"error",
|
||||
{
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
}
|
||||
window.qBittorrent = window.parent.qBittorrent;
|
||||
|
||||
var TriState = window.qBittorrent.FileTree.TriState;
|
||||
var data = window.MUI.Windows.instances["multiRenamePage"].options.data;
|
||||
var bulkRenameFilesContextMenu;
|
||||
const TriState = window.qBittorrent.FileTree.TriState;
|
||||
const data = window.MUI.Windows.instances["multiRenamePage"].options.data;
|
||||
let bulkRenameFilesContextMenu;
|
||||
if (!bulkRenameFilesContextMenu) {
|
||||
bulkRenameFilesContextMenu = new window.qBittorrent.ContextMenu.ContextMenu({
|
||||
targets: "#bulkRenameFilesTableDiv tr",
|
||||
|
@ -44,12 +44,12 @@
|
|||
}
|
||||
|
||||
// Setup the dynamic table for bulk renaming
|
||||
var bulkRenameFilesTable = new window.qBittorrent.DynamicTable.BulkRenameTorrentFilesTable();
|
||||
const bulkRenameFilesTable = new window.qBittorrent.DynamicTable.BulkRenameTorrentFilesTable();
|
||||
bulkRenameFilesTable.setup("bulkRenameFilesTableDiv", "bulkRenameFilesTableFixedHeaderDiv", bulkRenameFilesContextMenu);
|
||||
|
||||
// Inject checkbox into the first column of the table header
|
||||
var tableHeaders = $$("#bulkRenameFilesTableFixedHeaderDiv .dynamicTableHeader th");
|
||||
var checkboxHeader;
|
||||
const tableHeaders = $$("#bulkRenameFilesTableFixedHeaderDiv .dynamicTableHeader th");
|
||||
let checkboxHeader;
|
||||
if (tableHeaders.length > 0) {
|
||||
if (checkboxHeader) {
|
||||
checkboxHeader.remove();
|
||||
|
@ -69,7 +69,7 @@
|
|||
|
||||
// Register keyboard events to modal window
|
||||
// https://github.com/qbittorrent/qBittorrent/pull/18687#discussion_r1135045726
|
||||
var keyboard;
|
||||
let keyboard;
|
||||
if (!keyboard) {
|
||||
keyboard = new Keyboard({
|
||||
defaultEventType: "keydown",
|
||||
|
@ -87,53 +87,53 @@
|
|||
keyboard.activate();
|
||||
}
|
||||
|
||||
var fileRenamer = new window.qBittorrent.MultiRename.RenameFiles();
|
||||
const fileRenamer = new window.qBittorrent.MultiRename.RenameFiles();
|
||||
fileRenamer.hash = data.hash;
|
||||
|
||||
// Load Multi Rename Preferences
|
||||
var multiRenamePrefChecked = LocalPreferences.get("multirename_rememberPreferences", "true") === "true";
|
||||
const multiRenamePrefChecked = LocalPreferences.get("multirename_rememberPreferences", "true") === "true";
|
||||
$("multirename_rememberprefs_checkbox").setProperty("checked", multiRenamePrefChecked);
|
||||
|
||||
if (multiRenamePrefChecked) {
|
||||
var multirename_search = LocalPreferences.get("multirename_search", "");
|
||||
const multirename_search = LocalPreferences.get("multirename_search", "");
|
||||
fileRenamer.setSearch(multirename_search);
|
||||
$("multiRenameSearch").set("value", multirename_search);
|
||||
|
||||
var multirename_useRegex = LocalPreferences.get("multirename_useRegex", false);
|
||||
const multirename_useRegex = LocalPreferences.get("multirename_useRegex", false);
|
||||
fileRenamer.useRegex = multirename_useRegex === "true";
|
||||
$("use_regex_search").checked = fileRenamer.useRegex;
|
||||
|
||||
var multirename_matchAllOccurrences = LocalPreferences.get("multirename_matchAllOccurrences", false);
|
||||
const multirename_matchAllOccurrences = LocalPreferences.get("multirename_matchAllOccurrences", false);
|
||||
fileRenamer.matchAllOccurrences = multirename_matchAllOccurrences === "true";
|
||||
$("match_all_occurrences").checked = fileRenamer.matchAllOccurrences;
|
||||
|
||||
var multirename_caseSensitive = LocalPreferences.get("multirename_caseSensitive", false);
|
||||
const multirename_caseSensitive = LocalPreferences.get("multirename_caseSensitive", false);
|
||||
fileRenamer.caseSensitive = multirename_caseSensitive === "true";
|
||||
$("case_sensitive").checked = fileRenamer.caseSensitive;
|
||||
|
||||
var multirename_replace = LocalPreferences.get("multirename_replace", "");
|
||||
const multirename_replace = LocalPreferences.get("multirename_replace", "");
|
||||
fileRenamer.setReplacement(multirename_replace);
|
||||
$("multiRenameReplace").set("value", multirename_replace);
|
||||
|
||||
var multirename_appliesTo = LocalPreferences.get("multirename_appliesTo", window.qBittorrent.MultiRename.AppliesTo.FilenameExtension);
|
||||
const multirename_appliesTo = LocalPreferences.get("multirename_appliesTo", window.qBittorrent.MultiRename.AppliesTo.FilenameExtension);
|
||||
fileRenamer.appliesTo = window.qBittorrent.MultiRename.AppliesTo[multirename_appliesTo];
|
||||
$("applies_to_option").set("value", fileRenamer.appliesTo);
|
||||
|
||||
var multirename_includeFiles = LocalPreferences.get("multirename_includeFiles", true);
|
||||
const multirename_includeFiles = LocalPreferences.get("multirename_includeFiles", true);
|
||||
fileRenamer.includeFiles = multirename_includeFiles === "true";
|
||||
$("include_files").checked = fileRenamer.includeFiles;
|
||||
|
||||
var multirename_includeFolders = LocalPreferences.get("multirename_includeFolders", false);
|
||||
const multirename_includeFolders = LocalPreferences.get("multirename_includeFolders", false);
|
||||
fileRenamer.includeFolders = multirename_includeFolders === "true";
|
||||
$("include_folders").checked = fileRenamer.includeFolders;
|
||||
|
||||
var multirename_fileEnumerationStart = LocalPreferences.get("multirename_fileEnumerationStart", 0);
|
||||
const multirename_fileEnumerationStart = LocalPreferences.get("multirename_fileEnumerationStart", 0);
|
||||
fileRenamer.fileEnumerationStart = parseInt(multirename_fileEnumerationStart);
|
||||
$("file_counter").set("value", fileRenamer.fileEnumerationStart);
|
||||
|
||||
var multirename_replaceAll = LocalPreferences.get("multirename_replaceAll", false);
|
||||
const multirename_replaceAll = LocalPreferences.get("multirename_replaceAll", false);
|
||||
fileRenamer.replaceAll = multirename_replaceAll === "true";
|
||||
var renameButtonValue = fileRenamer.replaceAll ? "Replace All" : "Replace";
|
||||
const renameButtonValue = fileRenamer.replaceAll ? "Replace All" : "Replace";
|
||||
$("renameOptions").set("value", renameButtonValue);
|
||||
$("renameButton").set("value", renameButtonValue);
|
||||
}
|
||||
|
@ -146,7 +146,7 @@
|
|||
|
||||
// Setup Search Events that control renaming
|
||||
$("multiRenameSearch").addEvent("input", function(e) {
|
||||
let sanitized = e.target.value.replace(/\n/g, "");
|
||||
const sanitized = e.target.value.replace(/\n/g, "");
|
||||
$("multiRenameSearch").set("value", sanitized);
|
||||
|
||||
// Search input has changed
|
||||
|
@ -193,7 +193,7 @@
|
|||
|
||||
// Setup Replace Events that control renaming
|
||||
$("multiRenameReplace").addEvent("input", function(e) {
|
||||
let sanitized = e.target.value.replace(/\n/g, "");
|
||||
const sanitized = e.target.value.replace(/\n/g, "");
|
||||
$("multiRenameReplace").set("value", sanitized);
|
||||
|
||||
// Replace input has changed
|
||||
|
@ -265,7 +265,7 @@
|
|||
|
||||
// Recreate table
|
||||
let selectedRows = bulkRenameFilesTable.getSelectedRows().map(row => row.rowId.toString());
|
||||
for (let renamedRow of rows) {
|
||||
for (const renamedRow of rows) {
|
||||
selectedRows = selectedRows.filter(selectedRow => selectedRow !== renamedRow.rowId.toString());
|
||||
}
|
||||
bulkRenameFilesTable.clear();
|
||||
|
@ -307,7 +307,7 @@
|
|||
$("bulkRenameFilesTableFixedHeaderDiv").scrollLeft = length;
|
||||
};
|
||||
|
||||
var handleTorrentFiles = function(files, selectedRows) {
|
||||
const handleTorrentFiles = function(files, selectedRows) {
|
||||
const rows = files.map(function(file, index) {
|
||||
|
||||
const row = {
|
||||
|
@ -325,7 +325,7 @@
|
|||
addRowsToTable(rows, selectedRows);
|
||||
};
|
||||
|
||||
var addRowsToTable = function(rows, selectedRows) {
|
||||
const addRowsToTable = function(rows, selectedRows) {
|
||||
let rowId = 0;
|
||||
const rootNode = new window.qBittorrent.FileTree.FolderNode();
|
||||
rootNode.autoCheckFolders = false;
|
||||
|
@ -394,7 +394,7 @@
|
|||
fileRenamer.update();
|
||||
};
|
||||
|
||||
var setupTable = function(selectedRows) {
|
||||
const setupTable = function(selectedRows) {
|
||||
new Request.JSON({
|
||||
url: new URI("api/v2/torrents/files?hash=" + data.hash),
|
||||
noCache: true,
|
||||
|
|
|
@ -1342,7 +1342,7 @@ window.addEventListener("DOMContentLoaded", function() {
|
|||
});
|
||||
};
|
||||
|
||||
var addLogPanel = function() {
|
||||
const addLogPanel = function() {
|
||||
new MochaUI.Panel({
|
||||
id: "LogPanel",
|
||||
title: "Log",
|
||||
|
|
|
@ -363,7 +363,7 @@ window.qBittorrent.ContextMenu = (function() {
|
|||
// hide renameFiles when more than 1 torrent is selected
|
||||
if (selectedRows.length === 1) {
|
||||
const data = torrentsTable.rows.get(selectedRows[0]).full_data;
|
||||
let metadata_downloaded = !((data["state"] === "metaDL") || (data["state"] === "forcedMetaDL") || (data["total_size"] === -1));
|
||||
const metadata_downloaded = !((data["state"] === "metaDL") || (data["state"] === "forcedMetaDL") || (data["total_size"] === -1));
|
||||
|
||||
// hide renameFiles when metadata hasn't been downloaded yet
|
||||
metadata_downloaded
|
||||
|
@ -562,7 +562,7 @@ window.qBittorrent.ContextMenu = (function() {
|
|||
const RssFeedContextMenu = new Class({
|
||||
Extends: ContextMenu,
|
||||
updateMenuItems: function() {
|
||||
let selectedRows = window.qBittorrent.Rss.rssFeedTable.selectedRowsIds();
|
||||
const selectedRows = window.qBittorrent.Rss.rssFeedTable.selectedRowsIds();
|
||||
this.menu.getElement("a[href$=newSubscription]").parentNode.addClass("separator");
|
||||
switch (selectedRows.length) {
|
||||
case 0:
|
||||
|
@ -660,7 +660,7 @@ window.qBittorrent.ContextMenu = (function() {
|
|||
});
|
||||
},
|
||||
updateMenuItems: function() {
|
||||
let selectedRows = window.qBittorrent.RssDownloader.rssDownloaderRulesTable.selectedRowsIds();
|
||||
const selectedRows = window.qBittorrent.RssDownloader.rssDownloaderRulesTable.selectedRowsIds();
|
||||
this.showItem("addRule");
|
||||
switch (selectedRows.length) {
|
||||
case 0:
|
||||
|
|
|
@ -814,7 +814,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
}
|
||||
}
|
||||
|
||||
let rowPos = rows.length;
|
||||
const rowPos = rows.length;
|
||||
|
||||
while ((rowPos < trs.length) && (trs.length > 0)) {
|
||||
trs.pop().destroy();
|
||||
|
@ -1935,7 +1935,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
const node = this.getNode(i);
|
||||
|
||||
if (checkbox.checked || checkbox.indeterminate) {
|
||||
let cb = checkboxes[i];
|
||||
const cb = checkboxes[i];
|
||||
cb.checked = true;
|
||||
cb.indeterminate = false;
|
||||
cb.state = "checked";
|
||||
|
@ -1943,7 +1943,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
node.full_data.checked = node.checked;
|
||||
}
|
||||
else {
|
||||
let cb = checkboxes[i];
|
||||
const cb = checkboxes[i];
|
||||
cb.checked = false;
|
||||
cb.indeterminate = false;
|
||||
cb.state = "unchecked";
|
||||
|
@ -2635,7 +2635,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
this.columns["name"].updateTd = function(td, row) {
|
||||
const name = this.getRowValue(row, 0);
|
||||
const unreadCount = this.getRowValue(row, 1);
|
||||
let value = name + " (" + unreadCount + ")";
|
||||
const value = name + " (" + unreadCount + ")";
|
||||
td.set("text", value);
|
||||
td.set("title", value);
|
||||
};
|
||||
|
@ -2679,7 +2679,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||
}
|
||||
row["data"] = {};
|
||||
tds[0].style.overflow = "visible";
|
||||
let indentation = row.full_data.indentation;
|
||||
const indentation = row.full_data.indentation;
|
||||
tds[0].style.paddingLeft = (indentation * 32 + 4) + "px";
|
||||
tds[1].style.paddingLeft = (indentation * 32 + 4) + "px";
|
||||
},
|
||||
|
|
|
@ -123,7 +123,7 @@ const initializeWindows = function() {
|
|||
|
||||
showDownloadPage = function(urls) {
|
||||
const id = "downloadPage";
|
||||
let contentUri = new URI("download.html");
|
||||
const contentUri = new URI("download.html");
|
||||
|
||||
if (urls && (urls.length > 0)) {
|
||||
contentUri.setData("urls", urls.map(encodeURIComponent).join("|"));
|
||||
|
|
|
@ -58,7 +58,7 @@ window.qBittorrent.MultiRename = (function() {
|
|||
let count = 0;
|
||||
let lastIndex = 0;
|
||||
regex.lastIndex = 0;
|
||||
let matches = [];
|
||||
const matches = [];
|
||||
do {
|
||||
result = regex.exec(str);
|
||||
if (result === null)
|
||||
|
@ -193,17 +193,17 @@ window.qBittorrent.MultiRename = (function() {
|
|||
let replacement = this._inner_replacement;
|
||||
// Replace numerical groups
|
||||
for (let g = 0; g < match.length; ++g) {
|
||||
let group = match[g];
|
||||
const group = match[g];
|
||||
if (!group) { continue; }
|
||||
replacement = replaceGroup(replacement, `$${g}`, group, "\\", false);
|
||||
}
|
||||
// Replace named groups
|
||||
for (let namedGroup in match.groups) {
|
||||
for (const namedGroup in match.groups) {
|
||||
replacement = replaceGroup(replacement, `$${namedGroup}`, match.groups[namedGroup], "\\", false);
|
||||
}
|
||||
// Replace auxiliary variables
|
||||
for (let v = "dddddddd"; v !== ""; v = v.substring(1)) {
|
||||
let fileCount = fileEnumeration.toString().padStart(v.length, "0");
|
||||
const fileCount = fileEnumeration.toString().padStart(v.length, "0");
|
||||
replacement = replaceGroup(replacement, `$${v}`, fileCount, "\\", false);
|
||||
}
|
||||
// Remove empty $ variable
|
||||
|
@ -225,7 +225,7 @@ window.qBittorrent.MultiRename = (function() {
|
|||
return;
|
||||
}
|
||||
|
||||
let replaced = [];
|
||||
const replaced = [];
|
||||
const _inner_rename = async function(i) {
|
||||
const match = this.matchedFiles[i];
|
||||
const newName = match.renamed;
|
||||
|
@ -242,7 +242,7 @@ window.qBittorrent.MultiRename = (function() {
|
|||
const newPath = parentPath
|
||||
? parentPath + window.qBittorrent.Filesystem.PathSeparator + newName
|
||||
: newName;
|
||||
let renameRequest = new Request({
|
||||
const renameRequest = new Request({
|
||||
url: isFolder ? "api/v2/torrents/renameFolder" : "api/v2/torrents/renameFile",
|
||||
method: "post",
|
||||
data: {
|
||||
|
|
|
@ -435,7 +435,7 @@ window.qBittorrent.Search = (function() {
|
|||
const isSearchRunning = state && state.running;
|
||||
if (!isSearchRunning || searchPatternChanged) {
|
||||
const pattern = $("searchPattern").getProperty("value").trim();
|
||||
let category = $("categorySelect").getProperty("value");
|
||||
const category = $("categorySelect").getProperty("value");
|
||||
const plugins = $("pluginsSelect").getProperty("value");
|
||||
|
||||
if (!pattern || !category || !plugins)
|
||||
|
|
|
@ -167,7 +167,7 @@
|
|||
};
|
||||
|
||||
let currentSelectedTab = "main";
|
||||
let tableInfo = {
|
||||
const tableInfo = {
|
||||
main: {
|
||||
instance: new window.qBittorrent.DynamicTable.LogMessageTable(),
|
||||
progress: false,
|
||||
|
@ -240,7 +240,7 @@
|
|||
};
|
||||
|
||||
const unload = () => {
|
||||
for (let table in tableInfo)
|
||||
for (const table in tableInfo)
|
||||
resetTableTimer(table);
|
||||
};
|
||||
|
||||
|
@ -419,7 +419,7 @@
|
|||
|
||||
new ClipboardJS(".copyLogDataToClipboard", {
|
||||
text: function() {
|
||||
let msg = [];
|
||||
const msg = [];
|
||||
tableInfo[currentSelectedTab].instance.selectedRowsIds().each(function(rowId) {
|
||||
msg.push(tableInfo[currentSelectedTab].instance.rows.get(rowId).full_data[(currentSelectedTab === "main") ? "message" : "ip"]);
|
||||
});
|
||||
|
|
|
@ -1972,7 +1972,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
|
|||
};
|
||||
|
||||
const updateWebuiLocaleSelect = (selected) => {
|
||||
let languages = [];
|
||||
const languages = [];
|
||||
for (let i = 0; i < $("locale_select").options.length; i++)
|
||||
languages.push($("locale_select").options[i].value);
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@
|
|||
window.qBittorrent = {};
|
||||
}
|
||||
|
||||
let serverSyncRssDataInterval = 1500;
|
||||
const serverSyncRssDataInterval = 1500;
|
||||
|
||||
window.qBittorrent.Rss = (() => {
|
||||
const exports = () => {
|
||||
|
@ -185,8 +185,8 @@
|
|||
let feedData = {};
|
||||
let pathByFeedId = new Map();
|
||||
let feedRefreshTimer;
|
||||
let rssFeedTable = new window.qBittorrent.DynamicTable.RssFeedTable();
|
||||
let rssArticleTable = new window.qBittorrent.DynamicTable.RssArticleTable();
|
||||
const rssFeedTable = new window.qBittorrent.DynamicTable.RssFeedTable();
|
||||
const rssArticleTable = new window.qBittorrent.DynamicTable.RssArticleTable();
|
||||
|
||||
const init = () => {
|
||||
const pref = window.parent.qBittorrent.Cache.preferences.get();
|
||||
|
@ -211,9 +211,9 @@
|
|||
menu: "rssFeedMenu",
|
||||
actions: {
|
||||
update: (el) => {
|
||||
let feedsToUpdate = new Set();
|
||||
const feedsToUpdate = new Set();
|
||||
rssFeedTable.selectedRows.each((rowId) => {
|
||||
let selectedPath = rssFeedTable.rows[rowId].full_data.dataPath;
|
||||
const selectedPath = rssFeedTable.rows[rowId].full_data.dataPath;
|
||||
rssFeedTable.rows.filter((row) => row.full_data.dataPath.slice(0, selectedPath.length) === selectedPath)
|
||||
.filter((row) => row.full_data.dataUid !== "")
|
||||
.each((row) => feedsToUpdate.add(row));
|
||||
|
@ -225,11 +225,11 @@
|
|||
moveItem(rssFeedTable.rows[rssFeedTable.selectedRows[0]].full_data.dataPath);
|
||||
},
|
||||
delete: (el) => {
|
||||
let selectedDatapaths = rssFeedTable.selectedRows
|
||||
const selectedDatapaths = rssFeedTable.selectedRows
|
||||
.filter((e) => e !== 0)
|
||||
.map((sRow) => rssFeedTable.rows[sRow].full_data.dataPath);
|
||||
// filter children
|
||||
let reducedDatapaths = selectedDatapaths.filter((path) =>
|
||||
const reducedDatapaths = selectedDatapaths.filter((path) =>
|
||||
selectedDatapaths.filter((innerPath) => path.slice(0, innerPath.length) === innerPath).length === 1
|
||||
);
|
||||
removeItem(reducedDatapaths);
|
||||
|
@ -307,12 +307,12 @@
|
|||
const addRSSFeed = () => {
|
||||
let path = "";
|
||||
if (rssFeedTable.selectedRows.length !== 0) {
|
||||
let row = rssFeedTable.rows[rssFeedTable.selectedRows[0]];
|
||||
const row = rssFeedTable.rows[rssFeedTable.selectedRows[0]];
|
||||
if (row.full_data.dataUid === "") {
|
||||
path = row.full_data.dataPath;
|
||||
}
|
||||
else {
|
||||
let lastIndex = row.full_data.dataPath.lastIndexOf("\\");
|
||||
const lastIndex = row.full_data.dataPath.lastIndexOf("\\");
|
||||
if (lastIndex !== -1)
|
||||
path = row.full_data.dataPath.slice(0, lastIndex);
|
||||
}
|
||||
|
@ -334,12 +334,12 @@
|
|||
const addFolder = () => {
|
||||
let path = "";
|
||||
if (rssFeedTable.selectedRows.length !== 0) {
|
||||
let row = rssFeedTable.rows[rssFeedTable.selectedRows[0]];
|
||||
const row = rssFeedTable.rows[rssFeedTable.selectedRows[0]];
|
||||
if (row.full_data.dataUid === "") {
|
||||
path = row.full_data.dataPath;
|
||||
}
|
||||
else {
|
||||
let lastIndex = row.full_data.dataPath.lastIndexOf("\\");
|
||||
const lastIndex = row.full_data.dataPath.lastIndexOf("\\");
|
||||
if (lastIndex !== -1)
|
||||
path = row.full_data.dataPath.slice(0, lastIndex);
|
||||
}
|
||||
|
@ -362,13 +362,13 @@
|
|||
rssArticleTable.clear();
|
||||
let rowCount = 0;
|
||||
|
||||
let childFeeds = new Set();
|
||||
const childFeeds = new Set();
|
||||
rssFeedTable.rows.filter((row) => row.full_data.dataPath.slice(0, path.length) === path)
|
||||
.filter((row) => row.full_data.dataUid !== "")
|
||||
.each((row) => childFeeds.add(row.full_data.dataUid));
|
||||
|
||||
let visibleArticles = [];
|
||||
for (let feedEntry in feedData) {
|
||||
for (const feedEntry in feedData) {
|
||||
if (childFeeds.has(feedEntry))
|
||||
visibleArticles.append(feedData[feedEntry]
|
||||
.map((a) => {
|
||||
|
@ -400,30 +400,30 @@
|
|||
const showDetails = (feedUid, articleID) => {
|
||||
markArticleAsRead(pathByFeedId.get(feedUid), articleID);
|
||||
$("rssDetailsView").getChildren().each(c => c.destroy());
|
||||
let article = feedData[feedUid].filter((article) => article.id === articleID)[0];
|
||||
const article = feedData[feedUid].filter((article) => article.id === articleID)[0];
|
||||
if (article) {
|
||||
$("rssDetailsView").append((() => {
|
||||
let torrentName = document.createElement("p");
|
||||
const torrentName = document.createElement("p");
|
||||
torrentName.innerText = article.title;
|
||||
torrentName.setAttribute("id", "rssTorrentDetailsName");
|
||||
return torrentName;
|
||||
})());
|
||||
$("rssDetailsView").append((() => {
|
||||
let torrentDate = document.createElement("div");
|
||||
const torrentDate = document.createElement("div");
|
||||
torrentDate.setAttribute("id", "rssTorrentDetailsDate");
|
||||
|
||||
let torrentDateDesc = document.createElement("b");
|
||||
const torrentDateDesc = document.createElement("b");
|
||||
torrentDateDesc.innerText = "QBT_TR(Date: )QBT_TR[CONTEXT=RSSWidget]";
|
||||
torrentDate.append(torrentDateDesc);
|
||||
|
||||
let torrentDateData = document.createElement("span");
|
||||
const torrentDateData = document.createElement("span");
|
||||
torrentDateData.innerText = new Date(article.date).toLocaleString();
|
||||
torrentDate.append(torrentDateData);
|
||||
|
||||
return torrentDate;
|
||||
})());
|
||||
// Place in iframe with sandbox attribute to prevent js execution
|
||||
let torrentDescription = document.createRange().createContextualFragment('<iframe sandbox id="rssDescription"></iframe>');
|
||||
const torrentDescription = document.createRange().createContextualFragment('<iframe sandbox id="rssDescription"></iframe>');
|
||||
$("rssDetailsView").append(torrentDescription);
|
||||
document.getElementById("rssDescription").srcdoc = '<html><head><link rel="stylesheet" type="text/css" href="css/style.css" /></head><body>' + article.description + "</body></html>";
|
||||
|
||||
|
@ -444,10 +444,10 @@
|
|||
},
|
||||
onSuccess: (response) => {
|
||||
// flatten folder structure
|
||||
let flattenedResp = [];
|
||||
let recFlatten = (current, name = "", depth = 0, fullName = "") => {
|
||||
for (let child in current) {
|
||||
let currentFullName = fullName ? (fullName + "\\" + child) : child;
|
||||
const flattenedResp = [];
|
||||
const recFlatten = (current, name = "", depth = 0, fullName = "") => {
|
||||
for (const child in current) {
|
||||
const currentFullName = fullName ? (fullName + "\\" + child) : child;
|
||||
if (current[child].uid !== undefined) {
|
||||
current[child].name = child;
|
||||
current[child].isFolder = false;
|
||||
|
@ -486,7 +486,7 @@
|
|||
// update status
|
||||
let statusDiffers = false;
|
||||
for (let i = 0; i < flattenedResp.length; ++i) {
|
||||
let oldStatus = rssFeedTable.rows[i + 1].full_data.status;
|
||||
const oldStatus = rssFeedTable.rows[i + 1].full_data.status;
|
||||
let status = "default";
|
||||
if (flattenedResp[i].hasError)
|
||||
status = "hasError";
|
||||
|
@ -509,7 +509,7 @@
|
|||
// get currently opened feed
|
||||
let openedFeedPath = undefined;
|
||||
if (rssFeedTable.selectedRows.length !== 0) {
|
||||
let lastSelectedRow = rssFeedTable.selectedRows[rssFeedTable.selectedRows.length - 1];
|
||||
const lastSelectedRow = rssFeedTable.selectedRows[rssFeedTable.selectedRows.length - 1];
|
||||
openedFeedPath = rssFeedTable.rows[lastSelectedRow].full_data.dataPath;
|
||||
}
|
||||
|
||||
|
@ -528,9 +528,9 @@
|
|||
|
||||
if (articlesDiffer) {
|
||||
// update unread count
|
||||
let oldUnread = feedData[r.uid].map((art) => !art.isRead).filter((v) => v).length;
|
||||
let newUnread = r.articles.map((art) => !art.isRead).filter((v) => v).length;
|
||||
let unreadDifference = newUnread - oldUnread;
|
||||
const oldUnread = feedData[r.uid].map((art) => !art.isRead).filter((v) => v).length;
|
||||
const newUnread = r.articles.map((art) => !art.isRead).filter((v) => v).length;
|
||||
const unreadDifference = newUnread - oldUnread;
|
||||
|
||||
// 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)
|
||||
|
@ -549,8 +549,8 @@
|
|||
let readDifference = 0;
|
||||
let readChanged = false;
|
||||
for (let i = 0; i < r.articles.length; ++i) {
|
||||
let oldRead = feedData[r.uid][i].isRead ? 1 : 0;
|
||||
let newRead = r.articles[i].isRead ? 1 : 0;
|
||||
const oldRead = feedData[r.uid][i].isRead ? 1 : 0;
|
||||
const newRead = r.articles[i].isRead ? 1 : 0;
|
||||
feedData[r.uid][i].isRead = r.articles[i].isRead;
|
||||
readDifference += oldRead - newRead;
|
||||
if (readDifference !== 0)
|
||||
|
@ -567,7 +567,7 @@
|
|||
// if feed that is opened changed update dynamically
|
||||
if ((openedFeedPath !== undefined) && (r.fullName.slice(0, openedFeedPath.length) === openedFeedPath)) {
|
||||
for (let i = 0; i < r.articles.length; ++i) {
|
||||
let matchingRow = rssArticleTable.rows.filter((row) => row.full_data.feedUid === r.uid)
|
||||
const matchingRow = rssArticleTable.rows.filter((row) => row.full_data.feedUid === r.uid)
|
||||
.filter((row) => row.full_data.dataId === r.articles[i].id);
|
||||
matchingRow[Object.keys(matchingRow)[0]].full_data.isRead = r.articles[i].isRead;
|
||||
}
|
||||
|
@ -600,7 +600,7 @@
|
|||
});
|
||||
|
||||
let rowCount = 1;
|
||||
for (let dataEntry of flattenedResp) {
|
||||
for (const dataEntry of flattenedResp) {
|
||||
if (dataEntry.isFolder) {
|
||||
rssFeedTable.updateRowData({
|
||||
rowId: rowCount,
|
||||
|
@ -632,7 +632,7 @@
|
|||
});
|
||||
|
||||
// calculate number of unread
|
||||
let 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
|
||||
rssFeedTable.rows.filter((row) => dataEntry.fullName.slice(0, row.full_data.dataPath.length) === row.full_data.dataPath)
|
||||
.each((row) => row.full_data.unread += numberOfUnread);
|
||||
|
@ -671,7 +671,7 @@
|
|||
};
|
||||
|
||||
const refreshAllFeeds = () => {
|
||||
for (let feedEntry in feedData)
|
||||
for (const feedEntry in feedData)
|
||||
refreshFeed(feedEntry);
|
||||
};
|
||||
|
||||
|
@ -706,7 +706,7 @@
|
|||
|
||||
const markItemAsRead = (path) => {
|
||||
// feed data mark as read
|
||||
for (let feedID in feedData)
|
||||
for (const feedID in feedData)
|
||||
if (pathByFeedId.get(feedID).slice(0, path.length) === path)
|
||||
feedData[feedID].each((el) => el.isRead = true);
|
||||
|
||||
|
@ -790,10 +790,10 @@
|
|||
};
|
||||
|
||||
const markSelectedAsRead = () => {
|
||||
let selectedDatapaths = rssFeedTable.selectedRows
|
||||
const selectedDatapaths = rssFeedTable.selectedRows
|
||||
.map((sRow) => rssFeedTable.rows[sRow].full_data.dataPath);
|
||||
// filter children
|
||||
let reducedDatapaths = selectedDatapaths.filter((path) =>
|
||||
const reducedDatapaths = selectedDatapaths.filter((path) =>
|
||||
selectedDatapaths.filter((innerPath) => path.slice(0, innerPath.length) === innerPath).length === 1
|
||||
);
|
||||
reducedDatapaths.each((path) => markItemAsRead(path));
|
||||
|
|
|
@ -350,9 +350,9 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
|
|||
};
|
||||
};
|
||||
|
||||
let rssDownloaderRulesTable = new window.qBittorrent.DynamicTable.RssDownloaderRulesTable();
|
||||
let rssDownloaderFeedSelectionTable = new window.qBittorrent.DynamicTable.RssDownloaderFeedSelectionTable();
|
||||
let rssDownloaderArticlesTable = new window.qBittorrent.DynamicTable.RssDownloaderArticlesTable();
|
||||
const rssDownloaderRulesTable = new window.qBittorrent.DynamicTable.RssDownloaderRulesTable();
|
||||
const rssDownloaderFeedSelectionTable = new window.qBittorrent.DynamicTable.RssDownloaderFeedSelectionTable();
|
||||
const rssDownloaderArticlesTable = new window.qBittorrent.DynamicTable.RssDownloaderArticlesTable();
|
||||
|
||||
let rulesList = {};
|
||||
let feedList = [];
|
||||
|
@ -383,7 +383,7 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
|
|||
$("rssDownloaderFeedsTable").style.height = "100%";
|
||||
}
|
||||
else {
|
||||
let outsideTableHeight = ($("rssDownloaderFeedsTable").getBoundingClientRect().top - $("rssDownloaderFeeds").getBoundingClientRect().top) - 10;
|
||||
const outsideTableHeight = ($("rssDownloaderFeedsTable").getBoundingClientRect().top - $("rssDownloaderFeeds").getBoundingClientRect().top) - 10;
|
||||
$("rssDownloaderFeedsTable").style.height = "calc(100% - " + outsideTableHeight + "px)";
|
||||
}
|
||||
|
||||
|
@ -431,9 +431,9 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
|
|||
method: "get",
|
||||
noCache: true,
|
||||
onSuccess: (response) => {
|
||||
let combobox = $("assignCategoryCombobox");
|
||||
for (let cat in response) {
|
||||
let option = document.createElement("option");
|
||||
const combobox = $("assignCategoryCombobox");
|
||||
for (const cat in response) {
|
||||
const option = document.createElement("option");
|
||||
option.text = option.value = cat;
|
||||
combobox.add(option);
|
||||
}
|
||||
|
@ -449,8 +449,8 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
|
|||
},
|
||||
onSuccess: (response) => {
|
||||
feedList = [];
|
||||
let flatten = (root) => {
|
||||
for (let child in root) {
|
||||
const flatten = (root) => {
|
||||
for (const child in root) {
|
||||
if (root[child].uid !== undefined)
|
||||
feedList.push({ name: child, url: root[child].url });
|
||||
else
|
||||
|
@ -475,7 +475,7 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
|
|||
onSuccess: (response) => {
|
||||
rssDownloaderRulesTable.clear();
|
||||
let rowCount = 0;
|
||||
for (let rule in response) {
|
||||
for (const rule in response) {
|
||||
rssDownloaderRulesTable.updateRowData({
|
||||
rowId: rowCount++,
|
||||
checked: response[rule].enabled,
|
||||
|
@ -569,8 +569,8 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
|
|||
};
|
||||
|
||||
const saveSettings = () => {
|
||||
let lastSelectedRow = rssDownloaderRulesTable.selectedRows[rssDownloaderRulesTable.selectedRows.length - 1];
|
||||
let rule = rssDownloaderRulesTable.rows[lastSelectedRow].full_data.name;
|
||||
const lastSelectedRow = rssDownloaderRulesTable.selectedRows[rssDownloaderRulesTable.selectedRows.length - 1];
|
||||
const rule = rssDownloaderRulesTable.rows[lastSelectedRow].full_data.name;
|
||||
|
||||
rulesList[rule].useRegex = $("useRegEx").checked;
|
||||
rulesList[rule].mustContain = $("mustContainText").value;
|
||||
|
@ -640,7 +640,7 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
|
|||
onSuccess: (response) => {
|
||||
rssDownloaderArticlesTable.clear();
|
||||
let rowCount = 0;
|
||||
for (let feed in response) {
|
||||
for (const feed in response) {
|
||||
rssDownloaderArticlesTable.updateRowData({
|
||||
rowId: rowCount++,
|
||||
name: feed,
|
||||
|
@ -728,8 +728,8 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
|
|||
|
||||
// calculate days since last match
|
||||
if (rulesList[ruleName].lastMatch !== "") {
|
||||
let timeDiffInMs = new Date().getTime() - new Date(rulesList[ruleName].lastMatch).getTime();
|
||||
let daysAgo = Math.floor(timeDiffInMs / (1000 * 60 * 60 * 24)).toString();
|
||||
const timeDiffInMs = new Date().getTime() - new Date(rulesList[ruleName].lastMatch).getTime();
|
||||
const daysAgo = Math.floor(timeDiffInMs / (1000 * 60 * 60 * 24)).toString();
|
||||
$("lastMatchText").textContent = " QBT_TR(Last Match: %1 days ago)QBT_TR[CONTEXT=AutomatedRssDownloader]".replace("%1", daysAgo);
|
||||
}
|
||||
else {
|
||||
|
@ -776,7 +776,7 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
|
|||
+ " ● QBT_TR(| is used as OR operator)QBT_TR[CONTEXT=AutomatedRssDownloader]\n\n"
|
||||
+ "QBT_TR(If word order is important use * instead of whitespace.)QBT_TR[CONTEXT=AutomatedRssDownloader]\n\n";
|
||||
}
|
||||
let secondPart = "QBT_TR(An expression with an empty %1 clause (e.g. %2))QBT_TR[CONTEXT=AutomatedRssDownloader]"
|
||||
const secondPart = "QBT_TR(An expression with an empty %1 clause (e.g. %2))QBT_TR[CONTEXT=AutomatedRssDownloader]"
|
||||
.replace("%1", "|").replace("%2", "expr|");
|
||||
|
||||
$("mustContainText").title = mainPart + secondPart + "QBT_TR( will match all articles.)QBT_TR[CONTEXT=AutomatedRssDownloader]";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue