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 <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2022-03-07 23:53:57 -08:00
parent b80d914cba
commit 5045f0f3e4
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
2 changed files with 7 additions and 5 deletions

View file

@ -160,4 +160,3 @@
</table>
<script type="text/javascript" src="/static/js/copy.js"></script>

View file

@ -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);
});
});
});