2 * noVNC: HTML5 VNC client
3 * Copyright (C) 2018 The noVNC Authors
4 * Licensed under MPL 2.0 (see LICENSE.txt)
6 * See README.md for usage and integration instructions.
9 import * as Log
from '../core/util/logging.js';
10 import _
, { l10n
} from './localization.js';
11 import { isTouchDevice
, isSafari
, isIOS
, isAndroid
, dragThreshold
}
12 from '../core/util/browser.js';
13 import { setCapture
, getPointerEvent
} from '../core/util/events.js';
14 import KeyTable
from "../core/input/keysym.js";
15 import keysyms
from "../core/input/keysymdef.js";
16 import Keyboard
from "../core/input/keyboard.js";
17 import RFB
from "../core/rfb.js";
18 import * as WebUtil
from "./webutil.js";
26 hideKeyboardTimeout
: null,
27 idleControlbarTimeout
: null,
28 closeControlbarTimeout
: null,
30 controlbarGrabbed
: false,
31 controlbarDrag
: false,
32 controlbarMouseDownClientY
: 0,
33 controlbarMouseDownOffsetY
: 0,
35 lastKeyboardinput
: null,
36 defaultKeyboardinputLen
: 100,
38 inhibit_reconnect
: true,
39 reconnect_callback
: null,
40 reconnect_password
: null,
43 if (document
.readyState
=== "interactive" || document
.readyState
=== "complete") {
46 document
.addEventListener('DOMContentLoaded', UI
.load
.bind(UI
, callback
));
50 // Setup rfb object, load settings from browser storage, then call
51 // UI.init to setup the UI/menus
53 WebUtil
.initSettings(UI
.start
, callback
);
56 // Render default UI and initialize settings menu
64 // Adapt the interface for touch screen devices
66 document
.documentElement
.classList
.add("noVNC_touch");
67 // Remove the address bar
68 setTimeout(() => window
.scrollTo(0, 1), 100);
71 // Restore control bar position
72 if (WebUtil
.readSetting('controlbar_pos') === 'right') {
73 UI
.toggleControlbarSide();
78 // Setup event handlers
79 UI
.addControlbarHandlers();
80 UI
.addTouchSpecificHandlers();
81 UI
.addExtraKeysHandlers();
82 UI
.addMachineHandlers();
83 UI
.addConnectionControlHandlers();
84 UI
.addClipboardHandlers();
85 UI
.addSettingsHandlers();
86 document
.getElementById("noVNC_status")
87 .addEventListener('click', UI
.hideStatus
);
89 // Bootstrap fallback input handler
90 UI
.keyboardinputReset();
94 UI
.updateVisualState('init');
96 document
.documentElement
.classList
.remove("noVNC_loading");
98 let autoconnect
= WebUtil
.getConfigVar('autoconnect', false);
99 if (autoconnect
=== 'true' || autoconnect
== '1') {
104 // Show the connect panel on first load unless autoconnecting
105 UI
.openConnectPanel();
108 if (typeof callback
=== "function") {
114 // Only show the button if fullscreen is properly supported
115 // * Safari doesn't support alphanumerical input while in fullscreen
117 (document
.documentElement
.requestFullscreen
||
118 document
.documentElement
.mozRequestFullScreen
||
119 document
.documentElement
.webkitRequestFullscreen
||
120 document
.body
.msRequestFullscreen
)) {
121 document
.getElementById('noVNC_fullscreen_button')
122 .classList
.remove("noVNC_hidden");
123 UI
.addFullscreenHandlers();
128 // Logging selection dropdown
129 const llevels
= ['error', 'warn', 'info', 'debug'];
130 for (let i
= 0; i
< llevels
.length
; i
+= 1) {
131 UI
.addOption(document
.getElementById('noVNC_setting_logging'), llevels
[i
], llevels
[i
]);
134 // Settings with immediate effects
135 UI
.initSetting('logging', 'warn');
138 // if port == 80 (or 443) then it won't be present and should be
140 let port
= window
.location
.port
;
142 if (window
.location
.protocol
.substring(0, 5) == 'https') {
144 } else if (window
.location
.protocol
.substring(0, 4) == 'http') {
149 /* Populate the controls if defaults are provided in the URL */
150 UI
.initSetting('host', window
.location
.hostname
);
151 UI
.initSetting('port', port
);
152 UI
.initSetting('encrypt', (window
.location
.protocol
=== "https:"));
153 UI
.initSetting('view_clip', false);
154 UI
.initSetting('resize', 'off');
155 UI
.initSetting('shared', true);
156 UI
.initSetting('view_only', false);
157 UI
.initSetting('show_dot', false);
158 UI
.initSetting('path', 'websockify');
159 UI
.initSetting('repeaterID', '');
160 UI
.initSetting('reconnect', false);
161 UI
.initSetting('reconnect_delay', 5000);
163 UI
.setupSettingLabels();
165 // Adds a link to the label elements on the corresponding input elements
166 setupSettingLabels() {
167 const labels
= document
.getElementsByTagName('LABEL');
168 for (let i
= 0; i
< labels
.length
; i
++) {
169 const htmlFor
= labels
[i
].htmlFor
;
171 const elem
= document
.getElementById(htmlFor
);
172 if (elem
) elem
.label
= labels
[i
];
174 // If 'for' isn't set, use the first input element child
175 const children
= labels
[i
].children
;
176 for (let j
= 0; j
< children
.length
; j
++) {
177 if (children
[j
].form
!== undefined) {
178 children
[j
].label
= labels
[i
];
192 addControlbarHandlers() {
193 document
.getElementById("noVNC_control_bar")
194 .addEventListener('mousemove', UI
.activateControlbar
);
195 document
.getElementById("noVNC_control_bar")
196 .addEventListener('mouseup', UI
.activateControlbar
);
197 document
.getElementById("noVNC_control_bar")
198 .addEventListener('mousedown', UI
.activateControlbar
);
199 document
.getElementById("noVNC_control_bar")
200 .addEventListener('keydown', UI
.activateControlbar
);
202 document
.getElementById("noVNC_control_bar")
203 .addEventListener('mousedown', UI
.keepControlbar
);
204 document
.getElementById("noVNC_control_bar")
205 .addEventListener('keydown', UI
.keepControlbar
);
207 document
.getElementById("noVNC_view_drag_button")
208 .addEventListener('click', UI
.toggleViewDrag
);
210 document
.getElementById("noVNC_control_bar_handle")
211 .addEventListener('mousedown', UI
.controlbarHandleMouseDown
);
212 document
.getElementById("noVNC_control_bar_handle")
213 .addEventListener('mouseup', UI
.controlbarHandleMouseUp
);
214 document
.getElementById("noVNC_control_bar_handle")
215 .addEventListener('mousemove', UI
.dragControlbarHandle
);
216 // resize events aren't available for elements
217 window
.addEventListener('resize', UI
.updateControlbarHandle
);
219 const exps
= document
.getElementsByClassName("noVNC_expander");
220 for (let i
= 0;i
< exps
.length
;i
++) {
221 exps
[i
].addEventListener('click', UI
.toggleExpander
);
225 addTouchSpecificHandlers() {
226 document
.getElementById("noVNC_mouse_button0")
227 .addEventListener('click', () => UI
.setMouseButton(1));
228 document
.getElementById("noVNC_mouse_button1")
229 .addEventListener('click', () => UI
.setMouseButton(2));
230 document
.getElementById("noVNC_mouse_button2")
231 .addEventListener('click', () => UI
.setMouseButton(4));
232 document
.getElementById("noVNC_mouse_button4")
233 .addEventListener('click', () => UI
.setMouseButton(0));
234 document
.getElementById("noVNC_keyboard_button")
235 .addEventListener('click', UI
.toggleVirtualKeyboard
);
237 UI
.touchKeyboard
= new Keyboard(document
.getElementById('noVNC_keyboardinput'));
238 UI
.touchKeyboard
.onkeyevent
= UI
.keyEvent
;
239 UI
.touchKeyboard
.grab();
240 document
.getElementById("noVNC_keyboardinput")
241 .addEventListener('input', UI
.keyInput
);
242 document
.getElementById("noVNC_keyboardinput")
243 .addEventListener('focus', UI
.onfocusVirtualKeyboard
);
244 document
.getElementById("noVNC_keyboardinput")
245 .addEventListener('blur', UI
.onblurVirtualKeyboard
);
246 document
.getElementById("noVNC_keyboardinput")
247 .addEventListener('submit', () => false);
249 document
.documentElement
250 .addEventListener('mousedown', UI
.keepVirtualKeyboard
, true);
252 document
.getElementById("noVNC_control_bar")
253 .addEventListener('touchstart', UI
.activateControlbar
);
254 document
.getElementById("noVNC_control_bar")
255 .addEventListener('touchmove', UI
.activateControlbar
);
256 document
.getElementById("noVNC_control_bar")
257 .addEventListener('touchend', UI
.activateControlbar
);
258 document
.getElementById("noVNC_control_bar")
259 .addEventListener('input', UI
.activateControlbar
);
261 document
.getElementById("noVNC_control_bar")
262 .addEventListener('touchstart', UI
.keepControlbar
);
263 document
.getElementById("noVNC_control_bar")
264 .addEventListener('input', UI
.keepControlbar
);
266 document
.getElementById("noVNC_control_bar_handle")
267 .addEventListener('touchstart', UI
.controlbarHandleMouseDown
);
268 document
.getElementById("noVNC_control_bar_handle")
269 .addEventListener('touchend', UI
.controlbarHandleMouseUp
);
270 document
.getElementById("noVNC_control_bar_handle")
271 .addEventListener('touchmove', UI
.dragControlbarHandle
);
274 addExtraKeysHandlers() {
275 document
.getElementById("noVNC_toggle_extra_keys_button")
276 .addEventListener('click', UI
.toggleExtraKeys
);
277 document
.getElementById("noVNC_toggle_ctrl_button")
278 .addEventListener('click', UI
.toggleCtrl
);
279 document
.getElementById("noVNC_toggle_windows_button")
280 .addEventListener('click', UI
.toggleWindows
);
281 document
.getElementById("noVNC_toggle_alt_button")
282 .addEventListener('click', UI
.toggleAlt
);
283 document
.getElementById("noVNC_send_tab_button")
284 .addEventListener('click', UI
.sendTab
);
285 document
.getElementById("noVNC_send_esc_button")
286 .addEventListener('click', UI
.sendEsc
);
287 document
.getElementById("noVNC_send_ctrl_alt_del_button")
288 .addEventListener('click', UI
.sendCtrlAltDel
);
291 addMachineHandlers() {
292 document
.getElementById("noVNC_shutdown_button")
293 .addEventListener('click', () => UI
.rfb
.machineShutdown());
294 document
.getElementById("noVNC_reboot_button")
295 .addEventListener('click', () => UI
.rfb
.machineReboot());
296 document
.getElementById("noVNC_reset_button")
297 .addEventListener('click', () => UI
.rfb
.machineReset());
298 document
.getElementById("noVNC_power_button")
299 .addEventListener('click', UI
.togglePowerPanel
);
302 addConnectionControlHandlers() {
303 document
.getElementById("noVNC_disconnect_button")
304 .addEventListener('click', UI
.disconnect
);
305 document
.getElementById("noVNC_connect_button")
306 .addEventListener('click', UI
.connect
);
307 document
.getElementById("noVNC_cancel_reconnect_button")
308 .addEventListener('click', UI
.cancelReconnect
);
310 document
.getElementById("noVNC_password_button")
311 .addEventListener('click', UI
.setPassword
);
314 addClipboardHandlers() {
315 document
.getElementById("noVNC_clipboard_button")
316 .addEventListener('click', UI
.toggleClipboardPanel
);
317 document
.getElementById("noVNC_clipboard_text")
318 .addEventListener('change', UI
.clipboardSend
);
319 document
.getElementById("noVNC_clipboard_clear_button")
320 .addEventListener('click', UI
.clipboardClear
);
323 // Add a call to save settings when the element changes,
324 // unless the optional parameter changeFunc is used instead.
325 addSettingChangeHandler(name
, changeFunc
) {
326 const settingElem
= document
.getElementById("noVNC_setting_" + name
);
327 if (changeFunc
=== undefined) {
328 changeFunc
= () => UI
.saveSetting(name
);
330 settingElem
.addEventListener('change', changeFunc
);
333 addSettingsHandlers() {
334 document
.getElementById("noVNC_settings_button")
335 .addEventListener('click', UI
.toggleSettingsPanel
);
337 UI
.addSettingChangeHandler('encrypt');
338 UI
.addSettingChangeHandler('resize');
339 UI
.addSettingChangeHandler('resize', UI
.applyResizeMode
);
340 UI
.addSettingChangeHandler('resize', UI
.updateViewClip
);
341 UI
.addSettingChangeHandler('view_clip');
342 UI
.addSettingChangeHandler('view_clip', UI
.updateViewClip
);
343 UI
.addSettingChangeHandler('shared');
344 UI
.addSettingChangeHandler('view_only');
345 UI
.addSettingChangeHandler('view_only', UI
.updateViewOnly
);
346 UI
.addSettingChangeHandler('show_dot');
347 UI
.addSettingChangeHandler('show_dot', UI
.updateShowDotCursor
);
348 UI
.addSettingChangeHandler('host');
349 UI
.addSettingChangeHandler('port');
350 UI
.addSettingChangeHandler('path');
351 UI
.addSettingChangeHandler('repeaterID');
352 UI
.addSettingChangeHandler('logging');
353 UI
.addSettingChangeHandler('logging', UI
.updateLogging
);
354 UI
.addSettingChangeHandler('reconnect');
355 UI
.addSettingChangeHandler('reconnect_delay');
358 addFullscreenHandlers() {
359 document
.getElementById("noVNC_fullscreen_button")
360 .addEventListener('click', UI
.toggleFullscreen
);
362 window
.addEventListener('fullscreenchange', UI
.updateFullscreenButton
);
363 window
.addEventListener('mozfullscreenchange', UI
.updateFullscreenButton
);
364 window
.addEventListener('webkitfullscreenchange', UI
.updateFullscreenButton
);
365 window
.addEventListener('msfullscreenchange', UI
.updateFullscreenButton
);
374 // Disable/enable controls depending on connection state
375 updateVisualState(state
) {
377 document
.documentElement
.classList
.remove("noVNC_connecting");
378 document
.documentElement
.classList
.remove("noVNC_connected");
379 document
.documentElement
.classList
.remove("noVNC_disconnecting");
380 document
.documentElement
.classList
.remove("noVNC_reconnecting");
382 const transition_elem
= document
.getElementById("noVNC_transition_text");
387 transition_elem
.textContent
= _("Connecting...");
388 document
.documentElement
.classList
.add("noVNC_connecting");
391 document
.documentElement
.classList
.add("noVNC_connected");
393 case 'disconnecting':
394 transition_elem
.textContent
= _("Disconnecting...");
395 document
.documentElement
.classList
.add("noVNC_disconnecting");
400 transition_elem
.textContent
= _("Reconnecting...");
401 document
.documentElement
.classList
.add("noVNC_reconnecting");
404 Log
.Error("Invalid visual state: " + state
);
405 UI
.showStatus(_("Internal error"), 'error');
412 UI
.disableSetting('encrypt');
413 UI
.disableSetting('shared');
414 UI
.disableSetting('host');
415 UI
.disableSetting('port');
416 UI
.disableSetting('path');
417 UI
.disableSetting('repeaterID');
418 UI
.setMouseButton(1);
420 // Hide the controlbar after 2 seconds
421 UI
.closeControlbarTimeout
= setTimeout(UI
.closeControlbar
, 2000);
423 UI
.enableSetting('encrypt');
424 UI
.enableSetting('shared');
425 UI
.enableSetting('host');
426 UI
.enableSetting('port');
427 UI
.enableSetting('path');
428 UI
.enableSetting('repeaterID');
429 UI
.updatePowerButton();
433 // State change closes the password dialog
434 document
.getElementById('noVNC_password_dlg')
435 .classList
.remove('noVNC_open');
438 showStatus(text
, status_type
, time
) {
439 const statusElem
= document
.getElementById('noVNC_status');
441 clearTimeout(UI
.statusTimeout
);
443 if (typeof status_type
=== 'undefined') {
444 status_type
= 'normal';
447 // Don't overwrite more severe visible statuses and never
448 // errors. Only shows the first error.
449 let visible_status_type
= 'none';
450 if (statusElem
.classList
.contains("noVNC_open")) {
451 if (statusElem
.classList
.contains("noVNC_status_error")) {
452 visible_status_type
= 'error';
453 } else if (statusElem
.classList
.contains("noVNC_status_warn")) {
454 visible_status_type
= 'warn';
456 visible_status_type
= 'normal';
459 if (visible_status_type
=== 'error' ||
460 (visible_status_type
=== 'warn' && status_type
=== 'normal')) {
464 switch (status_type
) {
466 statusElem
.classList
.remove("noVNC_status_warn");
467 statusElem
.classList
.remove("noVNC_status_normal");
468 statusElem
.classList
.add("noVNC_status_error");
472 statusElem
.classList
.remove("noVNC_status_error");
473 statusElem
.classList
.remove("noVNC_status_normal");
474 statusElem
.classList
.add("noVNC_status_warn");
479 statusElem
.classList
.remove("noVNC_status_error");
480 statusElem
.classList
.remove("noVNC_status_warn");
481 statusElem
.classList
.add("noVNC_status_normal");
485 statusElem
.textContent
= text
;
486 statusElem
.classList
.add("noVNC_open");
488 // If no time was specified, show the status for 1.5 seconds
489 if (typeof time
=== 'undefined') {
493 // Error messages do not timeout
494 if (status_type
!== 'error') {
495 UI
.statusTimeout
= window
.setTimeout(UI
.hideStatus
, time
);
500 clearTimeout(UI
.statusTimeout
);
501 document
.getElementById('noVNC_status').classList
.remove("noVNC_open");
504 activateControlbar(event
) {
505 clearTimeout(UI
.idleControlbarTimeout
);
506 // We manipulate the anchor instead of the actual control
507 // bar in order to avoid creating new a stacking group
508 document
.getElementById('noVNC_control_bar_anchor')
509 .classList
.remove("noVNC_idle");
510 UI
.idleControlbarTimeout
= window
.setTimeout(UI
.idleControlbar
, 2000);
514 document
.getElementById('noVNC_control_bar_anchor')
515 .classList
.add("noVNC_idle");
519 clearTimeout(UI
.closeControlbarTimeout
);
523 document
.getElementById('noVNC_control_bar')
524 .classList
.add("noVNC_open");
529 document
.getElementById('noVNC_control_bar')
530 .classList
.remove("noVNC_open");
534 if (document
.getElementById('noVNC_control_bar')
535 .classList
.contains("noVNC_open")) {
536 UI
.closeControlbar();
542 toggleControlbarSide() {
543 // Temporarily disable animation, if bar is displayed, to avoid weird
544 // movement. The transitionend-event will not fire when display=none.
545 const bar
= document
.getElementById('noVNC_control_bar');
546 const barDisplayStyle
= window
.getComputedStyle(bar
).display
;
547 if (barDisplayStyle
!== 'none') {
548 bar
.style
.transitionDuration
= '0s';
549 bar
.addEventListener('transitionend', () => bar
.style
.transitionDuration
= '');
552 const anchor
= document
.getElementById('noVNC_control_bar_anchor');
553 if (anchor
.classList
.contains("noVNC_right")) {
554 WebUtil
.writeSetting('controlbar_pos', 'left');
555 anchor
.classList
.remove("noVNC_right");
557 WebUtil
.writeSetting('controlbar_pos', 'right');
558 anchor
.classList
.add("noVNC_right");
561 // Consider this a movement of the handle
562 UI
.controlbarDrag
= true;
565 showControlbarHint(show
) {
566 const hint
= document
.getElementById('noVNC_control_bar_hint');
568 hint
.classList
.add("noVNC_active");
570 hint
.classList
.remove("noVNC_active");
574 dragControlbarHandle(e
) {
575 if (!UI
.controlbarGrabbed
) return;
577 const ptr
= getPointerEvent(e
);
579 const anchor
= document
.getElementById('noVNC_control_bar_anchor');
580 if (ptr
.clientX
< (window
.innerWidth
* 0.1)) {
581 if (anchor
.classList
.contains("noVNC_right")) {
582 UI
.toggleControlbarSide();
584 } else if (ptr
.clientX
> (window
.innerWidth
* 0.9)) {
585 if (!anchor
.classList
.contains("noVNC_right")) {
586 UI
.toggleControlbarSide();
590 if (!UI
.controlbarDrag
) {
591 const dragDistance
= Math
.abs(ptr
.clientY
- UI
.controlbarMouseDownClientY
);
593 if (dragDistance
< dragThreshold
) return;
595 UI
.controlbarDrag
= true;
598 const eventY
= ptr
.clientY
- UI
.controlbarMouseDownOffsetY
;
600 UI
.moveControlbarHandle(eventY
);
605 UI
.activateControlbar();
608 // Move the handle but don't allow any position outside the bounds
609 moveControlbarHandle(viewportRelativeY
) {
610 const handle
= document
.getElementById("noVNC_control_bar_handle");
611 const handleHeight
= handle
.getBoundingClientRect().height
;
612 const controlbarBounds
= document
.getElementById("noVNC_control_bar")
613 .getBoundingClientRect();
616 // These heights need to be non-zero for the below logic to work
617 if (handleHeight
=== 0 || controlbarBounds
.height
=== 0) {
621 let newY
= viewportRelativeY
;
623 // Check if the coordinates are outside the control bar
624 if (newY
< controlbarBounds
.top
+ margin
) {
625 // Force coordinates to be below the top of the control bar
626 newY
= controlbarBounds
.top
+ margin
;
628 } else if (newY
> controlbarBounds
.top
+
629 controlbarBounds
.height
- handleHeight
- margin
) {
630 // Force coordinates to be above the bottom of the control bar
631 newY
= controlbarBounds
.top
+
632 controlbarBounds
.height
- handleHeight
- margin
;
635 // Corner case: control bar too small for stable position
636 if (controlbarBounds
.height
< (handleHeight
+ margin
* 2)) {
637 newY
= controlbarBounds
.top
+
638 (controlbarBounds
.height
- handleHeight
) / 2;
641 // The transform needs coordinates that are relative to the parent
642 const parentRelativeY
= newY
- controlbarBounds
.top
;
643 handle
.style
.transform
= "translateY(" + parentRelativeY
+ "px)";
646 updateControlbarHandle() {
647 // Since the control bar is fixed on the viewport and not the page,
648 // the move function expects coordinates relative the the viewport.
649 const handle
= document
.getElementById("noVNC_control_bar_handle");
650 const handleBounds
= handle
.getBoundingClientRect();
651 UI
.moveControlbarHandle(handleBounds
.top
);
654 controlbarHandleMouseUp(e
) {
655 if ((e
.type
== "mouseup") && (e
.button
!= 0)) return;
657 // mouseup and mousedown on the same place toggles the controlbar
658 if (UI
.controlbarGrabbed
&& !UI
.controlbarDrag
) {
659 UI
.toggleControlbar();
663 UI
.activateControlbar();
665 UI
.controlbarGrabbed
= false;
666 UI
.showControlbarHint(false);
669 controlbarHandleMouseDown(e
) {
670 if ((e
.type
== "mousedown") && (e
.button
!= 0)) return;
672 const ptr
= getPointerEvent(e
);
674 const handle
= document
.getElementById("noVNC_control_bar_handle");
675 const bounds
= handle
.getBoundingClientRect();
677 // Touch events have implicit capture
678 if (e
.type
=== "mousedown") {
682 UI
.controlbarGrabbed
= true;
683 UI
.controlbarDrag
= false;
685 UI
.showControlbarHint(true);
687 UI
.controlbarMouseDownClientY
= ptr
.clientY
;
688 UI
.controlbarMouseDownOffsetY
= ptr
.clientY
- bounds
.top
;
692 UI
.activateControlbar();
696 if (this.classList
.contains("noVNC_open")) {
697 this.classList
.remove("noVNC_open");
699 this.classList
.add("noVNC_open");
709 // Initial page load read/initialization of settings
710 initSetting(name
, defVal
) {
711 // Check Query string followed by cookie
712 let val
= WebUtil
.getConfigVar(name
);
714 val
= WebUtil
.readSetting(name
, defVal
);
716 WebUtil
.setSetting(name
, val
);
717 UI
.updateSetting(name
);
721 // Set the new value, update and disable form control setting
722 forceSetting(name
, val
) {
723 WebUtil
.setSetting(name
, val
);
724 UI
.updateSetting(name
);
725 UI
.disableSetting(name
);
728 // Update cookie and form control setting. If value is not set, then
729 // updates from control to current cookie setting.
730 updateSetting(name
) {
732 // Update the settings control
733 let value
= UI
.getSetting(name
);
735 const ctrl
= document
.getElementById('noVNC_setting_' + name
);
736 if (ctrl
.type
=== 'checkbox') {
737 ctrl
.checked
= value
;
739 } else if (typeof ctrl
.options
!== 'undefined') {
740 for (let i
= 0; i
< ctrl
.options
.length
; i
+= 1) {
741 if (ctrl
.options
[i
].value
=== value
) {
742 ctrl
.selectedIndex
= i
;
747 /*Weird IE9 error leads to 'null' appearring
748 in textboxes instead of ''.*/
749 if (value
=== null) {
756 // Save control setting to cookie
758 const ctrl
= document
.getElementById('noVNC_setting_' + name
);
760 if (ctrl
.type
=== 'checkbox') {
762 } else if (typeof ctrl
.options
!== 'undefined') {
763 val
= ctrl
.options
[ctrl
.selectedIndex
].value
;
767 WebUtil
.writeSetting(name
, val
);
768 //Log.Debug("Setting saved '" + name + "=" + val + "'");
772 // Read form control compatible setting from cookie
774 const ctrl
= document
.getElementById('noVNC_setting_' + name
);
775 let val
= WebUtil
.readSetting(name
);
776 if (typeof val
!== 'undefined' && val
!== null && ctrl
.type
=== 'checkbox') {
777 if (val
.toString().toLowerCase() in {'0': 1, 'no': 1, 'false': 1}) {
786 // These helpers compensate for the lack of parent-selectors and
787 // previous-sibling-selectors in CSS which are needed when we want to
788 // disable the labels that belong to disabled input elements.
789 disableSetting(name
) {
790 const ctrl
= document
.getElementById('noVNC_setting_' + name
);
791 ctrl
.disabled
= true;
792 ctrl
.label
.classList
.add('noVNC_disabled');
795 enableSetting(name
) {
796 const ctrl
= document
.getElementById('noVNC_setting_' + name
);
797 ctrl
.disabled
= false;
798 ctrl
.label
.classList
.remove('noVNC_disabled');
808 UI
.closeSettingsPanel();
809 UI
.closePowerPanel();
810 UI
.closeClipboardPanel();
820 openSettingsPanel() {
824 // Refresh UI elements from saved cookies
825 UI
.updateSetting('encrypt');
826 UI
.updateSetting('view_clip');
827 UI
.updateSetting('resize');
828 UI
.updateSetting('shared');
829 UI
.updateSetting('view_only');
830 UI
.updateSetting('path');
831 UI
.updateSetting('repeaterID');
832 UI
.updateSetting('logging');
833 UI
.updateSetting('reconnect');
834 UI
.updateSetting('reconnect_delay');
836 document
.getElementById('noVNC_settings')
837 .classList
.add("noVNC_open");
838 document
.getElementById('noVNC_settings_button')
839 .classList
.add("noVNC_selected");
842 closeSettingsPanel() {
843 document
.getElementById('noVNC_settings')
844 .classList
.remove("noVNC_open");
845 document
.getElementById('noVNC_settings_button')
846 .classList
.remove("noVNC_selected");
849 toggleSettingsPanel() {
850 if (document
.getElementById('noVNC_settings')
851 .classList
.contains("noVNC_open")) {
852 UI
.closeSettingsPanel();
854 UI
.openSettingsPanel();
868 document
.getElementById('noVNC_power')
869 .classList
.add("noVNC_open");
870 document
.getElementById('noVNC_power_button')
871 .classList
.add("noVNC_selected");
875 document
.getElementById('noVNC_power')
876 .classList
.remove("noVNC_open");
877 document
.getElementById('noVNC_power_button')
878 .classList
.remove("noVNC_selected");
882 if (document
.getElementById('noVNC_power')
883 .classList
.contains("noVNC_open")) {
884 UI
.closePowerPanel();
890 // Disable/enable power button
891 updatePowerButton() {
893 UI
.rfb
.capabilities
.power
&&
895 document
.getElementById('noVNC_power_button')
896 .classList
.remove("noVNC_hidden");
898 document
.getElementById('noVNC_power_button')
899 .classList
.add("noVNC_hidden");
900 // Close power panel if open
901 UI
.closePowerPanel();
911 openClipboardPanel() {
915 document
.getElementById('noVNC_clipboard')
916 .classList
.add("noVNC_open");
917 document
.getElementById('noVNC_clipboard_button')
918 .classList
.add("noVNC_selected");
921 closeClipboardPanel() {
922 document
.getElementById('noVNC_clipboard')
923 .classList
.remove("noVNC_open");
924 document
.getElementById('noVNC_clipboard_button')
925 .classList
.remove("noVNC_selected");
928 toggleClipboardPanel() {
929 if (document
.getElementById('noVNC_clipboard')
930 .classList
.contains("noVNC_open")) {
931 UI
.closeClipboardPanel();
933 UI
.openClipboardPanel();
937 clipboardReceive(e
) {
938 Log
.Debug(">> UI.clipboardReceive: " + e
.detail
.text
.substr(0, 40) + "...");
939 document
.getElementById('noVNC_clipboard_text').value
= e
.detail
.text
;
940 Log
.Debug("<< UI.clipboardReceive");
944 document
.getElementById('noVNC_clipboard_text').value
= "";
945 UI
.rfb
.clipboardPasteFrom("");
949 const text
= document
.getElementById('noVNC_clipboard_text').value
;
950 Log
.Debug(">> UI.clipboardSend: " + text
.substr(0, 40) + "...");
951 UI
.rfb
.clipboardPasteFrom(text
);
952 Log
.Debug("<< UI.clipboardSend");
962 document
.getElementById('noVNC_connect_dlg')
963 .classList
.add("noVNC_open");
966 closeConnectPanel() {
967 document
.getElementById('noVNC_connect_dlg')
968 .classList
.remove("noVNC_open");
971 connect(event
, password
) {
973 // Ignore when rfb already exists
974 if (typeof UI
.rfb
!== 'undefined') {
978 const host
= UI
.getSetting('host');
979 const port
= UI
.getSetting('port');
980 const path
= UI
.getSetting('path');
982 if (typeof password
=== 'undefined') {
983 password
= WebUtil
.getConfigVar('password');
984 UI
.reconnect_password
= password
;
987 if (password
=== null) {
988 password
= undefined;
994 Log
.Error("Can't connect when host is: " + host
);
995 UI
.showStatus(_("Must set host"), 'error');
1000 UI
.closeConnectPanel();
1002 UI
.updateVisualState('connecting');
1006 url
= UI
.getSetting('encrypt') ? 'wss' : 'ws';
1008 url
+= '://' + host
;
1014 UI
.rfb
= new RFB(document
.getElementById('noVNC_container'), url
,
1015 { shared
: UI
.getSetting('shared'),
1016 showDotCursor
: UI
.getSetting('show_dot'),
1017 repeaterID
: UI
.getSetting('repeaterID'),
1018 credentials
: { password
: password
} });
1019 UI
.rfb
.addEventListener("connect", UI
.connectFinished
);
1020 UI
.rfb
.addEventListener("disconnect", UI
.disconnectFinished
);
1021 UI
.rfb
.addEventListener("credentialsrequired", UI
.credentials
);
1022 UI
.rfb
.addEventListener("securityfailure", UI
.securityFailed
);
1023 UI
.rfb
.addEventListener("capabilities", UI
.updatePowerButton
);
1024 UI
.rfb
.addEventListener("clipboard", UI
.clipboardReceive
);
1025 UI
.rfb
.addEventListener("bell", UI
.bell
);
1026 UI
.rfb
.addEventListener("desktopname", UI
.updateDesktopName
);
1027 UI
.rfb
.clipViewport
= UI
.getSetting('view_clip');
1028 UI
.rfb
.scaleViewport
= UI
.getSetting('resize') === 'scale';
1029 UI
.rfb
.resizeSession
= UI
.getSetting('resize') === 'remote';
1031 UI
.updateViewOnly(); // requires UI.rfb
1035 UI
.closeAllPanels();
1036 UI
.rfb
.disconnect();
1038 UI
.connected
= false;
1040 // Disable automatic reconnecting
1041 UI
.inhibit_reconnect
= true;
1043 UI
.updateVisualState('disconnecting');
1045 // Don't display the connection settings until we're actually disconnected
1049 UI
.reconnect_callback
= null;
1051 // if reconnect has been disabled in the meantime, do nothing.
1052 if (UI
.inhibit_reconnect
) {
1056 UI
.connect(null, UI
.reconnect_password
);
1060 if (UI
.reconnect_callback
!== null) {
1061 clearTimeout(UI
.reconnect_callback
);
1062 UI
.reconnect_callback
= null;
1065 UI
.updateVisualState('disconnected');
1067 UI
.openControlbar();
1068 UI
.openConnectPanel();
1071 connectFinished(e
) {
1072 UI
.connected
= true;
1073 UI
.inhibit_reconnect
= false;
1076 if (UI
.getSetting('encrypt')) {
1077 msg
= _("Connected (encrypted) to ") + UI
.desktopName
;
1079 msg
= _("Connected (unencrypted) to ") + UI
.desktopName
;
1082 UI
.updateVisualState('connected');
1084 // Do this last because it can only be used on rendered elements
1088 disconnectFinished(e
) {
1089 const wasConnected
= UI
.connected
;
1091 // This variable is ideally set when disconnection starts, but
1092 // when the disconnection isn't clean or if it is initiated by
1093 // the server, we need to do it here as well since
1094 // UI.disconnect() won't be used in those cases.
1095 UI
.connected
= false;
1099 if (!e
.detail
.clean
) {
1100 UI
.updateVisualState('disconnected');
1102 UI
.showStatus(_("Something went wrong, connection is closed"),
1105 UI
.showStatus(_("Failed to connect to server"), 'error');
1107 } else if (UI
.getSetting('reconnect', false) === true && !UI
.inhibit_reconnect
) {
1108 UI
.updateVisualState('reconnecting');
1110 const delay
= parseInt(UI
.getSetting('reconnect_delay'));
1111 UI
.reconnect_callback
= setTimeout(UI
.reconnect
, delay
);
1114 UI
.updateVisualState('disconnected');
1115 UI
.showStatus(_("Disconnected"), 'normal');
1118 UI
.openControlbar();
1119 UI
.openConnectPanel();
1124 // On security failures we might get a string with a reason
1125 // directly from the server. Note that we can't control if
1126 // this string is translated or not.
1127 if ('reason' in e
.detail
) {
1128 msg
= _("New connection has been rejected with reason: ") +
1131 msg
= _("New connection has been rejected");
1133 UI
.showStatus(msg
, 'error');
1143 // FIXME: handle more types
1144 document
.getElementById('noVNC_password_dlg')
1145 .classList
.add('noVNC_open');
1147 setTimeout(() => document
1148 .getElementById('noVNC_password_input').focus(), 100);
1150 Log
.Warn("Server asked for a password");
1151 UI
.showStatus(_("Password is required"), "warning");
1155 // Prevent actually submitting the form
1158 const inputElem
= document
.getElementById('noVNC_password_input');
1159 const password
= inputElem
.value
;
1160 // Clear the input after reading the password
1161 inputElem
.value
= "";
1162 UI
.rfb
.sendCredentials({ password
: password
});
1163 UI
.reconnect_password
= password
;
1164 document
.getElementById('noVNC_password_dlg')
1165 .classList
.remove('noVNC_open');
1174 toggleFullscreen() {
1175 if (document
.fullscreenElement
|| // alternative standard method
1176 document
.mozFullScreenElement
|| // currently working methods
1177 document
.webkitFullscreenElement
||
1178 document
.msFullscreenElement
) {
1179 if (document
.exitFullscreen
) {
1180 document
.exitFullscreen();
1181 } else if (document
.mozCancelFullScreen
) {
1182 document
.mozCancelFullScreen();
1183 } else if (document
.webkitExitFullscreen
) {
1184 document
.webkitExitFullscreen();
1185 } else if (document
.msExitFullscreen
) {
1186 document
.msExitFullscreen();
1189 if (document
.documentElement
.requestFullscreen
) {
1190 document
.documentElement
.requestFullscreen();
1191 } else if (document
.documentElement
.mozRequestFullScreen
) {
1192 document
.documentElement
.mozRequestFullScreen();
1193 } else if (document
.documentElement
.webkitRequestFullscreen
) {
1194 document
.documentElement
.webkitRequestFullscreen(Element
.ALLOW_KEYBOARD_INPUT
);
1195 } else if (document
.body
.msRequestFullscreen
) {
1196 document
.body
.msRequestFullscreen();
1199 UI
.updateFullscreenButton();
1202 updateFullscreenButton() {
1203 if (document
.fullscreenElement
|| // alternative standard method
1204 document
.mozFullScreenElement
|| // currently working methods
1205 document
.webkitFullscreenElement
||
1206 document
.msFullscreenElement
) {
1207 document
.getElementById('noVNC_fullscreen_button')
1208 .classList
.add("noVNC_selected");
1210 document
.getElementById('noVNC_fullscreen_button')
1211 .classList
.remove("noVNC_selected");
1221 // Apply remote resizing or local scaling
1223 if (!UI
.rfb
) return;
1225 UI
.rfb
.scaleViewport
= UI
.getSetting('resize') === 'scale';
1226 UI
.rfb
.resizeSession
= UI
.getSetting('resize') === 'remote';
1235 // Update viewport clipping property for the connection. The normal
1236 // case is to get the value from the setting. There are special cases
1237 // for when the viewport is scaled or when a touch device is used.
1239 if (!UI
.rfb
) return;
1241 const scaling
= UI
.getSetting('resize') === 'scale';
1244 // Can't be clipping if viewport is scaled to fit
1245 UI
.forceSetting('view_clip', false);
1246 UI
.rfb
.clipViewport
= false;
1247 } else if (isIOS() || isAndroid()) {
1248 // iOS and Android usually have shit scrollbars
1249 UI
.forceSetting('view_clip', true);
1250 UI
.rfb
.clipViewport
= true;
1252 UI
.enableSetting('view_clip');
1253 UI
.rfb
.clipViewport
= UI
.getSetting('view_clip');
1256 // Changing the viewport may change the state of
1257 // the dragging button
1258 UI
.updateViewDrag();
1268 if (!UI
.rfb
) return;
1270 UI
.rfb
.dragViewport
= !UI
.rfb
.dragViewport
;
1271 UI
.updateViewDrag();
1275 if (!UI
.connected
) return;
1277 const viewDragButton
= document
.getElementById('noVNC_view_drag_button');
1279 if (!UI
.rfb
.clipViewport
&& UI
.rfb
.dragViewport
) {
1280 // We are no longer clipping the viewport. Make sure
1281 // viewport drag isn't active when it can't be used.
1282 UI
.rfb
.dragViewport
= false;
1285 if (UI
.rfb
.dragViewport
) {
1286 viewDragButton
.classList
.add("noVNC_selected");
1288 viewDragButton
.classList
.remove("noVNC_selected");
1291 // Different behaviour for touch vs non-touch
1292 // The button is disabled instead of hidden on touch devices
1293 if (isTouchDevice
) {
1294 viewDragButton
.classList
.remove("noVNC_hidden");
1296 if (UI
.rfb
.clipViewport
) {
1297 viewDragButton
.disabled
= false;
1299 viewDragButton
.disabled
= true;
1302 viewDragButton
.disabled
= false;
1304 if (UI
.rfb
.clipViewport
) {
1305 viewDragButton
.classList
.remove("noVNC_hidden");
1307 viewDragButton
.classList
.add("noVNC_hidden");
1318 showVirtualKeyboard() {
1319 if (!isTouchDevice
) return;
1321 const input
= document
.getElementById('noVNC_keyboardinput');
1323 if (document
.activeElement
== input
) return;
1328 const l
= input
.value
.length
;
1329 // Move the caret to the end
1330 input
.setSelectionRange(l
, l
);
1332 // setSelectionRange is undefined in Google Chrome
1336 hideVirtualKeyboard() {
1337 if (!isTouchDevice
) return;
1339 const input
= document
.getElementById('noVNC_keyboardinput');
1341 if (document
.activeElement
!= input
) return;
1346 toggleVirtualKeyboard() {
1347 if (document
.getElementById('noVNC_keyboard_button')
1348 .classList
.contains("noVNC_selected")) {
1349 UI
.hideVirtualKeyboard();
1351 UI
.showVirtualKeyboard();
1355 onfocusVirtualKeyboard(event
) {
1356 document
.getElementById('noVNC_keyboard_button')
1357 .classList
.add("noVNC_selected");
1359 UI
.rfb
.focusOnClick
= false;
1363 onblurVirtualKeyboard(event
) {
1364 document
.getElementById('noVNC_keyboard_button')
1365 .classList
.remove("noVNC_selected");
1367 UI
.rfb
.focusOnClick
= true;
1371 keepVirtualKeyboard(event
) {
1372 const input
= document
.getElementById('noVNC_keyboardinput');
1374 // Only prevent focus change if the virtual keyboard is active
1375 if (document
.activeElement
!= input
) {
1379 // Only allow focus to move to other elements that need
1380 // focus to function properly
1381 if (event
.target
.form
!== undefined) {
1382 switch (event
.target
.type
) {
1391 case 'select-multiple':
1396 event
.preventDefault();
1399 keyboardinputReset() {
1400 const kbi
= document
.getElementById('noVNC_keyboardinput');
1401 kbi
.value
= new Array(UI
.defaultKeyboardinputLen
).join("_");
1402 UI
.lastKeyboardinput
= kbi
.value
;
1405 keyEvent(keysym
, code
, down
) {
1406 if (!UI
.rfb
) return;
1408 UI
.rfb
.sendKey(keysym
, code
, down
);
1411 // When normal keyboard events are left uncought, use the input events from
1412 // the keyboardinput element instead and generate the corresponding key events.
1413 // This code is required since some browsers on Android are inconsistent in
1414 // sending keyCodes in the normal keyboard events when using on screen keyboards.
1417 if (!UI
.rfb
) return;
1419 const newValue
= event
.target
.value
;
1421 if (!UI
.lastKeyboardinput
) {
1422 UI
.keyboardinputReset();
1424 const oldValue
= UI
.lastKeyboardinput
;
1428 // Try to check caret position since whitespace at the end
1429 // will not be considered by value.length in some browsers
1430 newLen
= Math
.max(event
.target
.selectionStart
, newValue
.length
);
1432 // selectionStart is undefined in Google Chrome
1433 newLen
= newValue
.length
;
1435 const oldLen
= oldValue
.length
;
1437 let inputs
= newLen
- oldLen
;
1438 let backspaces
= inputs
< 0 ? -inputs
: 0;
1440 // Compare the old string with the new to account for
1441 // text-corrections or other input that modify existing text
1442 for (let i
= 0; i
< Math
.min(oldLen
, newLen
); i
++) {
1443 if (newValue
.charAt(i
) != oldValue
.charAt(i
)) {
1444 inputs
= newLen
- i
;
1445 backspaces
= oldLen
- i
;
1450 // Send the key events
1451 for (let i
= 0; i
< backspaces
; i
++) {
1452 UI
.rfb
.sendKey(KeyTable
.XK_BackSpace
, "Backspace");
1454 for (let i
= newLen
- inputs
; i
< newLen
; i
++) {
1455 UI
.rfb
.sendKey(keysyms
.lookup(newValue
.charCodeAt(i
)));
1458 // Control the text content length in the keyboardinput element
1459 if (newLen
> 2 * UI
.defaultKeyboardinputLen
) {
1460 UI
.keyboardinputReset();
1461 } else if (newLen
< 1) {
1462 // There always have to be some text in the keyboardinput
1463 // element with which backspace can interact.
1464 UI
.keyboardinputReset();
1465 // This sometimes causes the keyboard to disappear for a second
1466 // but it is required for the android keyboard to recognize that
1467 // text has been added to the field
1468 event
.target
.blur();
1469 // This has to be ran outside of the input handler in order to work
1470 setTimeout(event
.target
.focus
.bind(event
.target
), 0);
1472 UI
.lastKeyboardinput
= newValue
;
1483 UI
.closeAllPanels();
1484 UI
.openControlbar();
1486 document
.getElementById('noVNC_modifiers')
1487 .classList
.add("noVNC_open");
1488 document
.getElementById('noVNC_toggle_extra_keys_button')
1489 .classList
.add("noVNC_selected");
1493 document
.getElementById('noVNC_modifiers')
1494 .classList
.remove("noVNC_open");
1495 document
.getElementById('noVNC_toggle_extra_keys_button')
1496 .classList
.remove("noVNC_selected");
1500 if (document
.getElementById('noVNC_modifiers')
1501 .classList
.contains("noVNC_open")) {
1502 UI
.closeExtraKeys();
1509 UI
.rfb
.sendKey(KeyTable
.XK_Escape
, "Escape");
1513 UI
.rfb
.sendKey(KeyTable
.XK_Tab
);
1517 const btn
= document
.getElementById('noVNC_toggle_ctrl_button');
1518 if (btn
.classList
.contains("noVNC_selected")) {
1519 UI
.rfb
.sendKey(KeyTable
.XK_Control_L
, "ControlLeft", false);
1520 btn
.classList
.remove("noVNC_selected");
1522 UI
.rfb
.sendKey(KeyTable
.XK_Control_L
, "ControlLeft", true);
1523 btn
.classList
.add("noVNC_selected");
1528 const btn
= document
.getElementById('noVNC_toggle_windows_button');
1529 if (btn
.classList
.contains("noVNC_selected")) {
1530 UI
.rfb
.sendKey(KeyTable
.XK_Super_L
, "MetaLeft", false);
1531 btn
.classList
.remove("noVNC_selected");
1533 UI
.rfb
.sendKey(KeyTable
.XK_Super_L
, "MetaLeft", true);
1534 btn
.classList
.add("noVNC_selected");
1539 const btn
= document
.getElementById('noVNC_toggle_alt_button');
1540 if (btn
.classList
.contains("noVNC_selected")) {
1541 UI
.rfb
.sendKey(KeyTable
.XK_Alt_L
, "AltLeft", false);
1542 btn
.classList
.remove("noVNC_selected");
1544 UI
.rfb
.sendKey(KeyTable
.XK_Alt_L
, "AltLeft", true);
1545 btn
.classList
.add("noVNC_selected");
1550 UI
.rfb
.sendCtrlAltDel();
1559 setMouseButton(num
) {
1560 const view_only
= UI
.rfb
.viewOnly
;
1561 if (UI
.rfb
&& !view_only
) {
1562 UI
.rfb
.touchButton
= num
;
1565 const blist
= [0, 1, 2, 4];
1566 for (let b
= 0; b
< blist
.length
; b
++) {
1567 const button
= document
.getElementById('noVNC_mouse_button' +
1569 if (blist
[b
] === num
&& !view_only
) {
1570 button
.classList
.remove("noVNC_hidden");
1572 button
.classList
.add("noVNC_hidden");
1578 if (!UI
.rfb
) return;
1579 UI
.rfb
.viewOnly
= UI
.getSetting('view_only');
1581 // Hide input related buttons in view only mode
1582 if (UI
.rfb
.viewOnly
) {
1583 document
.getElementById('noVNC_keyboard_button')
1584 .classList
.add('noVNC_hidden');
1585 document
.getElementById('noVNC_toggle_extra_keys_button')
1586 .classList
.add('noVNC_hidden');
1587 document
.getElementById('noVNC_mouse_button' + UI
.rfb
.touchButton
)
1588 .classList
.add('noVNC_hidden');
1590 document
.getElementById('noVNC_keyboard_button')
1591 .classList
.remove('noVNC_hidden');
1592 document
.getElementById('noVNC_toggle_extra_keys_button')
1593 .classList
.remove('noVNC_hidden');
1594 document
.getElementById('noVNC_mouse_button' + UI
.rfb
.touchButton
)
1595 .classList
.remove('noVNC_hidden');
1599 updateShowDotCursor() {
1600 if (!UI
.rfb
) return;
1601 UI
.rfb
.showDotCursor
= UI
.getSetting('show_dot');
1605 WebUtil
.init_logging(UI
.getSetting('logging'));
1608 updateDesktopName(e
) {
1609 UI
.desktopName
= e
.detail
.name
;
1610 // Display the desktop name in the document title
1611 document
.title
= e
.detail
.name
+ " - noVNC";
1615 if (WebUtil
.getConfigVar('bell', 'on') === 'on') {
1616 const promise
= document
.getElementById('noVNC_bell').play();
1617 // The standards disagree on the return value here
1619 promise
.catch((e
) => {
1620 if (e
.name
=== "NotAllowedError") {
1621 // Ignore when the browser doesn't let us play audio.
1622 // It is common that the browsers require audio to be
1623 // initiated from a user action.
1625 Log
.Error("Unable to play bell: " + e
);
1632 //Helper to add options to dropdown.
1633 addOption(selectbox
, text
, value
) {
1634 const optn
= document
.createElement("OPTION");
1637 selectbox
.options
.add(optn
);
1646 // Set up translations
1647 const LINGUAS
= ["cs", "de", "el", "es", "nl", "pl", "sv", "tr", "zh_CN", "zh_TW"];
1648 l10n
.setup(LINGUAS
);
1649 if (l10n
.language
!== "en" && l10n
.dictionary
=== undefined) {
1650 WebUtil
.fetchJSON('app/locale/' + l10n
.language
+ '.json', (translations
) => {
1651 l10n
.dictionary
= translations
;
1653 // wait for translations to load before loading the UI
1656 Log
.Error("Failed to load translations: " + err
);