Skip to content

Commit

Permalink
Admin copy button
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersSeverinsen committed Apr 18, 2024
1 parent 3926d54 commit a685c33
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions web/templates/secrets_admin.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
{% extends "admin/base_site.html" %}
{% block scripts %}
<script>
function CopyText(value) {
var text = document.getElementById(value)
text.select();
document.execCommand('copy')
}
</script>
{% endblock scripts %}
{% block content %}
<table>
<tr>
Expand All @@ -30,8 +21,8 @@
</td>
<td>
{% if value != None %}
<code id="{{ value }}">{{ value }}</code>
<button type="submit" onclick="CopyText({{ value }})">Copy</button>
<code>{{ value }}</code>
<button class="copyButton">Copy</button>
{% else %}
<b>Missing from environment</b>
{% endif %}
Expand All @@ -47,3 +38,18 @@
{% endfor %}
</table>
{% endblock %}
{% 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');
});
}
)
</script>
{% endblock scripts %}

0 comments on commit a685c33

Please sign in to comment.