File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 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 -->
Original file line number Diff line number Diff line change 115115 } ) ;
116116 } ) ;
117117
118- var copyTextTimer = null ;
118+ var copyTexts = { } ;
119119 async function copyText ( text , spanCopyText ) {
120120 event . preventDefault ( )
121121 const type = "text/plain" ;
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 }
You can’t perform that action at this time.
0 commit comments