From 04b574fda7fe814165f081f9ca5f85c396dd99ea Mon Sep 17 00:00:00 2001 From: Fernando-A-Rocha Date: Fri, 24 Jan 2025 12:17:38 +0000 Subject: [PATCH] Function copy icon restyle --- web/resources/function.html | 2 +- web/resources/layout.html | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/web/resources/function.html b/web/resources/function.html index 9a60cc3..f7bc42c 100644 --- a/web/resources/function.html +++ b/web/resources/function.html @@ -9,7 +9,7 @@
{{ function.type_name|capitalize }} function

{{ function.name }} - Copy +

diff --git a/web/resources/layout.html b/web/resources/layout.html index 24bb7df..4c36946 100644 --- a/web/resources/layout.html +++ b/web/resources/layout.html @@ -115,7 +115,7 @@ }); }); - var copyTextTimer = null; + var copyTexts = {}; async function copyText(text, spanCopyText) { event.preventDefault() const type = "text/plain"; @@ -124,10 +124,16 @@ await navigator.clipboard.write(data); if (spanCopyText) { spanCopyText = document.getElementById(spanCopyText); + if (copyTexts[spanCopyText]) { + clearTimeout(copyTexts[spanCopyText]["timer"]); + } else { + copyTexts[spanCopyText] = {}; + } + copyTexts[spanCopyText]["oldText"] = spanCopyText.innerText; spanCopyText.innerText = "Copied!"; - clearTimeout(copyTextTimer); - copyTextTimer = setTimeout(() => { - spanCopyText.innerText = "Copy"; + copyTexts[spanCopyText]["timer"] = setTimeout(() => { + spanCopyText.innerText = copyTexts[spanCopyText]["oldText"]; + delete copyTexts[spanCopyText]; }, 2000); } }