mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-17 22:18:05 -06:00
WebUI: switch to lightweight clipboard library
The new library [1] will opt to the modern Clipboard API [2] when it is available. It will fallback to the old method otherwise. The new library is also smaller and without any bloat. Note that the line `module.exports` is required to be removed/commented out. This is the only patch required. [1] https://github.com/feross/clipboard-copy [2] https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API PR #22792.
This commit is contained in:
@@ -866,20 +866,20 @@ window.qBittorrent.Search ??= (() => {
|
||||
state.loadResultsTimer = loadSearchResultsData.delay(500, this, searchId);
|
||||
};
|
||||
|
||||
new ClipboardJS(".copySearchDataToClipboard", {
|
||||
text: (trigger) => {
|
||||
switch (trigger.id) {
|
||||
case "copySearchTorrentName":
|
||||
return copySearchTorrentName();
|
||||
case "copySearchTorrentDownloadLink":
|
||||
return copySearchTorrentDownloadLink();
|
||||
case "copySearchTorrentDescriptionUrl":
|
||||
return copySearchTorrentDescriptionUrl();
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
for (const element of document.getElementsByClassName("copySearchDataToClipboard")) {
|
||||
const setupClickEvent = (textFunc) => element.addEventListener("click", async (event) => await clipboardCopy(textFunc()));
|
||||
switch (element.id) {
|
||||
case "copySearchTorrentName":
|
||||
setupClickEvent(copySearchTorrentName);
|
||||
break;
|
||||
case "copySearchTorrentDownloadLink":
|
||||
setupClickEvent(copySearchTorrentDownloadLink);
|
||||
break;
|
||||
case "copySearchTorrentDescriptionUrl":
|
||||
setupClickEvent(copySearchTorrentDescriptionUrl);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return exports();
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user