@@ -500,6 +500,48 @@ var pcminer = (function () {
500500 $ ( "#basic-modal-content" ) . modal ( ) ;
501501 }
502502
503+ function copySelectedName ( ) {
504+ // Get the select element
505+ var selector = document . getElementById ( "selector" ) ;
506+ if ( ! selector ) {
507+ console . error ( "Selector element not found." ) ;
508+ return ;
509+ }
510+
511+ // Get the currently selected option
512+ var selectedOption = selector . options [ selector . selectedIndex ] ;
513+ if ( ! selectedOption ) {
514+ console . error ( "No option is selected." ) ;
515+ return ;
516+ }
517+
518+ var text = selectedOption . text ;
519+
520+ // Use the Clipboard API if available
521+ if ( navigator . clipboard && navigator . clipboard . writeText ) {
522+ navigator . clipboard
523+ . writeText ( text )
524+ . then ( function ( ) {
525+ console . log ( "Copied selected name: " + text ) ;
526+ } )
527+ . catch ( function ( err ) {
528+ console . error ( "Failed to copy text: " , err ) ;
529+ } ) ;
530+ } else {
531+ // Fallback method for older browsers
532+ var textarea = document . createElement ( "textarea" ) ;
533+ textarea . value = text ;
534+ document . body . appendChild ( textarea ) ;
535+ textarea . select ( ) ;
536+ try {
537+ document . execCommand ( "copy" ) ;
538+ console . log ( "Copied selected name: " + text ) ;
539+ } catch ( err ) {
540+ console . error ( "Fallback: Unable to copy text" , err ) ;
541+ }
542+ document . body . removeChild ( textarea ) ;
543+ }
544+ }
503545 /**
504546 * counts the number of publications and committees for an author in the current date range
505547 */
@@ -945,6 +987,7 @@ var pcminer = (function () {
945987 confSelected : confSelected ,
946988 confsSelected : confsSelected ,
947989 copyToClipboard : copyToClipboard ,
990+ copySelectedName : copySelectedName ,
948991 updateExcluded : updateExcluded ,
949992 main : main ,
950993 } ;
0 commit comments