File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -477,20 +477,23 @@ <h1>Verbose-O-Matic</h1>
477477 }
478478 }
479479
480- function copyOutput ( ) {
481- const output = document . getElementById ( 'outputText' ) . textContent ;
482- navigator . clipboard . writeText ( output ) . then ( ( ) => {
483- const btn = event . target . closest ( '.copy-btn' ) ;
484- const originalHTML = btn . innerHTML ;
480+ async function copyOutput ( event ) {
481+ const btn = event . target . closest ( '.copy-btn' ) ;
482+ const originalContent = btn . innerHTML ;
483+
484+ try {
485+ await navigator . clipboard . writeText ( document . getElementById ( 'outputText' ) . textContent ) ;
486+
485487 btn . classList . add ( 'copied' ) ;
486488 btn . innerHTML = '<svg width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z"/></svg> Copied!' ;
489+
487490 setTimeout ( ( ) => {
488491 btn . classList . remove ( 'copied' ) ;
489- btn . innerHTML = originalHTML
490- } , 2000 )
491- } ) . catch ( err => {
492- showAlert ( 'Failed to copy to clipboard' , 'error' )
493- } )
492+ btn . innerHTML = originalContent ;
493+ } , 2000 ) ;
494+ } catch {
495+ showAlert ( 'Failed to copy to clipboard' , 'error' ) ;
496+ }
494497 }
495498
496499 init ( )
You can’t perform that action at this time.
0 commit comments