diff --git a/debian/novnc.install b/debian/novnc.install index 9f6a3260..92867bce 100644 --- a/debian/novnc.install +++ b/debian/novnc.install @@ -23,9 +23,7 @@ include/playback.js /usr/share/novnc/include include/rfb.js /usr/share/novnc/include include/ui.js /usr/share/novnc/include include/util.js /usr/share/novnc/include -include/vnc.js /usr/share/novnc/include include/websock.js /usr/share/novnc/include include/webutil.js /usr/share/novnc/include include/jsunzip.js /usr/share/novnc/include -include/start.js /usr/share/novnc/include include/web-socket-js/* /usr/share/novnc/include/web-socket-js diff --git a/include/rfb.js b/include/rfb.js index 2110b7af..5b46c12b 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -1841,15 +1841,16 @@ that.clipboardPasteFrom = function(text) { }; // Override internal functions for testing -that.testMode = function(override_send) { +that.testMode = function(override_send, data_mode) { test_mode = true; - that.recv_message = ws.testMode(override_send); + that.recv_message = ws.testMode(override_send, data_mode); checkEvents = function () { /* Stub Out */ }; that.connect = function(host, port, password) { rfb_host = host; rfb_port = port; rfb_password = password; + init_vars(); updateState('ProtocolVersion', "Starting VNC handshake"); }; }; diff --git a/include/start.js b/include/start.js deleted file mode 100644 index b5d90b4c..00000000 --- a/include/start.js +++ /dev/null @@ -1 +0,0 @@ -window.onload = UI.load; diff --git a/include/ui.js b/include/ui.js index 44e91628..f6eda04c 100644 --- a/include/ui.js +++ b/include/ui.js @@ -10,6 +10,11 @@ /*jslint white: false, browser: true */ /*global window, $D, Util, WebUtil, RFB, Display */ +// Load supporting scripts +window.onscriptsload = function () { UI.load(); }; +Util.load_scripts(["webutil.js", "base64.js", "websock.js", "des.js", + "input.js", "display.js", "jsunzip.js", "rfb.js"]); + var UI = { rfb_state : 'loaded', diff --git a/include/util.js b/include/util.js index fc9242e1..7d1e4c02 100644 --- a/include/util.js +++ b/include/util.js @@ -207,6 +207,45 @@ Util.conf_defaults = function(cfg, api, defaults, arr) { * Cross-browser routines */ + +// Dynamically load scripts without using document.write() +// Reference: http://unixpapa.com/js/dyna.html +// +// Handles the case where load_scripts is invoked from a script that +// itself is loaded via load_scripts. Once all scripts are loaded the +// window.onscriptsloaded handler is called (if set). +Util.get_include_uri = function() { + return (typeof INCLUDE_URI !== "undefined") ? INCLUDE_URI : "include/"; +} +Util._pending_scripts = []; +Util.load_scripts = function(files) { + var head = document.getElementsByTagName('head')[0], + ps = Util._pending_scripts; + for (var f=0; f= 0) { + //console.log("loaded script: " + this.src); + ps.splice(ps.indexOf(this), 1); + } + // Call window.onscriptsload after last script loads + if (ps.length === 0 && window.onscriptsload) { + window.onscriptsload(); + } + } + } + } +} + // Get DOM element position on page Util.getPosition = function (obj) { var x = 0, y = 0; diff --git a/include/vnc.js b/include/vnc.js deleted file mode 100644 index bb4c3ad0..00000000 --- a/include/vnc.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * noVNC: HTML5 VNC client - * Copyright (C) 2012 Joel Martin - * Licensed under MPL 2.0 (see LICENSE.txt) - * - * See README.md for usage and integration instructions. - */ - -/*jslint evil: true */ -/*global window, document, INCLUDE_URI */ - -/* - * Load supporting scripts - */ -function get_INCLUDE_URI() { - return (typeof INCLUDE_URI !== "undefined") ? INCLUDE_URI : "include/"; -} -/* - * Dynamically load a script without using document.write() - * Reference: http://unixpapa.com/js/dyna.html - */ -function load_scripts(base, files) { - var head = document.getElementsByTagName('head')[0]; - for (var i=0; i var INCLUDE_URI= "../include/"; - + - - + + --> - - - - @@ -178,5 +174,8 @@ + + + diff --git a/vnc_auto.html b/vnc_auto.html index 2434d97e..a6273256 100644 --- a/vnc_auto.html +++ b/vnc_auto.html @@ -17,7 +17,7 @@ --> - + @@ -41,6 +41,10 @@ /*global window, $, Util, RFB, */ "use strict"; + // Load supporting scripts + Util.load_scripts(["webutil.js", "base64.js", "websock.js", "des.js", + "input.js", "display.js", "jsunzip.js", "rfb.js"]); + var rfb; function passwordRequired(rfb) { @@ -84,7 +88,7 @@ } } - window.onload = function () { + window.onscriptsload = function () { var host, port, password, path, token; $D('sendCtrlAltDelButton').style.display = "inline";