- commit
- f13d251
- parent
- c28b9f9
- author
- Eric Bower
- date
- 2025-08-02 13:40:35 -0400 EDT
feat(pastes): copy button
1 files changed,
+17,
-7
+17,
-7
1@@ -35,15 +35,25 @@
2 <a href="{{.RawURL}}">raw</a>
3 </p>
4 <p class="font-bold m-0">expires: {{.ExpiresAt}}</p>
5+ <script>
6+ function init() {
7+ const btn = document.querySelector("#copy-btn");
8+ const res = document.querySelector("#copy-result");
9+ const text = "{{.Text}}";
10+ btn.addEventListener("click", () => {
11+ res.innerHtml = "";
12+ navigator.clipboard.writeText(text)
13+ .then(() => res.innerHTML = "success!");
14+ })
15+ }
16+ document.addEventListener("DOMContentLoaded", init);
17+ </script>
18 </header>
19 <main>
20-<script>
21-function copyText() {
22- const text = `{{.Text}}`
23- navigator.clipboard.writeText(text)
24-}
25-</script>
26- <button onclick="copyText()" class="btn mt inline-block">Copy Paste</button>
27+ <div class="flex gap items-center">
28+ <button id="copy-btn" class="btn" style="background-color: transparent;">copy</button>
29+ <div id="copy-result" class=""></div>
30+ </div>
31 <article>
32 {{.Contents}}
33 </article>