Add setting for clipboard
This commit is contained in:
parent
6a1152e6b4
commit
40654f2586
22
app/ui.js
22
app/ui.js
|
|
@ -383,6 +383,8 @@ var UI = {
|
|||
UI.addSettingChangeHandler('encrypt');
|
||||
UI.addSettingChangeHandler('cursor');
|
||||
UI.addSettingChangeHandler('cursor', UI.updateLocalCursor);
|
||||
UI.addSettingChangeHandler('clipboard');
|
||||
UI.addSettingChangeHandler('clipboard', UI.updateClipboard);
|
||||
UI.addSettingChangeHandler('resize');
|
||||
UI.addSettingChangeHandler('resize', UI.enableDisableViewClip);
|
||||
UI.addSettingChangeHandler('resize', UI.applyResizeMode);
|
||||
|
|
@ -1002,23 +1004,43 @@ var UI = {
|
|||
},
|
||||
|
||||
clipboardReceive: function(rfb, text) {
|
||||
if (!UI.getSetting('clipboard')) return;
|
||||
|
||||
Log.Debug(">> UI.clipboardReceive: " + text.substr(0,40) + "...");
|
||||
document.getElementById('noVNC_clipboard_text').value = text;
|
||||
Log.Debug("<< UI.clipboardReceive");
|
||||
},
|
||||
|
||||
clipboardClear: function() {
|
||||
if (!UI.getSetting('clipboard')) return;
|
||||
|
||||
document.getElementById('noVNC_clipboard_text').value = "";
|
||||
UI.rfb.clipboardPasteFrom("");
|
||||
},
|
||||
|
||||
clipboardSend: function() {
|
||||
if (!UI.getSetting('clipboard')) return;
|
||||
|
||||
var text = document.getElementById('noVNC_clipboard_text').value;
|
||||
Log.Debug(">> UI.clipboardSend: " + text.substr(0,40) + "...");
|
||||
UI.rfb.clipboardPasteFrom(text);
|
||||
Log.Debug("<< UI.clipboardSend");
|
||||
},
|
||||
|
||||
updateClipboard: function() {
|
||||
if (!UI.rfb) return;
|
||||
|
||||
var clipboard_enabled = UI.getSetting('clipboard');
|
||||
var clipboard_button = document.getElementById('noVNC_clipboard_button');
|
||||
if (clipboard_enabled) {
|
||||
clipboard_button.disabled = false;
|
||||
UI.rfb.set_clipboard(true);
|
||||
} else {
|
||||
clipboard_button.disabled = true;
|
||||
UI.rfb.set_clipboard(false);
|
||||
}
|
||||
},
|
||||
|
||||
/* ------^-------
|
||||
* /CLIPBOARD
|
||||
* ==============
|
||||
|
|
|
|||
11
core/rfb.js
11
core/rfb.js
|
|
@ -151,6 +151,7 @@ export default function RFB(defaults) {
|
|||
'encrypt': false, // Use TLS/SSL/wss encryption
|
||||
'local_cursor': false, // Request locally rendered cursor
|
||||
'shared': true, // Request shared mode
|
||||
'clipboard': true, // Synchronize server and client clipboard contents
|
||||
'view_only': false, // Disable client mouse/keyboard
|
||||
'xvp_password_sep': '@', // Separator for XVP password fields
|
||||
'disconnectTimeout': 3, // Time (s) to wait for disconnection
|
||||
|
|
@ -356,7 +357,12 @@ RFB.prototype = {
|
|||
},
|
||||
|
||||
clipboardPasteFrom: function (text) {
|
||||
if (this._rfb_connection_state !== 'connected' || this._view_only) { return; }
|
||||
if (this._rfb_connection_state !== 'connected' ||
|
||||
this._view_only ||
|
||||
!this._clipboard) {
|
||||
|
||||
return;
|
||||
}
|
||||
RFB.messages.clientCutText(this._sock, text);
|
||||
},
|
||||
|
||||
|
|
@ -1167,7 +1173,7 @@ RFB.prototype = {
|
|||
|
||||
var text = this._sock.rQshiftStr(length);
|
||||
|
||||
if (this._view_only) { return true; }
|
||||
if (this._view_only || !this._clipboard) { return true; }
|
||||
|
||||
this._onClipboard(this, text);
|
||||
|
||||
|
|
@ -1426,6 +1432,7 @@ make_properties(RFB, [
|
|||
['encrypt', 'rw', 'bool'], // Use TLS/SSL/wss encryption
|
||||
['local_cursor', 'rw', 'bool'], // Request locally rendered cursor
|
||||
['shared', 'rw', 'bool'], // Request shared mode
|
||||
['clipboard', 'rw', 'bool'], // Synchronize server and client clipboard contents
|
||||
['view_only', 'rw', 'bool'], // Disable client mouse/keyboard
|
||||
['xvp_password_sep', 'rw', 'str'], // Separator for XVP password fields
|
||||
['disconnectTimeout', 'rw', 'int'], // Time (s) to wait for disconnection
|
||||
|
|
|
|||
3
vnc.html
3
vnc.html
|
|
@ -204,6 +204,9 @@
|
|||
<li>
|
||||
<label><input id="noVNC_setting_view_only" type="checkbox" /> View Only</label>
|
||||
</li>
|
||||
<li>
|
||||
<label><input id="noVNC_setting_clipboard" type="checkbox" /> Clipboard</label>
|
||||
</li>
|
||||
<li><hr></li>
|
||||
<li>
|
||||
<label><input id="noVNC_setting_view_clip" type="checkbox" /> Clip to Window</label>
|
||||
|
|
|
|||
Loading…
Reference in New Issue