2 * noVNC: HTML5 VNC client
3 * Copyright (C) 2012 Joel Martin
4 * Copyright (C) 2016 Samuel Mannehed for Cendio AB
5 * Copyright (C) 2016 Pierre Ossman for Cendio AB
6 * Licensed under MPL 2.0 (see LICENSE.txt)
8 * See README.md for usage and integration instructions.
11 /* jslint white: false, browser: true */
12 /* global window, document.getElementById, Util, WebUtil, RFB, Display */
15 * import Util from "../core/util";
16 * import KeyTable from "../core/input/keysym";
17 * import keysyms from "./keysymdef";
18 * import RFB from "../core/rfb";
19 * import Display from "../core/display";
20 * import WebUtil from "./webutil";
28 /* [begin skip-as-module] */
29 // Load supporting scripts
31 {'core': [WebUtil
.getLanguageFileLocation(), "base64.js", "websock.js",
32 "des.js", "input/keysymdef.js", "input/xtscancodes.js",
33 "input/util.js", "input/devices.js", "display.js",
34 "inflator.js", "rfb.js", "input/keysym.js"]});
36 window
.onscriptsload = function () { UI
.load(); };
37 /* [end skip-as-module] */
46 hideKeyboardTimeout
: null,
47 idleControlbarTimeout
: null,
48 closeControlbarTimeout
: null,
50 controlbarGrabbed
: false,
51 controlbarDrag
: false,
52 controlbarMouseDownClientY
: 0,
53 controlbarMouseDownOffsetY
: 0,
56 rememberedClipSetting
: null,
57 lastKeyboardinput
: null,
58 defaultKeyboardinputLen
: 100,
60 // Setup rfb object, load settings from browser storage, then call
61 // UI.init to setup the UI/menus
62 load: function(callback
) {
63 WebUtil
.initSettings(UI
.start
, callback
);
66 // Render default UI and initialize settings menu
67 start: function(callback
) {
69 // Setup global variables first
70 UI
.isSafari
= (navigator
.userAgent
.indexOf('Safari') !== -1 &&
71 navigator
.userAgent
.indexOf('Chrome') === -1);
75 // Adapt the interface for touch screen devices
76 if (Util
.isTouchDevice
) {
77 document
.documentElement
.classList
.add("noVNC_touch");
78 // Remove the address bar
79 setTimeout(function() { window
.scrollTo(0, 1); }, 100);
80 UI
.forceSetting('clip', true);
82 UI
.initSetting('clip', false);
85 // Setup and initialize event handlers
86 UI
.setupWindowEvents();
88 UI
.addControlbarHandlers();
89 UI
.addTouchSpecificHandlers();
90 UI
.addExtraKeysHandlers();
92 UI
.addConnectionControlHandlers();
93 UI
.addClipboardHandlers();
94 UI
.addSettingsHandlers();
96 // Show the connect panel on first load unless autoconnecting
98 UI
.openConnectPanel();
103 UI
.updateVisualState();
105 document
.getElementById('noVNC_setting_host').focus();
107 var autoconnect
= WebUtil
.getConfigVar('autoconnect', false);
108 if (autoconnect
=== 'true' || autoconnect
== '1') {
115 if (typeof callback
=== "function") {
120 initSettings: function() {
121 // Stylesheet selection dropdown
122 var sheet
= WebUtil
.selectStylesheet();
123 var sheets
= WebUtil
.getStylesheets();
125 for (i
= 0; i
< sheets
.length
; i
+= 1) {
126 UI
.addOption(document
.getElementById('noVNC_setting_stylesheet'),sheets
[i
].title
, sheets
[i
].title
);
129 // Logging selection dropdown
130 var llevels
= ['error', 'warn', 'info', 'debug'];
131 for (i
= 0; i
< llevels
.length
; i
+= 1) {
132 UI
.addOption(document
.getElementById('noVNC_setting_logging'),llevels
[i
], llevels
[i
]);
135 // Settings with immediate effects
136 UI
.initSetting('logging', 'warn');
137 WebUtil
.init_logging(UI
.getSetting('logging'));
139 UI
.initSetting('stylesheet', 'default');
140 WebUtil
.selectStylesheet(null);
141 // call twice to get around webkit bug
142 WebUtil
.selectStylesheet(UI
.getSetting('stylesheet'));
144 // if port == 80 (or 443) then it won't be present and should be
146 var port
= window
.location
.port
;
148 if (window
.location
.protocol
.substring(0,5) == 'https') {
151 else if (window
.location
.protocol
.substring(0,4) == 'http') {
156 /* Populate the controls if defaults are provided in the URL */
157 UI
.initSetting('host', window
.location
.hostname
);
158 UI
.initSetting('port', port
);
159 UI
.initSetting('password', '');
160 UI
.initSetting('encrypt', (window
.location
.protocol
=== "https:"));
161 UI
.initSetting('true_color', true);
162 UI
.initSetting('cursor', !Util
.isTouchDevice
);
163 UI
.initSetting('resize', 'off');
164 UI
.initSetting('shared', true);
165 UI
.initSetting('view_only', false);
166 UI
.initSetting('path', 'websockify');
167 UI
.initSetting('repeaterID', '');
168 UI
.initSetting('token', '');
171 setupWindowEvents: function() {
172 window
.addEventListener('resize', UI
.applyResizeMode
);
173 window
.addEventListener('resize', UI
.updateViewClip
);
174 window
.addEventListener('resize', UI
.updateViewDrag
);
176 document
.getElementById("noVNC_status")
177 .addEventListener('click', UI
.hideStatus
);
180 setupFullscreen: function() {
181 // Only show the button if fullscreen is properly supported
182 // * Safari doesn't support alphanumerical input while in fullscreen
184 (document
.documentElement
.requestFullscreen
||
185 document
.documentElement
.mozRequestFullScreen
||
186 document
.documentElement
.webkitRequestFullscreen
||
187 document
.body
.msRequestFullscreen
)) {
188 document
.getElementById('noVNC_fullscreen_button')
189 .classList
.remove("noVNC_hidden");
190 UI
.addFullscreenHandlers();
194 addControlbarHandlers: function() {
195 document
.getElementById("noVNC_control_bar")
196 .addEventListener('mousemove', UI
.activateControlbar
);
197 document
.getElementById("noVNC_control_bar")
198 .addEventListener('mouseup', UI
.activateControlbar
);
199 document
.getElementById("noVNC_control_bar")
200 .addEventListener('mousedown', UI
.activateControlbar
);
201 document
.getElementById("noVNC_control_bar")
202 .addEventListener('keypress', UI
.activateControlbar
);
204 document
.getElementById("noVNC_control_bar")
205 .addEventListener('mousedown', UI
.keepControlbar
);
206 document
.getElementById("noVNC_control_bar")
207 .addEventListener('keypress', UI
.keepControlbar
);
209 document
.getElementById("noVNC_view_drag_button")
210 .addEventListener('click', UI
.toggleViewDrag
);
212 document
.getElementById("noVNC_control_bar_handle")
213 .addEventListener('mousedown', UI
.controlbarHandleMouseDown
);
214 document
.getElementById("noVNC_control_bar_handle")
215 .addEventListener('mouseup', UI
.controlbarHandleMouseUp
);
216 document
.getElementById("noVNC_control_bar_handle")
217 .addEventListener('mousemove', UI
.dragControlbarHandle
);
218 // resize events aren't available for elements
219 window
.addEventListener('resize', UI
.updateControlbarHandle
);
222 addTouchSpecificHandlers: function() {
223 document
.getElementById("noVNC_mouse_button0")
224 .addEventListener('click', function () { UI
.setMouseButton(1); });
225 document
.getElementById("noVNC_mouse_button1")
226 .addEventListener('click', function () { UI
.setMouseButton(2); });
227 document
.getElementById("noVNC_mouse_button2")
228 .addEventListener('click', function () { UI
.setMouseButton(4); });
229 document
.getElementById("noVNC_mouse_button4")
230 .addEventListener('click', function () { UI
.setMouseButton(0); });
231 document
.getElementById("noVNC_keyboard_button")
232 .addEventListener('click', UI
.toggleVirtualKeyboard
);
234 document
.getElementById("noVNC_keyboardinput")
235 .addEventListener('input', UI
.keyInput
);
236 document
.getElementById("noVNC_keyboardinput")
237 .addEventListener('focus', UI
.onfocusVirtualKeyboard
);
238 document
.getElementById("noVNC_keyboardinput")
239 .addEventListener('blur', UI
.onblurVirtualKeyboard
);
240 document
.getElementById("noVNC_keyboardinput")
241 .addEventListener('submit', function () { return false; });
243 document
.documentElement
244 .addEventListener('mousedown', UI
.keepVirtualKeyboard
, true);
246 document
.getElementById("noVNC_control_bar")
247 .addEventListener('touchstart', UI
.activateControlbar
);
248 document
.getElementById("noVNC_control_bar")
249 .addEventListener('touchmove', UI
.activateControlbar
);
250 document
.getElementById("noVNC_control_bar")
251 .addEventListener('touchend', UI
.activateControlbar
);
252 document
.getElementById("noVNC_control_bar")
253 .addEventListener('input', UI
.activateControlbar
);
255 document
.getElementById("noVNC_control_bar")
256 .addEventListener('touchstart', UI
.keepControlbar
);
257 document
.getElementById("noVNC_control_bar")
258 .addEventListener('input', UI
.keepControlbar
);
260 document
.getElementById("noVNC_control_bar_handle")
261 .addEventListener('touchstart', UI
.controlbarHandleMouseDown
);
262 document
.getElementById("noVNC_control_bar_handle")
263 .addEventListener('touchend', UI
.controlbarHandleMouseUp
);
264 document
.getElementById("noVNC_control_bar_handle")
265 .addEventListener('touchmove', UI
.dragControlbarHandle
);
267 window
.addEventListener('load', UI
.keyboardinputReset
);
270 addExtraKeysHandlers: function() {
271 document
.getElementById("noVNC_toggle_extra_keys_button")
272 .addEventListener('click', UI
.toggleExtraKeys
);
273 document
.getElementById("noVNC_toggle_ctrl_button")
274 .addEventListener('click', UI
.toggleCtrl
);
275 document
.getElementById("noVNC_toggle_alt_button")
276 .addEventListener('click', UI
.toggleAlt
);
277 document
.getElementById("noVNC_send_tab_button")
278 .addEventListener('click', UI
.sendTab
);
279 document
.getElementById("noVNC_send_esc_button")
280 .addEventListener('click', UI
.sendEsc
);
281 document
.getElementById("noVNC_send_ctrl_alt_del_button")
282 .addEventListener('click', UI
.sendCtrlAltDel
);
285 addXvpHandlers: function() {
286 document
.getElementById("noVNC_xvp_shutdown_button")
287 .addEventListener('click', function() { UI
.rfb
.xvpShutdown(); });
288 document
.getElementById("noVNC_xvp_reboot_button")
289 .addEventListener('click', function() { UI
.rfb
.xvpReboot(); });
290 document
.getElementById("noVNC_xvp_reset_button")
291 .addEventListener('click', function() { UI
.rfb
.xvpReset(); });
292 document
.getElementById("noVNC_xvp_button")
293 .addEventListener('click', UI
.toggleXvpPanel
);
296 addConnectionControlHandlers: function() {
297 document
.getElementById("noVNC_connect_controls_button")
298 .addEventListener('click', UI
.toggleConnectPanel
);
299 document
.getElementById("noVNC_disconnect_button")
300 .addEventListener('click', UI
.disconnect
);
301 document
.getElementById("noVNC_connect_button")
302 .addEventListener('click', UI
.connect
);
304 document
.getElementById("noVNC_password_button")
305 .addEventListener('click', UI
.setPassword
);
308 addClipboardHandlers: function() {
309 document
.getElementById("noVNC_clipboard_button")
310 .addEventListener('click', UI
.toggleClipboardPanel
);
311 document
.getElementById("noVNC_clipboard_text")
312 .addEventListener('focus', UI
.displayBlur
);
313 document
.getElementById("noVNC_clipboard_text")
314 .addEventListener('blur', UI
.displayFocus
);
315 document
.getElementById("noVNC_clipboard_text")
316 .addEventListener('change', UI
.clipboardSend
);
317 document
.getElementById("noVNC_clipboard_clear_button")
318 .addEventListener('click', UI
.clipboardClear
);
321 addSettingsHandlers: function() {
322 document
.getElementById("noVNC_settings_button")
323 .addEventListener('click', UI
.toggleSettingsPanel
);
324 document
.getElementById("noVNC_settings_apply")
325 .addEventListener('click', UI
.settingsApply
);
327 document
.getElementById("noVNC_setting_resize")
328 .addEventListener('change', UI
.enableDisableViewClip
);
331 addFullscreenHandlers: function() {
332 document
.getElementById("noVNC_fullscreen_button")
333 .addEventListener('click', UI
.toggleFullscreen
);
335 window
.addEventListener('fullscreenchange', UI
.updateFullscreenButton
);
336 window
.addEventListener('mozfullscreenchange', UI
.updateFullscreenButton
);
337 window
.addEventListener('webkitfullscreenchange', UI
.updateFullscreenButton
);
338 window
.addEventListener('msfullscreenchange', UI
.updateFullscreenButton
);
341 initRFB: function() {
343 UI
.rfb
= new RFB({'target': document
.getElementById('noVNC_canvas'),
344 'onNotification': UI
.notification
,
345 'onUpdateState': UI
.updateState
,
346 'onDisconnected': UI
.disconnectFinished
,
347 'onPasswordRequired': UI
.passwordRequired
,
348 'onXvpInit': UI
.updateXvpButton
,
349 'onClipboard': UI
.clipboardReceive
,
351 'onFBUComplete': UI
.initialResize
,
352 'onFBResize': UI
.updateViewDrag
,
353 'onDesktopName': UI
.updateDesktopName
});
356 var msg
= "Unable to create RFB client -- " + exc
;
358 UI
.showStatus(msg
, 'error');
369 updateState: function(rfb
, state
, oldstate
) {
372 document
.documentElement
.classList
.remove("noVNC_connecting");
373 document
.documentElement
.classList
.remove("noVNC_connected");
374 document
.documentElement
.classList
.remove("noVNC_disconnecting");
378 document
.getElementById("noVNC_transition_text").innerHTML
= Util
.Localisation
.get("Connecting...");
379 document
.documentElement
.classList
.add("noVNC_connecting");
383 document
.documentElement
.classList
.add("noVNC_connected");
384 if (rfb
&& rfb
.get_encrypt()) {
385 msg
= Util
.Localisation
.get("Connected (encrypted) to ") + UI
.desktopName
;
387 msg
= Util
.Localisation
.get("Connected (unencrypted) to ") + UI
.desktopName
;
391 case 'disconnecting':
392 document
.getElementById("noVNC_transition_text").innerHTML
= Util
.Localisation
.get("Disconnecting...");
393 document
.documentElement
.classList
.add("noVNC_disconnecting");
396 UI
.connected
= false;
397 UI
.showStatus(Util
.Localisation
.get("Disconnected"));
400 msg
= "Invalid UI state";
402 UI
.showStatus(msg
, 'error');
406 UI
.updateVisualState();
409 // Disable/enable controls depending on connection state
410 updateVisualState: function() {
411 //Util.Debug(">> updateVisualState");
412 document
.getElementById('noVNC_setting_encrypt').disabled
= UI
.connected
;
413 document
.getElementById('noVNC_setting_true_color').disabled
= UI
.connected
;
414 if (Util
.browserSupportsCursorURIs()) {
415 document
.getElementById('noVNC_setting_cursor').disabled
= UI
.connected
;
417 UI
.updateSetting('cursor', !Util
.isTouchDevice
);
418 document
.getElementById('noVNC_setting_cursor').disabled
= true;
421 UI
.enableDisableViewClip();
422 document
.getElementById('noVNC_setting_resize').disabled
= UI
.connected
;
423 document
.getElementById('noVNC_setting_shared').disabled
= UI
.connected
;
424 document
.getElementById('noVNC_setting_view_only').disabled
= UI
.connected
;
425 document
.getElementById('noVNC_setting_path').disabled
= UI
.connected
;
426 document
.getElementById('noVNC_setting_repeaterID').disabled
= UI
.connected
;
430 UI
.setMouseButton(1);
432 // Hide the controlbar after 2 seconds
433 UI
.closeControlbarTimeout
= setTimeout(UI
.closeControlbar
, 2000);
435 UI
.updateXvpButton(0);
439 // Hide input related buttons in view only mode
440 if (UI
.rfb
&& UI
.rfb
.get_view_only()) {
441 document
.getElementById('noVNC_keyboard_button')
442 .classList
.add('noVNC_hidden');
443 document
.getElementById('noVNC_toggle_extra_keys_button')
444 .classList
.add('noVNC_hidden');
446 document
.getElementById('noVNC_keyboard_button')
447 .classList
.remove('noVNC_hidden');
448 document
.getElementById('noVNC_toggle_extra_keys_button')
449 .classList
.remove('noVNC_hidden');
452 // State change disables viewport dragging.
453 // It is enabled (toggled) by direct click on the button
454 UI
.setViewDrag(false);
456 // State change also closes the password dialog
457 document
.getElementById('noVNC_password_dlg')
458 .classList
.remove('noVNC_open');
460 //Util.Debug("<< updateVisualState");
463 showStatus: function(text
, status_type
, time
) {
464 var statusElem
= document
.getElementById('noVNC_status');
466 clearTimeout(UI
.statusTimeout
);
468 if (typeof status_type
=== 'undefined') {
469 status_type
= 'normal';
472 statusElem
.classList
.remove("noVNC_status_normal",
474 "noVNC_status_error");
476 switch (status_type
) {
479 statusElem
.classList
.add("noVNC_status_warn");
482 statusElem
.classList
.add("noVNC_status_error");
487 statusElem
.classList
.add("noVNC_status_normal");
491 statusElem
.innerHTML
= text
;
492 statusElem
.classList
.add("noVNC_open");
494 // If no time was specified, show the status for 1.5 seconds
495 if (typeof time
=== 'undefined') {
499 // Error messages do not timeout
500 if (status_type
!== 'error') {
501 UI
.statusTimeout
= window
.setTimeout(UI
.hideStatus
, time
);
505 hideStatus: function() {
506 clearTimeout(UI
.statusTimeout
);
507 document
.getElementById('noVNC_status').classList
.remove("noVNC_open");
510 notification: function (rfb
, msg
, level
, options
) {
511 UI
.showStatus(msg
, level
);
514 activateControlbar: function(event
) {
515 clearTimeout(UI
.idleControlbarTimeout
);
516 // We manipulate the anchor instead of the actual control
517 // bar in order to avoid creating new a stacking group
518 document
.getElementById('noVNC_control_bar_anchor')
519 .classList
.remove("noVNC_idle");
520 UI
.idleControlbarTimeout
= window
.setTimeout(UI
.idleControlbar
, 2000);
523 idleControlbar: function() {
524 document
.getElementById('noVNC_control_bar_anchor')
525 .classList
.add("noVNC_idle");
528 keepControlbar: function() {
529 clearTimeout(UI
.closeControlbarTimeout
);
532 openControlbar: function() {
533 document
.getElementById('noVNC_control_bar')
534 .classList
.add("noVNC_open");
537 closeControlbar: function() {
539 document
.getElementById('noVNC_control_bar')
540 .classList
.remove("noVNC_open");
543 toggleControlbar: function() {
544 if (document
.getElementById('noVNC_control_bar')
545 .classList
.contains("noVNC_open")) {
546 UI
.closeControlbar();
552 dragControlbarHandle: function (e
) {
553 if (!UI
.controlbarGrabbed
) return;
555 var ptr
= Util
.getPointerEvent(e
);
557 if (!UI
.controlbarDrag
) {
558 // The goal is to trigger on a certain physical width, the
559 // devicePixelRatio brings us a bit closer but is not optimal.
560 var dragThreshold
= 10 * (window
.devicePixelRatio
|| 1);
561 var dragDistance
= Math
.abs(ptr
.clientY
- UI
.controlbarMouseDownClientY
);
563 if (dragDistance
< dragThreshold
) return;
565 UI
.controlbarDrag
= true;
568 var eventY
= ptr
.clientY
- UI
.controlbarMouseDownOffsetY
;
570 UI
.moveControlbarHandle(eventY
);
576 // Move the handle but don't allow any position outside the bounds
577 moveControlbarHandle: function (viewportRelativeY
) {
578 var handle
= document
.getElementById("noVNC_control_bar_handle");
579 var handleHeight
= handle
.getBoundingClientRect().height
;
580 var controlbarBounds
= document
.getElementById("noVNC_control_bar")
581 .getBoundingClientRect();
584 // These heights need to be non-zero for the below logic to work
585 if (handleHeight
=== 0 || controlbarBounds
.height
=== 0) {
589 var newY
= viewportRelativeY
;
591 // Check if the coordinates are outside the control bar
592 if (newY
< controlbarBounds
.top
+ margin
) {
593 // Force coordinates to be below the top of the control bar
594 newY
= controlbarBounds
.top
+ margin
;
596 } else if (newY
> controlbarBounds
.top
+
597 controlbarBounds
.height
- handleHeight
- margin
) {
598 // Force coordinates to be above the bottom of the control bar
599 newY
= controlbarBounds
.top
+
600 controlbarBounds
.height
- handleHeight
- margin
;
603 // Corner case: control bar too small for stable position
604 if (controlbarBounds
.height
< (handleHeight
+ margin
* 2)) {
605 newY
= controlbarBounds
.top
+
606 (controlbarBounds
.height
- handleHeight
) / 2;
609 // The transform needs coordinates that are relative to the parent
610 var parentRelativeY
= newY
- controlbarBounds
.top
;
611 handle
.style
.transform
= "translateY(" + parentRelativeY
+ "px)";
614 updateControlbarHandle: function () {
615 // Since the control bar is fixed on the viewport and not the page,
616 // the move function expects coordinates relative the the viewport.
617 var handle
= document
.getElementById("noVNC_control_bar_handle");
618 var handleBounds
= handle
.getBoundingClientRect();
619 UI
.moveControlbarHandle(handleBounds
.top
);
622 controlbarHandleMouseUp: function(e
) {
623 if ((e
.type
== "mouseup") && (e
.button
!= 0)) return;
625 // mouseup and mousedown on the same place toggles the controlbar
626 if (UI
.controlbarGrabbed
&& !UI
.controlbarDrag
) {
627 UI
.toggleControlbar();
631 UI
.controlbarGrabbed
= false;
634 controlbarHandleMouseDown: function(e
) {
635 if ((e
.type
== "mousedown") && (e
.button
!= 0)) return;
637 var ptr
= Util
.getPointerEvent(e
);
639 var handle
= document
.getElementById("noVNC_control_bar_handle");
640 var bounds
= handle
.getBoundingClientRect();
642 WebUtil
.setCapture(handle
);
643 UI
.controlbarGrabbed
= true;
644 UI
.controlbarDrag
= false;
646 UI
.controlbarMouseDownClientY
= ptr
.clientY
;
647 UI
.controlbarMouseDownOffsetY
= ptr
.clientY
- bounds
.top
;
658 // Initial page load read/initialization of settings
659 initSetting: function(name
, defVal
) {
660 // Check Query string followed by cookie
661 var val
= WebUtil
.getConfigVar(name
);
663 val
= WebUtil
.readSetting(name
, defVal
);
665 UI
.updateSetting(name
, val
);
669 // Update cookie and form control setting. If value is not set, then
670 // updates from control to current cookie setting.
671 updateSetting: function(name
, value
) {
673 // Save the cookie for this session
674 if (typeof value
!== 'undefined') {
675 WebUtil
.writeSetting(name
, value
);
678 // Update the settings control
679 value
= UI
.getSetting(name
);
681 var ctrl
= document
.getElementById('noVNC_setting_' + name
);
682 if (ctrl
.type
=== 'checkbox') {
683 ctrl
.checked
= value
;
685 } else if (typeof ctrl
.options
!== 'undefined') {
686 for (var i
= 0; i
< ctrl
.options
.length
; i
+= 1) {
687 if (ctrl
.options
[i
].value
=== value
) {
688 ctrl
.selectedIndex
= i
;
693 /*Weird IE9 error leads to 'null' appearring
694 in textboxes instead of ''.*/
695 if (value
=== null) {
702 // Save control setting to cookie
703 saveSetting: function(name
) {
704 var val
, ctrl
= document
.getElementById('noVNC_setting_' + name
);
705 if (ctrl
.type
=== 'checkbox') {
707 } else if (typeof ctrl
.options
!== 'undefined') {
708 val
= ctrl
.options
[ctrl
.selectedIndex
].value
;
712 WebUtil
.writeSetting(name
, val
);
713 //Util.Debug("Setting saved '" + name + "=" + val + "'");
717 // Force a setting to be a certain value
718 forceSetting: function(name
, val
) {
719 UI
.updateSetting(name
, val
);
723 // Read form control compatible setting from cookie
724 getSetting: function(name
) {
725 var ctrl
= document
.getElementById('noVNC_setting_' + name
);
726 var val
= WebUtil
.readSetting(name
);
727 if (typeof val
!== 'undefined' && val
!== null && ctrl
.type
=== 'checkbox') {
728 if (val
.toString().toLowerCase() in {'0':1, 'no':1, 'false':1}) {
737 // Save/apply settings when 'Apply' button is pressed
738 settingsApply: function() {
739 //Util.Debug(">> settingsApply");
740 UI
.saveSetting('encrypt');
741 UI
.saveSetting('true_color');
742 if (Util
.browserSupportsCursorURIs()) {
743 UI
.saveSetting('cursor');
746 UI
.saveSetting('resize');
748 if (UI
.getSetting('resize') === 'downscale' || UI
.getSetting('resize') === 'scale') {
749 UI
.forceSetting('clip', false);
752 UI
.saveSetting('clip');
753 UI
.saveSetting('shared');
754 UI
.saveSetting('view_only');
755 UI
.saveSetting('path');
756 UI
.saveSetting('repeaterID');
757 UI
.saveSetting('stylesheet');
758 UI
.saveSetting('logging');
760 // Settings with immediate (non-connected related) effect
761 WebUtil
.selectStylesheet(UI
.getSetting('stylesheet'));
762 WebUtil
.init_logging(UI
.getSetting('logging'));
765 //Util.Debug("<< settingsApply");
774 closeAllPanels: function() {
775 UI
.closeSettingsPanel();
777 UI
.closeClipboardPanel();
778 UI
.closeConnectPanel();
788 openSettingsPanel: function() {
792 UI
.updateSetting('encrypt');
793 UI
.updateSetting('true_color');
794 if (Util
.browserSupportsCursorURIs()) {
795 UI
.updateSetting('cursor');
797 UI
.updateSetting('cursor', !Util
.isTouchDevice
);
798 document
.getElementById('noVNC_setting_cursor').disabled
= true;
800 UI
.updateSetting('clip');
801 UI
.updateSetting('resize');
802 UI
.updateSetting('shared');
803 UI
.updateSetting('view_only');
804 UI
.updateSetting('path');
805 UI
.updateSetting('repeaterID');
806 UI
.updateSetting('stylesheet');
807 UI
.updateSetting('logging');
809 document
.getElementById('noVNC_settings')
810 .classList
.add("noVNC_open");
811 document
.getElementById('noVNC_settings_button')
812 .classList
.add("noVNC_selected");
815 closeSettingsPanel: function() {
816 document
.getElementById('noVNC_settings')
817 .classList
.remove("noVNC_open");
818 document
.getElementById('noVNC_settings_button')
819 .classList
.remove("noVNC_selected");
822 // Toggle the settings menu:
823 // On open, settings are refreshed from saved cookies.
824 // On close, settings are applied
825 toggleSettingsPanel: function() {
826 if (document
.getElementById('noVNC_settings')
827 .classList
.contains("noVNC_open")) {
829 UI
.closeSettingsPanel();
831 UI
.openSettingsPanel();
841 openXvpPanel: function() {
845 document
.getElementById('noVNC_xvp')
846 .classList
.add("noVNC_open");
847 document
.getElementById('noVNC_xvp_button')
848 .classList
.add("noVNC_selected");
851 closeXvpPanel: function() {
852 document
.getElementById('noVNC_xvp')
853 .classList
.remove("noVNC_open");
854 document
.getElementById('noVNC_xvp_button')
855 .classList
.remove("noVNC_selected");
858 toggleXvpPanel: function() {
859 if (document
.getElementById('noVNC_xvp')
860 .classList
.contains("noVNC_open")) {
867 // Disable/enable XVP button
868 updateXvpButton: function(ver
) {
869 if (ver
>= 1 && !UI
.rfb
.get_view_only()) {
870 document
.getElementById('noVNC_xvp_button')
871 .classList
.remove("noVNC_hidden");
873 document
.getElementById('noVNC_xvp_button')
874 .classList
.add("noVNC_hidden");
875 // Close XVP panel if open
886 openClipboardPanel: function() {
890 document
.getElementById('noVNC_clipboard')
891 .classList
.add("noVNC_open");
892 document
.getElementById('noVNC_clipboard_button')
893 .classList
.add("noVNC_selected");
896 closeClipboardPanel: function() {
897 document
.getElementById('noVNC_clipboard')
898 .classList
.remove("noVNC_open");
899 document
.getElementById('noVNC_clipboard_button')
900 .classList
.remove("noVNC_selected");
903 toggleClipboardPanel: function() {
904 if (document
.getElementById('noVNC_clipboard')
905 .classList
.contains("noVNC_open")) {
906 UI
.closeClipboardPanel();
908 UI
.openClipboardPanel();
912 clipboardReceive: function(rfb
, text
) {
913 Util
.Debug(">> UI.clipboardReceive: " + text
.substr(0,40) + "...");
914 document
.getElementById('noVNC_clipboard_text').value
= text
;
915 Util
.Debug("<< UI.clipboardReceive");
918 clipboardClear: function() {
919 document
.getElementById('noVNC_clipboard_text').value
= "";
920 UI
.rfb
.clipboardPasteFrom("");
923 clipboardSend: function() {
924 var text
= document
.getElementById('noVNC_clipboard_text').value
;
925 Util
.Debug(">> UI.clipboardSend: " + text
.substr(0,40) + "...");
926 UI
.rfb
.clipboardPasteFrom(text
);
927 Util
.Debug("<< UI.clipboardSend");
936 openConnectPanel: function() {
940 document
.getElementById('noVNC_connect_controls')
941 .classList
.add("noVNC_open");
942 document
.getElementById('noVNC_connect_controls_button')
943 .classList
.add("noVNC_selected");
945 document
.getElementById('noVNC_setting_host').focus();
948 closeConnectPanel: function() {
949 document
.getElementById('noVNC_connect_controls')
950 .classList
.remove("noVNC_open");
951 document
.getElementById('noVNC_connect_controls_button')
952 .classList
.remove("noVNC_selected");
954 UI
.saveSetting('host');
955 UI
.saveSetting('port');
956 UI
.saveSetting('token');
957 //UI.saveSetting('password');
960 toggleConnectPanel: function() {
961 if (document
.getElementById('noVNC_connect_controls')
962 .classList
.contains("noVNC_open")) {
963 UI
.closeConnectPanel();
965 UI
.openConnectPanel();
969 connect: function() {
970 var host
= document
.getElementById('noVNC_setting_host').value
;
971 var port
= document
.getElementById('noVNC_setting_port').value
;
972 var password
= document
.getElementById('noVNC_setting_password').value
;
973 var token
= document
.getElementById('noVNC_setting_token').value
;
974 var path
= document
.getElementById('noVNC_setting_path').value
;
976 //if token is in path then ignore the new token variable
978 path
= WebUtil
.injectParamIfMissing(path
, "token", token
);
981 if ((!host
) || (!port
)) {
982 var msg
= Util
.Localisation
.get("Must set host and port");
984 UI
.showStatus(msg
, 'error');
988 if (!UI
.initRFB()) return;
992 UI
.rfb
.set_encrypt(UI
.getSetting('encrypt'));
993 UI
.rfb
.set_true_color(UI
.getSetting('true_color'));
994 UI
.rfb
.set_local_cursor(UI
.getSetting('cursor'));
995 UI
.rfb
.set_shared(UI
.getSetting('shared'));
996 UI
.rfb
.set_view_only(UI
.getSetting('view_only'));
997 UI
.rfb
.set_repeaterID(UI
.getSetting('repeaterID'));
999 UI
.rfb
.connect(host
, port
, password
, path
);
1002 disconnect: function() {
1003 UI
.closeAllPanels();
1004 UI
.rfb
.disconnect();
1006 // Restore the callback used for initial resize
1007 UI
.rfb
.set_onFBUComplete(UI
.initialResize
);
1009 // Don't display the connection settings until we're actually disconnected
1012 disconnectFinished: function (rfb
, reason
) {
1013 if (typeof reason
!== 'undefined') {
1014 UI
.showStatus(reason
, 'error');
1016 UI
.openConnectPanel();
1025 passwordRequired: function(rfb
, msg
) {
1027 document
.getElementById('noVNC_password_dlg')
1028 .classList
.add('noVNC_open');
1030 setTimeout(function () {
1031 document
.getElementById('noVNC_password_input').focus();
1034 if (typeof msg
=== 'undefined') {
1035 msg
= "Password is required";
1038 UI
.showStatus(msg
, "warning");
1041 setPassword: function() {
1042 UI
.rfb
.sendPassword(document
.getElementById('noVNC_password_input').value
);
1043 document
.getElementById('noVNC_password_dlg')
1044 .classList
.remove('noVNC_open');
1054 toggleFullscreen: function() {
1055 if (document
.fullscreenElement
|| // alternative standard method
1056 document
.mozFullScreenElement
|| // currently working methods
1057 document
.webkitFullscreenElement
||
1058 document
.msFullscreenElement
) {
1059 if (document
.exitFullscreen
) {
1060 document
.exitFullscreen();
1061 } else if (document
.mozCancelFullScreen
) {
1062 document
.mozCancelFullScreen();
1063 } else if (document
.webkitExitFullscreen
) {
1064 document
.webkitExitFullscreen();
1065 } else if (document
.msExitFullscreen
) {
1066 document
.msExitFullscreen();
1069 if (document
.documentElement
.requestFullscreen
) {
1070 document
.documentElement
.requestFullscreen();
1071 } else if (document
.documentElement
.mozRequestFullScreen
) {
1072 document
.documentElement
.mozRequestFullScreen();
1073 } else if (document
.documentElement
.webkitRequestFullscreen
) {
1074 document
.documentElement
.webkitRequestFullscreen(Element
.ALLOW_KEYBOARD_INPUT
);
1075 } else if (document
.body
.msRequestFullscreen
) {
1076 document
.body
.msRequestFullscreen();
1079 UI
.enableDisableViewClip();
1080 UI
.updateFullscreenButton();
1083 updateFullscreenButton: function() {
1084 if (document
.fullscreenElement
|| // alternative standard method
1085 document
.mozFullScreenElement
|| // currently working methods
1086 document
.webkitFullscreenElement
||
1087 document
.msFullscreenElement
) {
1088 document
.getElementById('noVNC_fullscreen_button')
1089 .classList
.add("noVNC_selected");
1091 document
.getElementById('noVNC_fullscreen_button')
1092 .classList
.remove("noVNC_selected");
1102 // Apply remote resizing or local scaling
1103 applyResizeMode: function() {
1104 if (!UI
.rfb
) return;
1106 var screen
= UI
.screenSize();
1108 if (screen
&& UI
.connected
&& UI
.rfb
.get_display()) {
1110 var display
= UI
.rfb
.get_display();
1111 var resizeMode
= UI
.getSetting('resize');
1113 if (resizeMode
=== 'remote') {
1115 // Request changing the resolution of the remote display to
1116 // the size of the local browser viewport.
1118 // In order to not send multiple requests before the browser-resize
1119 // is finished we wait 0.5 seconds before sending the request.
1120 clearTimeout(UI
.resizeTimeout
);
1121 UI
.resizeTimeout
= setTimeout(function(){
1123 // Limit the viewport to the size of the browser window
1124 display
.set_maxWidth(screen
.w
);
1125 display
.set_maxHeight(screen
.h
);
1127 // Request a remote size covering the viewport
1128 if (UI
.rfb
.requestDesktopSize(screen
.w
, screen
.h
)) {
1129 Util
.Debug('Requested new desktop size: ' +
1130 screen
.w
+ 'x' + screen
.h
);
1134 } else if (resizeMode
=== 'scale' || resizeMode
=== 'downscale') {
1135 var downscaleOnly
= resizeMode
=== 'downscale';
1136 var scaleRatio
= display
.autoscale(screen
.w
, screen
.h
, downscaleOnly
);
1138 if (!UI
.rfb
.get_view_only()) {
1139 UI
.rfb
.get_mouse().set_scale(scaleRatio
);
1140 Util
.Debug('Scaling by ' + UI
.rfb
.get_mouse().get_scale());
1146 // Gets the the size of the available viewport in the browser window
1147 screenSize: function() {
1148 var screen
= document
.getElementById('noVNC_screen');
1150 // Hide the scrollbars until the size is calculated
1151 screen
.style
.overflow
= "hidden";
1153 var pos
= Util
.getPosition(screen
);
1157 screen
.style
.overflow
= "visible";
1159 if (isNaN(w
) || isNaN(h
)) {
1162 return {w
: w
, h
: h
};
1166 // Normally we only apply the current resize mode after a window resize
1167 // event. This means that when a new connection is opened, there is no
1168 // resize mode active.
1169 // We have to wait until the first FBU because this is where the client
1170 // will find the supported encodings of the server. Some calls later in
1171 // the chain is dependant on knowing the server-capabilities.
1172 initialResize: function(rfb
, fbu
) {
1173 UI
.applyResizeMode();
1174 // After doing this once, we remove the callback.
1175 UI
.rfb
.set_onFBUComplete(function() { });
1184 // Set and configure viewport clipping
1185 setViewClip: function(clip
) {
1186 UI
.updateSetting('clip', clip
);
1187 UI
.updateViewClip();
1190 // Update parameters that depend on the clip setting
1191 updateViewClip: function() {
1192 if (!UI
.rfb
) return;
1194 var display
= UI
.rfb
.get_display();
1195 var cur_clip
= display
.get_viewport();
1196 var new_clip
= UI
.getSetting('clip');
1198 if (cur_clip
!== new_clip
) {
1199 display
.set_viewport(new_clip
);
1202 var size
= UI
.screenSize();
1204 if (new_clip
&& size
) {
1205 // When clipping is enabled, the screen is limited to
1206 // the size of the browser window.
1207 display
.set_maxWidth(size
.w
);
1208 display
.set_maxHeight(size
.h
);
1210 var screen
= document
.getElementById('noVNC_screen');
1211 var canvas
= document
.getElementById('noVNC_canvas');
1213 // Hide potential scrollbars that can skew the position
1214 screen
.style
.overflow
= "hidden";
1216 // The x position marks the left margin of the canvas,
1217 // remove the margin from both sides to keep it centered.
1218 var new_w
= size
.w
- (2 * Util
.getPosition(canvas
).x
);
1220 screen
.style
.overflow
= "visible";
1222 display
.viewportChangeSize(new_w
, size
.h
);
1224 // Disable max dimensions
1225 display
.set_maxWidth(0);
1226 display
.set_maxHeight(0);
1227 display
.viewportChangeSize();
1231 // Handle special cases where clipping is forced on/off or locked
1232 enableDisableViewClip: function() {
1233 var resizeSetting
= document
.getElementById('noVNC_setting_resize');
1236 // Safari auto-hides the scrollbars which makes them
1237 // impossible to use in most cases
1238 UI
.setViewClip(true);
1239 document
.getElementById('noVNC_setting_clip').disabled
= true;
1240 } else if (resizeSetting
.value
=== 'downscale' || resizeSetting
.value
=== 'scale') {
1241 // Disable clipping if we are scaling
1242 UI
.setViewClip(false);
1243 document
.getElementById('noVNC_setting_clip').disabled
= true;
1244 } else if (document
.msFullscreenElement
) {
1245 // The browser is IE and we are in fullscreen mode.
1246 // - We need to force clipping while in fullscreen since
1247 // scrollbars doesn't work.
1248 var msg
= Util
.Localisation
.get("Forcing clipping mode since " +
1249 "scrollbars aren't supported " +
1250 "by IE in fullscreen");
1253 UI
.rememberedClipSetting
= UI
.getSetting('clip');
1254 UI
.setViewClip(true);
1255 document
.getElementById('noVNC_setting_clip').disabled
= true;
1256 } else if (document
.body
.msRequestFullscreen
&&
1257 UI
.rememberedClipSetting
!== null) {
1258 // Restore view clip to what it was before fullscreen on IE
1259 UI
.setViewClip(UI
.rememberedClipSetting
);
1260 document
.getElementById('noVNC_setting_clip').disabled
=
1261 UI
.connected
|| Util
.isTouchDevice
;
1263 document
.getElementById('noVNC_setting_clip').disabled
=
1264 UI
.connected
|| Util
.isTouchDevice
;
1265 if (Util
.isTouchDevice
) {
1266 UI
.setViewClip(true);
1277 toggleViewDrag: function() {
1278 if (!UI
.rfb
) return;
1280 var drag
= UI
.rfb
.get_viewportDrag();
1281 UI
.setViewDrag(!drag
);
1284 // Set the view drag mode which moves the viewport on mouse drags
1285 setViewDrag: function(drag
) {
1286 if (!UI
.rfb
) return;
1288 UI
.rfb
.set_viewportDrag(drag
);
1290 UI
.updateViewDrag();
1293 updateViewDrag: function() {
1294 var clipping
= false;
1296 if (!UI
.connected
) return;
1298 // Check if viewport drag is possible. It is only possible
1299 // if the remote display is clipping the client display.
1300 if (UI
.rfb
.get_display().get_viewport() &&
1301 UI
.rfb
.get_display().clippingDisplay()) {
1305 var viewDragButton
= document
.getElementById('noVNC_view_drag_button');
1308 UI
.rfb
.get_viewportDrag()) {
1309 // The size of the remote display is the same or smaller
1310 // than the client display. Make sure viewport drag isn't
1311 // active when it can't be used.
1312 UI
.rfb
.set_viewportDrag(false);
1315 if (UI
.rfb
.get_viewportDrag()) {
1316 viewDragButton
.classList
.add("noVNC_selected");
1318 viewDragButton
.classList
.remove("noVNC_selected");
1321 // Different behaviour for touch vs non-touch
1322 // The button is disabled instead of hidden on touch devices
1323 if (Util
.isTouchDevice
) {
1324 viewDragButton
.classList
.remove("noVNC_hidden");
1327 viewDragButton
.disabled
= false;
1329 viewDragButton
.disabled
= true;
1332 viewDragButton
.disabled
= false;
1335 viewDragButton
.classList
.remove("noVNC_hidden");
1337 viewDragButton
.classList
.add("noVNC_hidden");
1348 showVirtualKeyboard: function() {
1349 if (!Util
.isTouchDevice
) return;
1351 var input
= document
.getElementById('noVNC_keyboardinput');
1353 if (document
.activeElement
== input
) return;
1358 var l
= input
.value
.length
;
1359 // Move the caret to the end
1360 input
.setSelectionRange(l
, l
);
1361 } catch (err
) {} // setSelectionRange is undefined in Google Chrome
1364 hideVirtualKeyboard: function() {
1365 if (!Util
.isTouchDevice
) return;
1367 var input
= document
.getElementById('noVNC_keyboardinput');
1369 if (document
.activeElement
!= input
) return;
1374 toggleVirtualKeyboard: function () {
1375 if (document
.getElementById('noVNC_keyboard_button')
1376 .classList
.contains("noVNC_selected")) {
1377 UI
.hideVirtualKeyboard();
1379 UI
.showVirtualKeyboard();
1383 onfocusVirtualKeyboard: function(event
) {
1384 document
.getElementById('noVNC_keyboard_button')
1385 .classList
.add("noVNC_selected");
1388 onblurVirtualKeyboard: function(event
) {
1389 document
.getElementById('noVNC_keyboard_button')
1390 .classList
.remove("noVNC_selected");
1393 keepVirtualKeyboard: function(event
) {
1394 var input
= document
.getElementById('noVNC_keyboardinput');
1396 // Only prevent focus change if the virtual keyboard is active
1397 if (document
.activeElement
!= input
) {
1401 // Allow clicking on links
1402 if (event
.target
.tagName
=== "a") {
1406 // And form elements, except standard noVNC buttons
1407 if ((event
.target
.form
!== undefined) &&
1408 !event
.target
.classList
.contains("noVNC_button")) {
1412 event
.preventDefault();
1415 keyboardinputReset: function() {
1416 var kbi
= document
.getElementById('noVNC_keyboardinput');
1417 kbi
.value
= new Array(UI
.defaultKeyboardinputLen
).join("_");
1418 UI
.lastKeyboardinput
= kbi
.value
;
1421 // When normal keyboard events are left uncought, use the input events from
1422 // the keyboardinput element instead and generate the corresponding key events.
1423 // This code is required since some browsers on Android are inconsistent in
1424 // sending keyCodes in the normal keyboard events when using on screen keyboards.
1425 keyInput: function(event
) {
1427 if (!UI
.rfb
) return;
1429 var newValue
= event
.target
.value
;
1431 if (!UI
.lastKeyboardinput
) {
1432 UI
.keyboardinputReset();
1434 var oldValue
= UI
.lastKeyboardinput
;
1438 // Try to check caret position since whitespace at the end
1439 // will not be considered by value.length in some browsers
1440 newLen
= Math
.max(event
.target
.selectionStart
, newValue
.length
);
1442 // selectionStart is undefined in Google Chrome
1443 newLen
= newValue
.length
;
1445 var oldLen
= oldValue
.length
;
1448 var inputs
= newLen
- oldLen
;
1450 backspaces
= -inputs
;
1455 // Compare the old string with the new to account for
1456 // text-corrections or other input that modify existing text
1458 for (i
= 0; i
< Math
.min(oldLen
, newLen
); i
++) {
1459 if (newValue
.charAt(i
) != oldValue
.charAt(i
)) {
1460 inputs
= newLen
- i
;
1461 backspaces
= oldLen
- i
;
1466 // Send the key events
1467 for (i
= 0; i
< backspaces
; i
++) {
1468 UI
.rfb
.sendKey(KeyTable
.XK_BackSpace
);
1470 for (i
= newLen
- inputs
; i
< newLen
; i
++) {
1471 UI
.rfb
.sendKey(keysyms
.fromUnicode(newValue
.charCodeAt(i
)).keysym
);
1474 // Control the text content length in the keyboardinput element
1475 if (newLen
> 2 * UI
.defaultKeyboardinputLen
) {
1476 UI
.keyboardinputReset();
1477 } else if (newLen
< 1) {
1478 // There always have to be some text in the keyboardinput
1479 // element with which backspace can interact.
1480 UI
.keyboardinputReset();
1481 // This sometimes causes the keyboard to disappear for a second
1482 // but it is required for the android keyboard to recognize that
1483 // text has been added to the field
1484 event
.target
.blur();
1485 // This has to be ran outside of the input handler in order to work
1486 setTimeout(event
.target
.focus
.bind(event
.target
), 0);
1488 UI
.lastKeyboardinput
= newValue
;
1498 openExtraKeys: function() {
1499 UI
.closeAllPanels();
1500 UI
.openControlbar();
1502 document
.getElementById('noVNC_modifiers')
1503 .classList
.add("noVNC_open");
1504 document
.getElementById('noVNC_toggle_extra_keys_button')
1505 .classList
.add("noVNC_selected");
1508 closeExtraKeys: function() {
1509 document
.getElementById('noVNC_modifiers')
1510 .classList
.remove("noVNC_open");
1511 document
.getElementById('noVNC_toggle_extra_keys_button')
1512 .classList
.remove("noVNC_selected");
1515 toggleExtraKeys: function() {
1516 if(document
.getElementById('noVNC_modifiers')
1517 .classList
.contains("noVNC_open")) {
1518 UI
.closeExtraKeys();
1524 sendEsc: function() {
1525 UI
.rfb
.sendKey(KeyTable
.XK_Escape
);
1528 sendTab: function() {
1529 UI
.rfb
.sendKey(KeyTable
.XK_Tab
);
1532 toggleCtrl: function() {
1533 var btn
= document
.getElementById('noVNC_toggle_ctrl_button');
1534 if (btn
.classList
.contains("noVNC_selected")) {
1535 UI
.rfb
.sendKey(KeyTable
.XK_Control_L
, false);
1536 btn
.classList
.remove("noVNC_selected");
1538 UI
.rfb
.sendKey(KeyTable
.XK_Control_L
, true);
1539 btn
.classList
.add("noVNC_selected");
1543 toggleAlt: function() {
1544 var btn
= document
.getElementById('noVNC_toggle_alt_button');
1545 if (btn
.classList
.contains("noVNC_selected")) {
1546 UI
.rfb
.sendKey(KeyTable
.XK_Alt_L
, false);
1547 btn
.classList
.remove("noVNC_selected");
1549 UI
.rfb
.sendKey(KeyTable
.XK_Alt_L
, true);
1550 btn
.classList
.add("noVNC_selected");
1554 sendCtrlAltDel: function() {
1555 UI
.rfb
.sendCtrlAltDel();
1564 setMouseButton: function(num
) {
1565 var view_only
= UI
.rfb
.get_view_only();
1566 if (UI
.rfb
&& !view_only
) {
1567 UI
.rfb
.get_mouse().set_touchButton(num
);
1570 var blist
= [0, 1,2,4];
1571 for (var b
= 0; b
< blist
.length
; b
++) {
1572 var button
= document
.getElementById('noVNC_mouse_button' +
1574 if (blist
[b
] === num
&& !view_only
) {
1575 button
.classList
.remove("noVNC_hidden");
1577 button
.classList
.add("noVNC_hidden");
1582 displayBlur: function() {
1583 if (UI
.rfb
&& !UI
.rfb
.get_view_only()) {
1584 UI
.rfb
.get_keyboard().set_focused(false);
1585 UI
.rfb
.get_mouse().set_focused(false);
1589 displayFocus: function() {
1590 if (UI
.rfb
&& !UI
.rfb
.get_view_only()) {
1591 UI
.rfb
.get_keyboard().set_focused(true);
1592 UI
.rfb
.get_mouse().set_focused(true);
1596 updateDesktopName: function(rfb
, name
) {
1597 UI
.desktopName
= name
;
1598 // Display the desktop name in the document title
1599 document
.title
= name
+ " - noVNC";
1602 bell: function(rfb
) {
1603 if (WebUtil
.getConfigVar('bell', 'on') === 'on') {
1604 document
.getElementById('noVNC_bell').play();
1608 //Helper to add options to dropdown.
1609 addOption: function(selectbox
, text
, value
) {
1610 var optn
= document
.createElement("OPTION");
1613 selectbox
.options
.add(optn
);
1622 /* [module] UI.load(); */
1625 /* [module] export default UI; */