forked from neri/datatrash
add 'copy link' button to upload view
This commit is contained in:
parent
f5a7ed4213
commit
dc99b87bcc
|
@ -11,10 +11,27 @@
|
|||
<h1><a href="/">datatrash</a></h1>
|
||||
<p>
|
||||
datei-link:
|
||||
<a href="{url}">
|
||||
<a id="link" href="{url}">
|
||||
{url}
|
||||
</a>
|
||||
</p>
|
||||
<button id="copy" class="main button" onclick="copyToClipboard()">
|
||||
link kopieren
|
||||
</button>
|
||||
</main>
|
||||
<script lang="javascript">
|
||||
function copyToClipboard() {
|
||||
const button = document.getElementById("copy");
|
||||
if (!navigator.clipboard) {
|
||||
button.innerText = "nicht unterstützt";
|
||||
return;
|
||||
}
|
||||
const anchor = document.getElementById("link");
|
||||
navigator.clipboard.writeText(anchor.href).then(
|
||||
_ => { button.innerText = "kopiert!"; },
|
||||
_ => { button.innerText = "nicht unterstützt"; },
|
||||
);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue