WebUI: enforce usage of const whenever possible

This commit is contained in:
Chocobo1
2024-05-27 22:54:18 +08:00
parent cb90b6769c
commit 55bff4f07a
12 changed files with 102 additions and 100 deletions

View File

@@ -1342,7 +1342,7 @@ window.addEventListener("DOMContentLoaded", function() {
});
};
var addLogPanel = function() {
const addLogPanel = function() {
new MochaUI.Panel({
id: "LogPanel",
title: "Log",

View File

@@ -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:

View File

@@ -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";
},

View File

@@ -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("|"));

View File

@@ -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: {

View File

@@ -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)