diff --git a/static/copy.js b/static/copy.js index 889b8ff..4f090ec 100644 --- a/static/copy.js +++ b/static/copy.js @@ -1,17 +1,13 @@ -const button = document.getElementById("copy"); -button.classList.remove("hidden"); -button.onclick = () => { - if (!navigator.clipboard) { - button.innerText = "nicht unterstützt"; - return; +if (navigator.clipboard) { + const buttons = document.querySelectorAll("button[data-copy], a[data-copy]"); + for (const button of buttons) { + button.classList.remove("hidden"); + button.onclick = () => { + const target = document.querySelector(button.getAttribute("data-copy")); + navigator.clipboard.writeText(target.textContent).then( + (_) => (button.innerText = "kopiert!"), + (_) => (button.innerText = "nicht unterstützt") + ); + }; } - const content = document.getElementsByClassName("copy-content")[0]; - navigator.clipboard.writeText(content.textContent).then( - (_) => { - button.innerText = "kopiert!"; - }, - (_) => { - button.innerText = "nicht unterstützt"; - } - ); -}; +} diff --git a/template/text-view.html b/template/text-view.html index b644c65..8baba7f 100644 --- a/template/text-view.html +++ b/template/text-view.html @@ -9,12 +9,12 @@

datatrash

- +
herunterladen - +