From 5574b31a5f9ea1ebc081a2f813d83002f79a9d1b Mon Sep 17 00:00:00 2001 From: Lino Schmidt Date: Mon, 12 Jun 2023 22:20:48 +0200 Subject: [PATCH] added copy button --- src/static/index.ejs | 1 + src/static/index.js | 15 +++++++++++++++ src/static/style.css | 4 ++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/static/index.ejs b/src/static/index.ejs index 68ddf1e..f0e25d7 100644 --- a/src/static/index.ejs +++ b/src/static/index.ejs @@ -15,6 +15,7 @@ <% }); %> + diff --git a/src/static/index.js b/src/static/index.js index e127803..8c11e17 100644 --- a/src/static/index.js +++ b/src/static/index.js @@ -1,8 +1,23 @@ const exportTextarea = document.getElementById('export-textarea'); const weekList = document.getElementById('week-list'); const exportButton = document.getElementById('export-button'); +const copyButton = document.getElementById('copy-button'); let loadingInterval; +function copyToClipboard() { + navigator.clipboard.writeText(exportTextarea.value).then(() => { + copyButton.innerText = 'Copied!'; + setTimeout(() => { + copyButton.innerText = 'Copy'; + }, 2000); + }).catch(() => { + copyButton.innerText = 'Error!'; + setTimeout(() => { + copyButton.innerText = 'Copy'; + }, 2000); + }); +} + function loading() { exportButton.disabled = true; exportTextarea.value = 'Loading'; diff --git a/src/static/style.css b/src/static/style.css index a1339b0..6e09a4f 100644 --- a/src/static/style.css +++ b/src/static/style.css @@ -30,7 +30,7 @@ select::-webkit-scrollbar { overflow-y: scroll; } -.selector button { +button { font-size: 16px; height: 30px; margin-left: 10px; @@ -39,7 +39,7 @@ select::-webkit-scrollbar { color: #fff; border: none; } -.selector button:hover { +button:hover { scale: 1.1; cursor: pointer; }