Skip to content

Commit

Permalink
Fixed copy button
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersSeverinsen committed Apr 19, 2024
1 parent a685c33 commit f779ff1
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions web/templates/secrets_admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</td>
<td>
{% if value != None %}
<code>{{ value }}</code>
<code class="copyText">{{ value }}</code>
<button class="copyButton">Copy</button>
{% else %}
<b>Missing from environment</b>
Expand All @@ -41,15 +41,18 @@
{% block scripts %}
<script>
var copyButtons = document.getElementsByClassName('copyButton');
copyButtons.forEach(
(element) => {
element.addEventListener('click', function(){
var parent = element.parentElement;
var text = parent.firstElementChild.textContent;
text.select();
document.execCommand('copy');
for(var index=0; index < copyButtons.length; index++){
var element = copyButtons[index];
element.addEventListener('click', function(){
console.log(element);
var parent = element.parentElement;
var text = parent.firstElementChild.textContent;
navigator.clipboard.writeText(text).then(() => {
/* Resolved - text copied to clipboard successfully */
},() => {
/* Rejected - text failed to copy to the clipboard */
});
}
)
});
}
</script>
{% endblock scripts %}

0 comments on commit f779ff1

Please sign in to comment.