From 39257c8e8112d54cc47bb7b50cb5bdc5573ef1ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Rajchl?= Date: Wed, 10 Apr 2024 06:36:29 +0200 Subject: [PATCH] Fix multiple "Copy to clipboard" on page --- adminer/static/functions.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/adminer/static/functions.js b/adminer/static/functions.js index 247a43f1..4d63e1ce 100644 --- a/adminer/static/functions.js +++ b/adminer/static/functions.js @@ -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