mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-14 01:03:08 -07:00
WebUI: prevent passing wrong parameter
The `event` object will be passed as the first parameter to the event handler. So wrap the event handler with a closure to prevent `event` leaking to other functions.
This commit is contained in:
parent
e069fbc37f
commit
1179fc3de3
4 changed files with 18 additions and 15 deletions
|
@ -1059,8 +1059,8 @@ window.addEventListener("DOMContentLoaded", () => {
|
|||
}).send();
|
||||
});
|
||||
|
||||
$("DlInfos").addEventListener("click", globalDownloadLimitFN);
|
||||
$("UpInfos").addEventListener("click", globalUploadLimitFN);
|
||||
$("DlInfos").addEventListener("click", () => { globalDownloadLimitFN(); });
|
||||
$("UpInfos").addEventListener("click", () => { globalUploadLimitFN(); });
|
||||
|
||||
$("showTopToolbarLink").addEventListener("click", (e) => {
|
||||
showTopToolbar = !showTopToolbar;
|
||||
|
@ -1206,7 +1206,7 @@ window.addEventListener("DOMContentLoaded", () => {
|
|||
$("mainWindowTabs").addClass("invisible");
|
||||
};
|
||||
|
||||
$("StatisticsLink").addEventListener("click", StatisticsLinkFN);
|
||||
$("StatisticsLink").addEventListener("click", () => { StatisticsLinkFN(); });
|
||||
|
||||
// main window tabs
|
||||
|
||||
|
@ -1567,10 +1567,10 @@ window.addEventListener("DOMContentLoaded", () => {
|
|||
|
||||
document.getElementById("torrentsFilterToolbar").addEventListener("change", (e) => { torrentsTable.updateTable(); });
|
||||
|
||||
$("transfersTabLink").addEventListener("click", showTransfersTab);
|
||||
$("searchTabLink").addEventListener("click", showSearchTab);
|
||||
$("rssTabLink").addEventListener("click", showRssTab);
|
||||
$("logTabLink").addEventListener("click", showLogTab);
|
||||
$("transfersTabLink").addEventListener("click", () => { showTransfersTab(); });
|
||||
$("searchTabLink").addEventListener("click", () => { showSearchTab(); });
|
||||
$("rssTabLink").addEventListener("click", () => { showRssTab(); });
|
||||
$("logTabLink").addEventListener("click", () => { showLogTab(); });
|
||||
updateTabDisplay();
|
||||
|
||||
const registerDragAndDrop = () => {
|
||||
|
|
|
@ -440,7 +440,7 @@ window.qBittorrent.ContextMenu ??= (() => {
|
|||
const createMenuItem = (text, imgURL, clickFn) => {
|
||||
const anchor = document.createElement("a");
|
||||
anchor.textContent = text;
|
||||
anchor.addEventListener("click", clickFn);
|
||||
anchor.addEventListener("click", () => { clickFn(); });
|
||||
|
||||
const img = document.createElement("img");
|
||||
img.src = imgURL;
|
||||
|
@ -495,7 +495,7 @@ window.qBittorrent.ContextMenu ??= (() => {
|
|||
const createMenuItem = (text, imgURL, clickFn) => {
|
||||
const anchor = document.createElement("a");
|
||||
anchor.textContent = text;
|
||||
anchor.addEventListener("click", clickFn);
|
||||
anchor.addEventListener("click", () => { clickFn(); });
|
||||
|
||||
const img = document.createElement("img");
|
||||
img.src = imgURL;
|
||||
|
|
|
@ -753,14 +753,15 @@ window.qBittorrent.Search ??= (() => {
|
|||
};
|
||||
|
||||
const setupSearchTableEvents = function(enable) {
|
||||
const clickHandler = (e) => { downloadSearchTorrent(); };
|
||||
if (enable) {
|
||||
$$(".searchTableRow").each((target) => {
|
||||
target.addEventListener("dblclick", downloadSearchTorrent, false);
|
||||
target.addEventListener("dblclick", clickHandler);
|
||||
});
|
||||
}
|
||||
else {
|
||||
$$(".searchTableRow").each((target) => {
|
||||
target.removeEventListener("dblclick", downloadSearchTorrent, false);
|
||||
target.removeEventListener("dblclick", clickHandler);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -182,16 +182,18 @@
|
|||
};
|
||||
|
||||
const setupSearchPluginTableEvents = function(enable) {
|
||||
const clickHandler = (e) => { enablePlugin(); };
|
||||
const menuHandler = (e) => { updateSearchPluginsTableContextMenuOffset(); };
|
||||
if (enable) {
|
||||
$$(".searchPluginsTableRow").each((target) => {
|
||||
target.addEventListener("dblclick", enablePlugin, false);
|
||||
target.addEventListener("contextmenu", updateSearchPluginsTableContextMenuOffset, true);
|
||||
target.addEventListener("dblclick", clickHandler);
|
||||
target.addEventListener("contextmenu", menuHandler, true);
|
||||
});
|
||||
}
|
||||
else {
|
||||
$$(".searchPluginsTableRow").each((target) => {
|
||||
target.removeEventListener("dblclick", enablePlugin, false);
|
||||
target.removeEventListener("contextmenu", updateSearchPluginsTableContextMenuOffset, true);
|
||||
target.removeEventListener("dblclick", clickHandler);
|
||||
target.removeEventListener("contextmenu", menuHandler, true);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue