@@ -185,6 +185,7 @@ const UI = {
185185 UI . initSetting ( 'bell' , 'on' ) ;
186186 UI . initSetting ( 'view_only' , false ) ;
187187 UI . initSetting ( 'show_dot' , false ) ;
188+ UI . initSetting ( 'notify_clipboard_received' , false ) ;
188189 UI . initSetting ( 'path' , 'websockify' ) ;
189190 UI . initSetting ( 'repeaterID' , '' ) ;
190191 UI . initSetting ( 'reconnect' , false ) ;
@@ -371,6 +372,8 @@ const UI = {
371372 UI . addSettingChangeHandler ( 'view_only' , UI . updateViewOnly ) ;
372373 UI . addSettingChangeHandler ( 'show_dot' ) ;
373374 UI . addSettingChangeHandler ( 'show_dot' , UI . updateShowDotCursor ) ;
375+ UI . addSettingChangeHandler ( 'notify_clipboard_received' ) ;
376+ UI . addSettingChangeHandler ( 'notify_clipboard_received' , UI . updateNotifyClipboardReceived ) ;
374377 UI . addSettingChangeHandler ( 'host' ) ;
375378 UI . addSettingChangeHandler ( 'port' ) ;
376379 UI . addSettingChangeHandler ( 'path' ) ;
@@ -892,6 +895,7 @@ const UI = {
892895 UI . updateSetting ( 'logging' ) ;
893896 UI . updateSetting ( 'reconnect' ) ;
894897 UI . updateSetting ( 'reconnect_delay' ) ;
898+ UI . updateSetting ( 'notify_clipboard_received' ) ;
895899
896900 document . getElementById ( 'noVNC_settings' )
897901 . classList . add ( "noVNC_open" ) ;
@@ -993,25 +997,17 @@ const UI = {
993997 UI . openClipboardPanel ( ) ;
994998 }
995999 } ,
996- showCopiedNotification ( ) {
997- // This is responsible for showing the notification when text is updated in the clipboard.
998- const notificationBox = document . createElement ( "div" ) ;
999- notificationBox . className = "notification" ;
1000- notificationBox . innerText = "Clipboard updated" ;
1001- document . body . appendChild ( notificationBox ) ;
10021000
1003- setTimeout ( ( ) => {
1004- notificationBox . classList . add ( "fade-out" ) ;
1005- setTimeout ( ( ) => {
1006- notificationBox . remove ( ) ;
1007- } , 500 ) ; // Wait for fade-out transition
1008- } , 3000 ) ; // Display for 3 seconds
1001+ notifyClipboardReceived ( ) {
1002+ // When enabled with setting 'notify_clipboard_received', shows
1003+ // notification when a 'clipboard-received'-event is fired by
1004+ // the RFB instance.
1005+ UI . showStatus ( _ ( 'Clipboard updated' ) , 3000 ) ;
10091006 } ,
10101007
10111008 clipboardReceive ( e ) {
10121009 Log . Debug ( ">> UI.clipboardReceive: " + e . detail . text . substr ( 0 , 40 ) + "..." ) ;
10131010 document . getElementById ( 'noVNC_clipboard_text' ) . value = e . detail . text ;
1014- UI . showCopiedNotification ( ) ;
10151011 Log . Debug ( "<< UI.clipboardReceive" ) ;
10161012 } ,
10171013
@@ -1119,6 +1115,7 @@ const UI = {
11191115
11201116 UI . updateViewOnly ( ) ; // requires UI.rfb
11211117 UI . updateClipboard ( ) ;
1118+ UI . updateNotifyClipboardReceived ( ) ;
11221119 } ,
11231120
11241121 disconnect ( ) {
@@ -1824,6 +1821,14 @@ const UI = {
18241821 UI . rfb . showDotCursor = UI . getSetting ( 'show_dot' ) ;
18251822 } ,
18261823
1824+ updateNotifyClipboardReceived ( ) {
1825+ if ( ! UI . rfb ) return ;
1826+ UI . rfb . removeEventListener ( 'clipboardreceived' , UI . notifyClipboardReceived ) ;
1827+ if ( UI . getSetting ( 'notify_clipboard_received' ) ) {
1828+ UI . rfb . addEventListener ( 'clipboardreceived' , UI . notifyClipboardReceived ) ;
1829+ }
1830+ } ,
1831+
18271832 updateLogging ( ) {
18281833 WebUtil . initLogging ( UI . getSetting ( 'logging' ) ) ;
18291834 } ,
0 commit comments