Skip to content

Commit 04b574f

Browse files
Function copy icon restyle
1 parent 3fd38a2 commit 04b574f

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

web/resources/function.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<div class="function-type-title" style="color: {{type_colors[function.type_name]}};">{{ function.type_name|capitalize }} function</div>
1010
<h1 style="border-bottom: 3px solid {{type_colors[function.type_name]}}; padding-bottom: 0.2em;">
1111
<span {% if function.disabled %}style="text-decoration: line-through;"{% endif %}>{{ function.name }}</span>
12-
<a class="small-fs" href="#" onclick="copyText('{{ function.name }}', 'copy-{{ function.name }}')"><i class="fa-regular fa-copy"></i> <span id="copy-{{ function.name }}">Copy</span> </a>
12+
<a class="small-fs" href="#" onclick="copyText('{{ function.name }}', 'copy-{{ function.name }}')"><i class="fa-regular fa-copy"></i> <span id="copy-{{ function.name }}"></span> </a>
1313
</h1>
1414

1515
<!-- Disabled Warning -->

web/resources/layout.html

+10-4
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
});
116116
});
117117

118-
var copyTextTimer = null;
118+
var copyTexts = {};
119119
async function copyText(text, spanCopyText) {
120120
event.preventDefault()
121121
const type = "text/plain";
@@ -124,10 +124,16 @@
124124
await navigator.clipboard.write(data);
125125
if (spanCopyText) {
126126
spanCopyText = document.getElementById(spanCopyText);
127+
if (copyTexts[spanCopyText]) {
128+
clearTimeout(copyTexts[spanCopyText]["timer"]);
129+
} else {
130+
copyTexts[spanCopyText] = {};
131+
}
132+
copyTexts[spanCopyText]["oldText"] = spanCopyText.innerText;
127133
spanCopyText.innerText = "Copied!";
128-
clearTimeout(copyTextTimer);
129-
copyTextTimer = setTimeout(() => {
130-
spanCopyText.innerText = "Copy";
134+
copyTexts[spanCopyText]["timer"] = setTimeout(() => {
135+
spanCopyText.innerText = copyTexts[spanCopyText]["oldText"];
136+
delete copyTexts[spanCopyText];
131137
}, 2000);
132138
}
133139
}

0 commit comments

Comments
 (0)