File tree 2 files changed +11
-5
lines changed
2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 9
9
< div class ="function-type-title " style ="color: {{type_colors[function.type_name]}}; "> {{ function.type_name|capitalize }} function</ div >
10
10
< h1 style ="border-bottom: 3px solid {{type_colors[function.type_name]}}; padding-bottom: 0.2em; ">
11
11
< 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 >
13
13
</ h1 >
14
14
15
15
<!-- Disabled Warning -->
Original file line number Diff line number Diff line change 115
115
} ) ;
116
116
} ) ;
117
117
118
- var copyTextTimer = null ;
118
+ var copyTexts = { } ;
119
119
async function copyText ( text , spanCopyText ) {
120
120
event . preventDefault ( )
121
121
const type = "text/plain" ;
124
124
await navigator . clipboard . write ( data ) ;
125
125
if ( spanCopyText ) {
126
126
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 ;
127
133
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 ] ;
131
137
} , 2000 ) ;
132
138
}
133
139
}
You can’t perform that action at this time.
0 commit comments