From 5045f0f3e464fc0fbb3229968cb07617ec48314f Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Mon, 7 Mar 2022 23:53:57 -0800 Subject: [PATCH] fix: copy.js javascript initialization Not sure where this works, but it doesn't seem to work on my browser. Achieved the same by forEaching through the array returned by querySelectorAll instead. Signed-off-by: Kevin Morris --- templates/partials/packages/details.html | 1 - web/html/js/copy.js | 11 +++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/templates/partials/packages/details.html b/templates/partials/packages/details.html index 22d519b9..e0eda54c 100644 --- a/templates/partials/packages/details.html +++ b/templates/partials/packages/details.html @@ -160,4 +160,3 @@ - diff --git a/web/html/js/copy.js b/web/html/js/copy.js index 21324ccb..3b659270 100644 --- a/web/html/js/copy.js +++ b/web/html/js/copy.js @@ -1,6 +1,9 @@ document.addEventListener('DOMContentLoaded', function() { - document.querySelectorAll('.copy').addEventListener('click', function(e) { - e.preventDefault(); - navigator.clipboard.writeText(e.target.text); - }); + let elements = document.querySelectorAll('.copy'); + elements.forEach(function(el) { + el.addEventListener('click', function(e) { + e.preventDefault(); + navigator.clipboard.writeText(e.target.text); + }); + }); });