@@ -95,6 +95,9 @@ <h5 class="mb-0">{% trans 'Payout Details' %}</h5>
9595
9696< script >
9797 ( function ( ) {
98+ var COPIED_TEXT = '{% trans "Copied!" %}' ;
99+ var RESET_TIMEOUT = 2000 ;
100+
98101 document . getElementById ( 'copy-payout-info' ) . addEventListener ( 'click' , function ( ) {
99102 // Get the payout information
100103 var amount = document . getElementById ( 'payout-amount' ) . textContent . trim ( ) ;
@@ -109,17 +112,21 @@ <h5 class="mb-0">{% trans 'Payout Details' %}</h5>
109112 }
110113 textToCopy += 'Subject: ' + subject ;
111114
115+ // Function to show success feedback
116+ function showSuccessFeedback ( ) {
117+ var btnText = document . getElementById ( 'copy-btn-text' ) ;
118+ var originalText = btnText . textContent ;
119+ btnText . textContent = COPIED_TEXT ;
120+
121+ setTimeout ( function ( ) {
122+ btnText . textContent = originalText ;
123+ } , RESET_TIMEOUT ) ;
124+ }
125+
112126 // Copy to clipboard
113127 if ( navigator . clipboard && navigator . clipboard . writeText ) {
114128 navigator . clipboard . writeText ( textToCopy ) . then ( function ( ) {
115- // Show success feedback
116- var btnText = document . getElementById ( 'copy-btn-text' ) ;
117- var originalText = btnText . textContent ;
118- btnText . textContent = '{% trans "Copied!" %}' ;
119-
120- setTimeout ( function ( ) {
121- btnText . textContent = originalText ;
122- } , 2000 ) ;
129+ showSuccessFeedback ( ) ;
123130 } ) . catch ( function ( err ) {
124131 console . error ( 'Failed to copy text: ' , err ) ;
125132 alert ( 'Failed to copy to clipboard' ) ;
@@ -134,13 +141,7 @@ <h5 class="mb-0">{% trans 'Payout Details' %}</h5>
134141 textArea . select ( ) ;
135142 try {
136143 document . execCommand ( 'copy' ) ;
137- var btnText = document . getElementById ( 'copy-btn-text' ) ;
138- var originalText = btnText . textContent ;
139- btnText . textContent = '{% trans "Copied!" %}' ;
140-
141- setTimeout ( function ( ) {
142- btnText . textContent = originalText ;
143- } , 2000 ) ;
144+ showSuccessFeedback ( ) ;
144145 } catch ( err ) {
145146 console . error ( 'Fallback: Failed to copy text: ' , err ) ;
146147 alert ( 'Failed to copy to clipboard' ) ;
0 commit comments