Преглед на файлове

Merge init() into the constructor.

This is logical now since the external update callback can be provided
when the object is created so we don't need a separate init function.
Joel Martin преди 15 години
родител
ревизия
0d1e1b7281
променени са 2 файла, в които са добавени 20 реда и са изтрити 29 реда
  1. 0 1
      include/default_controls.js
  2. 20 28
      include/rfb.js

+ 0 - 1
include/default_controls.js

@@ -117,7 +117,6 @@ load: function(target) {
     DC.rfb = RFB({'target': 'VNC_canvas',
                   'updateState': DC.updateState,
                   'clipboardReceive': DC.clipReceive});
-    DC.rfb.init();
 
     // Unfocus clipboard when over the VNC area
     $('VNC_screen').onmousemove = function () {

+ 20 - 28
include/rfb.js

@@ -215,7 +215,7 @@ RQshiftBytes = function(len) {
 // Setup routines
 //
 
-// Create the public API interface
+// Create the public API interface and initialize
 function constructor() {
     var i;
     Util.Debug(">> RFB.constructor");
@@ -234,6 +234,25 @@ function constructor() {
         updateState('fatal', "No working Canvas");
     }
 
+    init_vars();
+
+    /* Check web-socket-js if no builtin WebSocket support */
+    if (VNC_native_ws) {
+        Util.Info("Using native WebSockets");
+        updateState('loaded', 'noVNC ready (using native WebSockets)');
+    } else {
+        Util.Warn("Using web-socket-js flash bridge");
+        if ((! Util.Flash) ||
+            (Util.Flash.version < 9)) {
+            updateState('fatal', "WebSockets or Adobe Flash is required");
+        } else if (document.location.href.substr(0, 7) === "file://") {
+            updateState('fatal',
+                    "'file://' URL is incompatible with Adobe Flash");
+        } else {
+            updateState('loaded', 'noVNC ready (using Flash WebSockets emulation)');
+        }
+    }
+
     Util.Debug("<< RFB.constructor");
     return that;  // Return the public API interface
 }
@@ -1522,36 +1541,9 @@ clientCutText = function(text) {
 // Public API interface functions
 //
 
-that.init = function () {
-
-    init_vars();
-
-    /* Check web-socket-js if no builtin WebSocket support */
-    if (VNC_native_ws) {
-        Util.Info("Using native WebSockets");
-        updateState('loaded', 'noVNC ready (using native WebSockets)');
-    } else {
-        Util.Warn("Using web-socket-js flash bridge");
-        if ((! Util.Flash) ||
-            (Util.Flash.version < 9)) {
-            updateState('fatal', "WebSockets or Adobe Flash is required");
-        } else if (document.location.href.substr(0, 7) === "file://") {
-            updateState('fatal',
-                    "'file://' URL is incompatible with Adobe Flash");
-        } else {
-            updateState('loaded', 'noVNC ready (using Flash WebSockets emulation)');
-        }
-    }
-};
-
 that.connect = function(host, port, password) {
     //Util.Debug(">> connect");
 
-    // Make sure we have done init checks
-    if ((rfb_state !== 'loaded') && (rfb_state !== 'fatal')) {
-        that.init();
-    }
-
     rfb_host       = host;
     rfb_port       = port;
     rfb_password   = (password !== undefined)   ? password : "";