From 8cbae8c6403f6b1dc97bec0285b0ffbdaa5198ea Mon Sep 17 00:00:00 2001 From: coderaiser Date: Sat, 20 Oct 2012 14:42:22 -0400 Subject: [PATCH] added function socketLoad --- client.js | 7 +++++++ lib/client/socket.js | 16 ++++++++++++++-- lib/client/terminal.js | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/client.js b/client.js index a59e8b93..6165ed8e 100644 --- a/client.js +++ b/client.js @@ -510,6 +510,10 @@ CloudClient.Util = (function(){ } }); }; + + this.socketLoad = function(){ + Util.jsload('lib/client/socket.js'); + }; this.getByTag = function(pTag, pElement){ return (pElement || document).getElementsByTagName(pTag); @@ -1207,6 +1211,9 @@ CloudClient.init = (function(){ getByClass = Util.getByClass; getById = Util.getById; + + Util.socketLoad(); + if(!document.body.scrollIntoViewIfNeeded){ this.OLD_BROWSER = true; Util.jsload(CloudClient.LIBDIRCLIENT + 'ie.js', diff --git a/lib/client/socket.js b/lib/client/socket.js index 9300dec6..1623e760 100644 --- a/lib/client/socket.js +++ b/lib/client/socket.js @@ -7,8 +7,12 @@ var CloudCommander, io; Util = cloudcmd.Util, Messages = [], socket, - JqueryTerminal = cloudcmd.Terminal.JqueryTerminal; + JqueryTerminal; + function getJqueryTerminal(){ + return cloudcmd.Terminal.JqueryTerminal; + } + Util.jsload('/socket.io/lib/socket.io.js', { onload : function(){ socket = io.connect(document.location.hostname); @@ -16,6 +20,8 @@ var CloudCommander, io; cloudcmd.Socket = socket; socket.on('connect', function () { + JqueryTerminal = getJqueryTerminal(); + outToTerminal({stdout: 'socket connected'}); JqueryTerminal.Term.resume(); @@ -29,6 +35,8 @@ var CloudCommander, io; }); socket.on('disconnect', function () { + JqueryTerminal = getJqueryTerminal(); + outToTerminal({stderr: 'socket disconected'}); JqueryTerminal.Term.pause(); @@ -42,9 +50,13 @@ var CloudCommander, io; }); function outToTerminal(pMsg){ - var lTerm = JqueryTerminal.Term, + var lTerm, lResult = true; + JqueryTerminal = getJqueryTerminal(); + if(JqueryTerminal) + lTerm = JqueryTerminal.Term; + if(lTerm){ var lStdout, lStderr; diff --git a/lib/client/terminal.js b/lib/client/terminal.js index 0bab5ac5..d0fa43b9 100644 --- a/lib/client/terminal.js +++ b/lib/client/terminal.js @@ -28,7 +28,7 @@ var CloudCommander, $; Util.cssLoad(lDir + 'terminal.css'); - Util.jsload('lib/client/socket.js'); + Util.socketLoad(); Util.anyLoadOnload([