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();
|
}).send();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("DlInfos").addEventListener("click", globalDownloadLimitFN);
|
$("DlInfos").addEventListener("click", () => { globalDownloadLimitFN(); });
|
||||||
$("UpInfos").addEventListener("click", globalUploadLimitFN);
|
$("UpInfos").addEventListener("click", () => { globalUploadLimitFN(); });
|
||||||
|
|
||||||
$("showTopToolbarLink").addEventListener("click", (e) => {
|
$("showTopToolbarLink").addEventListener("click", (e) => {
|
||||||
showTopToolbar = !showTopToolbar;
|
showTopToolbar = !showTopToolbar;
|
||||||
|
@ -1206,7 +1206,7 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||||
$("mainWindowTabs").addClass("invisible");
|
$("mainWindowTabs").addClass("invisible");
|
||||||
};
|
};
|
||||||
|
|
||||||
$("StatisticsLink").addEventListener("click", StatisticsLinkFN);
|
$("StatisticsLink").addEventListener("click", () => { StatisticsLinkFN(); });
|
||||||
|
|
||||||
// main window tabs
|
// main window tabs
|
||||||
|
|
||||||
|
@ -1567,10 +1567,10 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||||
|
|
||||||
document.getElementById("torrentsFilterToolbar").addEventListener("change", (e) => { torrentsTable.updateTable(); });
|
document.getElementById("torrentsFilterToolbar").addEventListener("change", (e) => { torrentsTable.updateTable(); });
|
||||||
|
|
||||||
$("transfersTabLink").addEventListener("click", showTransfersTab);
|
$("transfersTabLink").addEventListener("click", () => { showTransfersTab(); });
|
||||||
$("searchTabLink").addEventListener("click", showSearchTab);
|
$("searchTabLink").addEventListener("click", () => { showSearchTab(); });
|
||||||
$("rssTabLink").addEventListener("click", showRssTab);
|
$("rssTabLink").addEventListener("click", () => { showRssTab(); });
|
||||||
$("logTabLink").addEventListener("click", showLogTab);
|
$("logTabLink").addEventListener("click", () => { showLogTab(); });
|
||||||
updateTabDisplay();
|
updateTabDisplay();
|
||||||
|
|
||||||
const registerDragAndDrop = () => {
|
const registerDragAndDrop = () => {
|
||||||
|
|
|
@ -440,7 +440,7 @@ window.qBittorrent.ContextMenu ??= (() => {
|
||||||
const createMenuItem = (text, imgURL, clickFn) => {
|
const createMenuItem = (text, imgURL, clickFn) => {
|
||||||
const anchor = document.createElement("a");
|
const anchor = document.createElement("a");
|
||||||
anchor.textContent = text;
|
anchor.textContent = text;
|
||||||
anchor.addEventListener("click", clickFn);
|
anchor.addEventListener("click", () => { clickFn(); });
|
||||||
|
|
||||||
const img = document.createElement("img");
|
const img = document.createElement("img");
|
||||||
img.src = imgURL;
|
img.src = imgURL;
|
||||||
|
@ -495,7 +495,7 @@ window.qBittorrent.ContextMenu ??= (() => {
|
||||||
const createMenuItem = (text, imgURL, clickFn) => {
|
const createMenuItem = (text, imgURL, clickFn) => {
|
||||||
const anchor = document.createElement("a");
|
const anchor = document.createElement("a");
|
||||||
anchor.textContent = text;
|
anchor.textContent = text;
|
||||||
anchor.addEventListener("click", clickFn);
|
anchor.addEventListener("click", () => { clickFn(); });
|
||||||
|
|
||||||
const img = document.createElement("img");
|
const img = document.createElement("img");
|
||||||
img.src = imgURL;
|
img.src = imgURL;
|
||||||
|
|
|
@ -753,14 +753,15 @@ window.qBittorrent.Search ??= (() => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const setupSearchTableEvents = function(enable) {
|
const setupSearchTableEvents = function(enable) {
|
||||||
|
const clickHandler = (e) => { downloadSearchTorrent(); };
|
||||||
if (enable) {
|
if (enable) {
|
||||||
$$(".searchTableRow").each((target) => {
|
$$(".searchTableRow").each((target) => {
|
||||||
target.addEventListener("dblclick", downloadSearchTorrent, false);
|
target.addEventListener("dblclick", clickHandler);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$$(".searchTableRow").each((target) => {
|
$$(".searchTableRow").each((target) => {
|
||||||
target.removeEventListener("dblclick", downloadSearchTorrent, false);
|
target.removeEventListener("dblclick", clickHandler);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -182,16 +182,18 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
const setupSearchPluginTableEvents = function(enable) {
|
const setupSearchPluginTableEvents = function(enable) {
|
||||||
|
const clickHandler = (e) => { enablePlugin(); };
|
||||||
|
const menuHandler = (e) => { updateSearchPluginsTableContextMenuOffset(); };
|
||||||
if (enable) {
|
if (enable) {
|
||||||
$$(".searchPluginsTableRow").each((target) => {
|
$$(".searchPluginsTableRow").each((target) => {
|
||||||
target.addEventListener("dblclick", enablePlugin, false);
|
target.addEventListener("dblclick", clickHandler);
|
||||||
target.addEventListener("contextmenu", updateSearchPluginsTableContextMenuOffset, true);
|
target.addEventListener("contextmenu", menuHandler, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$$(".searchPluginsTableRow").each((target) => {
|
$$(".searchPluginsTableRow").each((target) => {
|
||||||
target.removeEventListener("dblclick", enablePlugin, false);
|
target.removeEventListener("dblclick", clickHandler);
|
||||||
target.removeEventListener("contextmenu", updateSearchPluginsTableContextMenuOffset, true);
|
target.removeEventListener("contextmenu", menuHandler, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue