add 'copy link' button to upload view

This commit is contained in:
neri 2020-08-19 16:26:47 +02:00
parent f5a7ed4213
commit dc99b87bcc
1 changed files with 18 additions and 1 deletions

View File

@ -11,10 +11,27 @@
<h1><a href="/">datatrash</a></h1> <h1><a href="/">datatrash</a></h1>
<p> <p>
datei-link: datei-link:
<a href="{url}"> <a id="link" href="{url}">
{url} {url}
</a> </a>
</p> </p>
<button id="copy" class="main button" onclick="copyToClipboard()">
link kopieren
</button>
</main> </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> </body>
</html> </html>