Skip to content

Commit 0527737

Browse files
committed
index.html: Make copy button work
Signed-off-by: Hector Martin <[email protected]>
1 parent b0d96d7 commit 0527737

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

layouts/index.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,21 @@ <h1>Documentation</h1>
9191
<a href="https://github.com/AsahiLinux/docs/wiki" class="more">Visit the Wiki<i class="fas fa-angle-right more"></i></a>
9292
</div>
9393
</section>
94+
<script>
95+
document.addEventListener("DOMContentLoaded", function() {
96+
var btn = document.getElementById("copy-button");
97+
btn.onmouseover = function(e) {
98+
btn.firstChild.classList.remove("fa-check");
99+
btn.firstChild.classList.add("fa-clipboard");
100+
}
101+
btn.onclick = function(e) {
102+
var text = document.getElementById("curl");
103+
window.getSelection().selectAllChildren(text);
104+
navigator.clipboard.writeText(text.textContent);
105+
btn.firstChild.classList.add("fa-check");
106+
btn.firstChild.classList.remove("fa-clipboard");
107+
e.preventDefault();
108+
};
109+
});
110+
</script>
94111
{{ partial "footer.html" . }}

0 commit comments

Comments
 (0)