From a79da3ffce3107e69cc8f6f8d6ce7c61d287f701 Mon Sep 17 00:00:00 2001 From: Ludwig Lehnert Date: Mon, 12 Jan 2026 17:24:28 +0100 Subject: [PATCH] updated expressjs project to add a 'copy link' button --- expressjs/src/server.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/expressjs/src/server.js b/expressjs/src/server.js index 90e9fd1..70d7718 100644 --- a/expressjs/src/server.js +++ b/expressjs/src/server.js @@ -411,6 +411,7 @@ app.get(`${basePath}/dashboard`, requireAuthPage, async (req, res) => {
Noch ${formatCountdown(item.expires_at)}
+
@@ -474,6 +475,7 @@ app.get(`${basePath}/dashboard`, requireAuthPage, async (req, res) => { const uploadForm = document.getElementById('upload-form'); const progress = document.getElementById('upload-progress'); const status = document.getElementById('upload-status'); + const copyButtons = document.querySelectorAll('.copy-link'); uploadForm.addEventListener('submit', (event) => { event.preventDefault(); status.textContent = ''; @@ -498,6 +500,25 @@ app.get(`${basePath}/dashboard`, requireAuthPage, async (req, res) => { }); xhr.send(new FormData(uploadForm)); }); + + copyButtons.forEach((button) => { + button.addEventListener('click', async () => { + const path = button.dataset.path || ''; + const url = window.location.origin + path; + try { + await navigator.clipboard.writeText(url); + status.textContent = 'Link kopiert.'; + } catch (err) { + const helper = document.createElement('textarea'); + helper.value = url; + document.body.appendChild(helper); + helper.select(); + document.execCommand('copy'); + document.body.removeChild(helper); + status.textContent = 'Link kopiert.'; + } + }); + }); `;