mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-10-22 10:46:04 +03:00
WebUI: fix 'rename files' dialog cannot be opened more than once
Added an IIFE around the whole script to suppress variable redeclaration errors. Closes #21614. PR #21620.
This commit is contained in:
parent
a47e1cdb48
commit
25dbea1388
1 changed files with 312 additions and 320 deletions
|
@ -14,15 +14,13 @@
|
||||||
<script>
|
<script>
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
(() => {
|
||||||
if (window.parent.qBittorrent !== undefined)
|
if (window.parent.qBittorrent !== undefined)
|
||||||
window.qBittorrent = window.parent.qBittorrent;
|
window.qBittorrent = window.parent.qBittorrent;
|
||||||
window.qBittorrent = window.parent.qBittorrent;
|
window.qBittorrent = window.parent.qBittorrent;
|
||||||
|
|
||||||
const TriState = window.qBittorrent.FileTree.TriState;
|
|
||||||
const data = window.MUI.Windows.instances["multiRenamePage"].options.data;
|
const data = window.MUI.Windows.instances["multiRenamePage"].options.data;
|
||||||
let bulkRenameFilesContextMenu;
|
const bulkRenameFilesContextMenu = new window.qBittorrent.ContextMenu.ContextMenu({
|
||||||
if (!bulkRenameFilesContextMenu) {
|
|
||||||
bulkRenameFilesContextMenu = new window.qBittorrent.ContextMenu.ContextMenu({
|
|
||||||
targets: "#bulkRenameFilesTableDiv tr",
|
targets: "#bulkRenameFilesTableDiv tr",
|
||||||
menu: "multiRenameFilesMenu",
|
menu: "multiRenameFilesMenu",
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -40,7 +38,6 @@
|
||||||
y: 2
|
y: 2
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// Setup the dynamic table for bulk renaming
|
// Setup the dynamic table for bulk renaming
|
||||||
const bulkRenameFilesTable = new window.qBittorrent.DynamicTable.BulkRenameTorrentFilesTable();
|
const bulkRenameFilesTable = new window.qBittorrent.DynamicTable.BulkRenameTorrentFilesTable();
|
||||||
|
@ -48,11 +45,8 @@
|
||||||
|
|
||||||
// Inject checkbox into the first column of the table header
|
// Inject checkbox into the first column of the table header
|
||||||
const tableHeaders = $$("#bulkRenameFilesTableFixedHeaderDiv .dynamicTableHeader th");
|
const tableHeaders = $$("#bulkRenameFilesTableFixedHeaderDiv .dynamicTableHeader th");
|
||||||
let checkboxHeader;
|
|
||||||
if (tableHeaders.length > 0) {
|
if (tableHeaders.length > 0) {
|
||||||
if (checkboxHeader)
|
const checkboxHeader = new Element("input");
|
||||||
checkboxHeader.remove();
|
|
||||||
checkboxHeader = new Element("input");
|
|
||||||
checkboxHeader.type = "checkbox";
|
checkboxHeader.type = "checkbox";
|
||||||
checkboxHeader.id = "rootMultiRename_cb";
|
checkboxHeader.id = "rootMultiRename_cb";
|
||||||
checkboxHeader.addEventListener("click", (e) => {
|
checkboxHeader.addEventListener("click", (e) => {
|
||||||
|
@ -67,9 +61,7 @@
|
||||||
|
|
||||||
// Register keyboard events to modal window
|
// Register keyboard events to modal window
|
||||||
// https://github.com/qbittorrent/qBittorrent/pull/18687#discussion_r1135045726
|
// https://github.com/qbittorrent/qBittorrent/pull/18687#discussion_r1135045726
|
||||||
let keyboard;
|
const keyboard = new Keyboard({
|
||||||
if (!keyboard) {
|
|
||||||
keyboard = new Keyboard({
|
|
||||||
defaultEventType: "keydown",
|
defaultEventType: "keydown",
|
||||||
events: {
|
events: {
|
||||||
"Escape": function(event) {
|
"Escape": function(event) {
|
||||||
|
@ -83,7 +75,6 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
keyboard.activate();
|
keyboard.activate();
|
||||||
}
|
|
||||||
|
|
||||||
const fileRenamer = new window.qBittorrent.MultiRename.RenameFiles();
|
const fileRenamer = new window.qBittorrent.MultiRename.RenameFiles();
|
||||||
fileRenamer.hash = data.hash;
|
fileRenamer.hash = data.hash;
|
||||||
|
@ -402,6 +393,7 @@
|
||||||
}).send();
|
}).send();
|
||||||
};
|
};
|
||||||
setupTable(data.selectedRows);
|
setupTable(data.selectedRows);
|
||||||
|
})();
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue