Skip to content

Commit

Permalink
index.html: Make copy button work
Browse files Browse the repository at this point in the history
Signed-off-by: Hector Martin <marcan@marcan.st>
  • Loading branch information
marcan committed Jan 14, 2024
1 parent b0d96d7 commit 0527737
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,21 @@ <h1>Documentation</h1>
<a href="https://github.com/AsahiLinux/docs/wiki" class="more">Visit the Wiki<i class="fas fa-angle-right more"></i></a>
</div>
</section>
<script>
document.addEventListener("DOMContentLoaded", function() {
var btn = document.getElementById("copy-button");
btn.onmouseover = function(e) {
btn.firstChild.classList.remove("fa-check");
btn.firstChild.classList.add("fa-clipboard");
}
btn.onclick = function(e) {
var text = document.getElementById("curl");
window.getSelection().selectAllChildren(text);
navigator.clipboard.writeText(text.textContent);
btn.firstChild.classList.add("fa-check");
btn.firstChild.classList.remove("fa-clipboard");
e.preventDefault();
};
});
</script>
{{ partial "footer.html" . }}

0 comments on commit 0527737

Please sign in to comment.