Commit f13d251
Eric Bower
·
2025-08-02 13:40:35 -0400 EDT
parent c28b9f9
feat(pastes): copy button
1 files changed,
+17,
-7
+17,
-7
| ... | ... | @@ -35,15 +35,25 @@ | |
| 35 | 35 | <a href="{{.RawURL}}">raw</a> | |
| 36 | 36 | </p> | |
| 37 | 37 | <p class="font-bold m-0">expires: {{.ExpiresAt}}</p> | |
| 38 | + | <script> | |
| 39 | + | function init() { | |
| 40 | + | const btn = document.querySelector("#copy-btn"); | |
| 41 | + | const res = document.querySelector("#copy-result"); | |
| 42 | + | const text = "{{.Text}}"; | |
| 43 | + | btn.addEventListener("click", () => { | |
| 44 | + | res.innerHtml = ""; | |
| 45 | + | navigator.clipboard.writeText(text) | |
| 46 | + | .then(() => res.innerHTML = "success!"); | |
| 47 | + | }) | |
| 48 | + | } | |
| 49 | + | document.addEventListener("DOMContentLoaded", init); | |
| 50 | + | </script> | |
| 38 | 51 | </header> | |
| 39 | 52 | <main> | |
| 40 | - | <script> | |
| 41 | - | function copyText() { | |
| 42 | - | const text = `{{.Text}}` | |
| 43 | - | navigator.clipboard.writeText(text) | |
| 44 | - | } | |
| 45 | - | </script> | |
| 46 | - | <button onclick="copyText()" class="btn mt inline-block">Copy Paste</button> | |
| 53 | + | <div class="flex gap items-center"> | |
| 54 | + | <button id="copy-btn" class="btn" style="background-color: transparent;">copy</button> | |
| 55 | + | <div id="copy-result" class=""></div> | |
| 56 | + | </div> | |
| 47 | 57 | <article> | |
| 48 | 58 | {{.Contents}} | |
| 49 | 59 | </article> |