Merge pull request #141 from Lumeriol/main

Fix multiple "Copy to clipboard" on page
This commit is contained in:
Lionel 2024-04-13 15:31:24 +02:00 committed by GitHub
commit 6bb4d778cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -884,21 +884,21 @@ function findDefaultSubmit(el) {
* @param HTMLElement
*/
function setupCopyToClipboard(document) {
var node = document.querySelector("a.copy-to-clipboard");
if (node) {
node.addEventListener("click", function() {
var node = document.querySelectorAll("a.copy-to-clipboard");
node.forEach(function(element) {
element.addEventListener("click", function() {
var nodeSql = document.querySelector("code.copy-to-clipboard");
if (nodeSql == null || nodeSql == undefined) {
nodeSql = document.querySelector("textarea.sqlarea");
}
if (nodeSql != null && nodeSql != undefined) {
if (node.classList.contains('expand')) {
document.getElementById(node.getAttribute('data-expand-id')).classList.remove("hidden");
if (element.classList.contains('expand')) {
document.getElementById(element.getAttribute('data-expand-id')).classList.remove("hidden");
}
copyToClipboard(nodeSql);
}
});
}
});
}
/** Copy element's content in clipboard