]> git.proxmox.com Git - mirror_novnc.git/blobdiff - app/ui.js
Add eslint and fix reported issues
[mirror_novnc.git] / app / ui.js
index e39b3f08c01718cc44729948e424a263309e6576..8515387a56b68231934089becd90ad703903b0d6 100644 (file)
--- a/app/ui.js
+++ b/app/ui.js
@@ -8,18 +8,14 @@
  * 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 = {
@@ -552,10 +548,15 @@ var UI = {
     },
 
     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")) {
@@ -724,21 +725,17 @@ var UI = {
         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') {
@@ -1048,8 +1045,6 @@ var UI = {
 
         UI.updateVisualState('disconnecting');
 
-        UI.rfb = undefined;
-
         // Don't display the connection settings until we're actually disconnected
     },
 
@@ -1102,6 +1097,8 @@ var UI = {
         // UI.disconnect() won't be used in those cases.
         UI.connected = false;
 
+        UI.rfb = undefined;
+
         if (!e.detail.clean) {
             UI.updateVisualState('disconnected');
             if (wasConnected) {
@@ -1352,7 +1349,9 @@ var UI = {
             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() {
@@ -1653,7 +1652,7 @@ var UI = {
 };
 
 // Set up translations
-var LINGUAS = ["de", "el", "nl", "pl", "sv", "zh"];
+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) {
@@ -1662,7 +1661,8 @@ if (l10n.language !== "en" && l10n.dictionary === undefined) {
         // 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();