feat: Add copy feature

This commit is contained in:
overflowerror 2023-12-03 14:18:51 +01:00
parent 6a77e6636c
commit 6188e3e063
3 changed files with 8 additions and 0 deletions

6
html/static/js/copy.js Normal file
View file

@ -0,0 +1,6 @@
function copy(selector) {
let element = document.querySelector(selector);
navigator.clipboard.writeText(element.innerHTML);
return false;
}

View file

@ -1,2 +1,3 @@
<script src="/static/js/copy.js"></script>
</body>
</html>

View file

@ -1,5 +1,6 @@
<div class="result">
<a href="<?php echo $data["url"] ?? ""; ?>" target="_blank"><?php echo $data["url"] ?? ""; ?></a>
<a href="javascript:copy('.result a')">copy</a>
</div>
<!-- <?php echo $data["accessKey"] ?? ""; ?> -->
Click <a hx-get="/?formonly" hx-swap="innerHTML" hx-target=".center-panel" href="/">here</a> to create a new link.