diff --git a/include/start.js b/include/start.js index b5d90b4c..e3d99a1d 100644 --- a/include/start.js +++ b/include/start.js @@ -1 +1 @@ -window.onload = UI.load; +NoVnc.onload = UI.load; diff --git a/include/vnc.js b/include/vnc.js index 435fdc47..b3801934 100644 --- a/include/vnc.js +++ b/include/vnc.js @@ -9,6 +9,10 @@ /*jslint evil: true */ /*global window, document, INCLUDE_URI */ +var NoVnc = {}; +NoVnc.onload = null; +NoVnc.init_scripts = []; + /* * Load supporting scripts */ @@ -20,13 +24,38 @@ function get_INCLUDE_URI() { * Reference: http://unixpapa.com/js/dyna.html */ function load_scripts(base, files) { - var head = document.getElementsByTagName('head')[0]; - for (var i=0; i 0) + start_loading(); + else if (!!NoVnc.onload) { + NoVnc.onload(); + NoVnc.onload = null; + } + } + function start_loading() { + var head = document.getElementsByTagName('head')[0]; var script = document.createElement('script'); script.type = 'text/javascript'; - script.src = base + files[i]; + script.onload = onloadhook; + script.onreadystatechange = function () { + if (this.readyState == 'complete' || this.readyState == 'loaded') + this.onload(); + } + script.initState = false; + script.src = NoVnc.init_scripts[0]; head.appendChild(script); } + + var needtokick = (NoVnc.init_scripts.length === 0); + for (var i=0; i