* See README.md for usage and integration instructions.
*/
-/* jslint white: false, browser: true */
-/* global window, document.getElementById, Util, WebUtil, RFB, Display */
-
import * as Log from '../core/util/logging.js';
import _, { l10n } from './localization.js';
-import { isTouchDevice } from '../core/util/browsers.js';
+import { isTouchDevice } from '../core/util/browser.js';
import { setCapture, getPointerEvent } from '../core/util/events.js';
import KeyTable from "../core/input/keysym.js";
import keysyms from "../core/input/keysymdef.js";
import Keyboard from "../core/input/keyboard.js";
import RFB from "../core/rfb.js";
-import Display from "../core/display.js";
import * as WebUtil from "./webutil.js";
var UI = {
UI.keepControlbar();
}
- // Hide input related buttons in view only mode
- if (UI.rfb && UI.rfb.viewOnly) {
- document.getElementById('noVNC_keyboard_button')
- .classList.add('noVNC_hidden');
- document.getElementById('noVNC_toggle_extra_keys_button')
- .classList.add('noVNC_hidden');
- } else {
- document.getElementById('noVNC_keyboard_button')
- .classList.remove('noVNC_hidden');
- document.getElementById('noVNC_toggle_extra_keys_button')
- .classList.remove('noVNC_hidden');
- }
-
// State change disables viewport dragging.
// It is enabled (toggled) by direct click on the button
UI.setViewDrag(false);
},
toggleControlbarSide: function () {
- // Temporarily disable animation to avoid weird movement
+ // Temporarily disable animation, if bar is displayed, to avoid weird
+ // movement. The transitionend-event will not fire when display=none.
var bar = document.getElementById('noVNC_control_bar');
- bar.style.transitionDuration = '0s';
- bar.addEventListener('transitionend', function () { this.style.transitionDuration = ""; });
+ var barDisplayStyle = window.getComputedStyle(bar).display;
+ if (barDisplayStyle !== 'none') {
+ bar.style.transitionDuration = '0s';
+ bar.addEventListener('transitionend', function () {
+ this.style.transitionDuration = ""; });
+ }
var anchor = document.getElementById('noVNC_control_bar_anchor');
if (anchor.classList.contains("noVNC_right")) {
if (val === null) {
val = WebUtil.readSetting(name, defVal);
}
- UI.updateSetting(name, val);
+ WebUtil.setSetting(name, val);
+ UI.updateSetting(name);
return val;
},
// Update cookie and form control setting. If value is not set, then
// updates from control to current cookie setting.
- updateSetting: function(name, value) {
-
- // Save the cookie for this session
- if (typeof value !== 'undefined') {
- WebUtil.writeSetting(name, value);
- }
+ updateSetting: function(name) {
// Update the settings control
- value = UI.getSetting(name);
+ var value = UI.getSetting(name);
var ctrl = document.getElementById('noVNC_setting_' + name);
if (ctrl.type === 'checkbox') {
},
connect: function(event, password) {
+
+ // Ignore when rfb already exists
+ if (typeof UI.rfb !== 'undefined') {
+ return;
+ }
+
var host = UI.getSetting('host');
var port = UI.getSetting('port');
var path = UI.getSetting('path');
UI.updateVisualState('connecting');
- UI.updateViewOnly();
-
var url;
url = UI.getSetting('encrypt') ? 'wss' : 'ws';
UI.rfb.clipViewport = UI.getSetting('view_clip');
UI.rfb.scaleViewport = UI.getSetting('resize') === 'scale';
UI.rfb.resizeSession = UI.getSetting('resize') === 'remote';
+
+ UI.updateViewOnly(); // requires UI.rfb
},
disconnect: function() {
UI.updateVisualState('disconnecting');
- UI.rfb = undefined;
-
// Don't display the connection settings until we're actually disconnected
},
// UI.disconnect() won't be used in those cases.
UI.connected = false;
+ UI.rfb = undefined;
+
if (!e.detail.clean) {
UI.updateVisualState('disconnected');
if (wasConnected) {
var l = input.value.length;
// Move the caret to the end
input.setSelectionRange(l, l);
- } catch (err) {} // setSelectionRange is undefined in Google Chrome
+ } catch (err) {
+ // setSelectionRange is undefined in Google Chrome
+ }
},
hideVirtualKeyboard: function() {
updateViewOnly: function() {
if (!UI.rfb) return;
UI.rfb.viewOnly = UI.getSetting('view_only');
+
+ // Hide input related buttons in view only mode
+ if (UI.rfb.viewOnly) {
+ document.getElementById('noVNC_keyboard_button')
+ .classList.add('noVNC_hidden');
+ document.getElementById('noVNC_toggle_extra_keys_button')
+ .classList.add('noVNC_hidden');
+ } else {
+ document.getElementById('noVNC_keyboard_button')
+ .classList.remove('noVNC_hidden');
+ document.getElementById('noVNC_toggle_extra_keys_button')
+ .classList.remove('noVNC_hidden');
+ }
+ UI.setMouseButton(1); //has it's own logic for hiding/showing
},
updateLogging: function() {
};
// Set up translations
-var LINGUAS = ["de", "el", "nl", "pl", "sv"];
+var LINGUAS = ["de", "el", "es", "nl", "pl", "sv", "tr", "zh_CN", "zh_TW"];
l10n.setup(LINGUAS);
if (l10n.language !== "en" && l10n.dictionary === undefined) {
WebUtil.fetchJSON('app/locale/' + l10n.language + '.json', function (translations) {
// wait for translations to load before loading the UI
UI.prime();
}, function (err) {
- throw err;
+ Log.Error("Failed to load translations: " + err);
+ UI.prime();
});
} else {
UI.prime();