mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-10 09:24:59 -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:
@@ -144,7 +144,7 @@
|
||||
</div>
|
||||
|
||||
<ul id="logTableMenu" class="contextMenu">
|
||||
<li><a href="#" class="copyLogDataToClipboard"><img src="images/edit-copy.svg" alt="QBT_TR(Copy)QBT_TR[CONTEXT=ExecutionLogWidget]">QBT_TR(Copy)QBT_TR[CONTEXT=ExecutionLogWidget]</a></li>
|
||||
<li><a href="#" id="copyLogDataToClipboard"><img src="images/edit-copy.svg" alt="QBT_TR(Copy)QBT_TR[CONTEXT=ExecutionLogWidget]">QBT_TR(Copy)QBT_TR[CONTEXT=ExecutionLogWidget]</a></li>
|
||||
<li><a href="#Clear"><img src="images/list-remove.svg" alt="QBT_TR(Clear)QBT_TR[CONTEXT=ExecutionLogWidget]">QBT_TR(Clear)QBT_TR[CONTEXT=ExecutionLogWidget]</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -418,15 +418,11 @@
|
||||
});
|
||||
};
|
||||
|
||||
new ClipboardJS(".copyLogDataToClipboard", {
|
||||
text: () => {
|
||||
const msg = [];
|
||||
tableInfo[currentSelectedTab].instance.selectedRowsIds().forEach((rowId) => {
|
||||
msg.push(tableInfo[currentSelectedTab].instance.getRow(rowId).full_data[(currentSelectedTab === "main") ? "message" : "ip"]);
|
||||
});
|
||||
|
||||
return msg.join("\n");
|
||||
}
|
||||
document.getElementById("copyLogDataToClipboard").addEventListener("click", async (event) => {
|
||||
const instance = tableInfo[currentSelectedTab].instance;
|
||||
const type = (currentSelectedTab === "main") ? "message" : "ip";
|
||||
const msg = instance.selectedRowsIds().map((rowId) => instance.getRow(rowId).full_data[type]);
|
||||
await clipboardCopy(msg.join("\n"));
|
||||
});
|
||||
|
||||
return exports();
|
||||
|
||||
Reference in New Issue
Block a user