]> git.proxmox.com Git - mirror_novnc.git/commitdiff
Merge pull request #1204 from juanjoDiaz/small_improvements
authorSamuel Mannehed <samuel@cendio.se>
Mon, 4 Mar 2019 08:32:11 +0000 (09:32 +0100)
committerGitHub <noreply@github.com>
Mon, 4 Mar 2019 08:32:11 +0000 (09:32 +0100)
Small improvements

1  2 
app/ui.js

diff --combined app/ui.js
index db3b1f373fb1fb7b42162ce55ce5bd6b566f7e36,67af7cda1ab45c5f43ee646f1d725c1fad2124fc..17ec48d4bd04dd151ccc151603ae13b6a825d9d7
+++ b/app/ui.js
@@@ -39,22 -39,20 +39,20 @@@ const UI = 
      reconnect_callback: null,
      reconnect_password: null,
  
-     prime(callback) {
-         if (document.readyState === "interactive" || document.readyState === "complete") {
-             UI.load(callback);
-         } else {
-             document.addEventListener('DOMContentLoaded', UI.load.bind(UI, callback));
-         }
-     },
+     prime() {
+         return WebUtil.initSettings().then(() => {
+             if (document.readyState === "interactive" || document.readyState === "complete") {
+                 return UI.start();
+             }
  
-     // Setup rfb object, load settings from browser storage, then call
-     // UI.init to setup the UI/menus
-     load(callback) {
-         WebUtil.initSettings(UI.start, callback);
+             return new Promise((resolve, reject) => {
+                 document.addEventListener('DOMContentLoaded', () => UI.start().then(resolve).catch(reject));
+             });
+         });
      },
  
      // Render default UI and initialize settings menu
-     start(callback) {
+     start() {
  
          UI.initSettings();
  
              UI.openConnectPanel();
          }
  
-         if (typeof callback === "function") {
-             callback(UI.rfb);
-         }
+         return Promise.resolve(UI.rfb);
      },
  
      initFullscreen() {
  };
  
  // Set up translations
 -const LINGUAS = ["cs", "de", "el", "es", "ko", "nl", "pl", "sv", "tr", "zh_CN", "zh_TW"];
 +const LINGUAS = ["cs", "de", "el", "es", "ko", "nl", "pl", "ru", "sv", "tr", "zh_CN", "zh_TW"];
  l10n.setup(LINGUAS);
- if (l10n.language !== "en" && l10n.dictionary === undefined) {
-     WebUtil.fetchJSON('app/locale/' + l10n.language + '.json', (translations) => {
-         l10n.dictionary = translations;
-         // wait for translations to load before loading the UI
-         UI.prime();
-     }, (err) => {
-         Log.Error("Failed to load translations: " + err);
-         UI.prime();
-     });
- } else {
+ if (l10n.language === "en" || l10n.dictionary !== undefined) {
      UI.prime();
+ } else {
+     WebUtil.fetchJSON('app/locale/' + l10n.language + '.json')
+         .then((translations) => { l10n.dictionary = translations; })
+         .catch(err => Log.Error("Failed to load translations: " + err))
+         .then(UI.prime);
  }
  
  export default UI;