diff --git a/ChangeLog b/ChangeLog index 19092aa0..ce696f93 100644 --- a/ChangeLog +++ b/ChangeLog @@ -58,6 +58,8 @@ disabled in browsers. * Added plagin terminal ( ` button under TAB). +* Added ability to execute commands on server thrue terminal. + 2012.08.24, Version 0.1.6 diff --git a/lib/client/socket.js b/lib/client/socket.js index 7fd8de7d..79dcb9af 100644 --- a/lib/client/socket.js +++ b/lib/client/socket.js @@ -1,10 +1,10 @@ /* module make possible connectoin thrue socket.io on a client */ -var CloudCommander, io, socket; +var CloudCommander, io, socket, Term; (function(){ "use strict"; var Util = CloudCommander.Util; - Util.jsload("http://localhost:31337/socket.io/lib/socket.io.js", { + Util.jsload("/socket.io/lib/socket.io.js", { onload : function(){ socket = io.connect(document.location.hostname); @@ -14,6 +14,7 @@ var CloudCommander, io, socket; socket.on('message', function (msg) { console.log(msg); + Term.echo(msg); }); socket.on('disconnect', function () { diff --git a/lib/client/terminal.js b/lib/client/terminal.js index 7839bdf7..f42c7e7d 100644 --- a/lib/client/terminal.js +++ b/lib/client/terminal.js @@ -1,4 +1,4 @@ -var CloudCommander, $; +var CloudCommander, $, Term, socket; /* object contains terminal jqconsole */ (function(){ @@ -20,17 +20,7 @@ var CloudCommander, $; src : 'lib/client/terminal/jquery-terminal/jquery.terminal.css' }); - Util.cssSet({ - id :'terminal-css', - inner :'#terminal{' + - 'position : relative' + - '},' + - '#terminal::selection{' + - 'background: #fe57a1;' + - 'color: #fff;' + - 'text-shadow: none;' + - '}' - }); + Util.jsload('lib/client/socket.js'); var lLoadTerm_func = function(){ Util.jsload('lib/client/terminal/jquery-terminal/jquery.terminal.js', @@ -67,7 +57,9 @@ var CloudCommander, $; $(function($, undefined) { $('#terminal').terminal(function(command, term) { - term.echo(''); + Term = term; + term.echo(''); + socket.send(command); }); }); }; diff --git a/lib/client/terminal/jquery-terminal/jquery.terminal.css b/lib/client/terminal/jquery-terminal/jquery.terminal.css index e3178958..a5450638 100644 --- a/lib/client/terminal/jquery-terminal/jquery.terminal.css +++ b/lib/client/terminal/jquery-terminal/jquery.terminal.css @@ -11,7 +11,6 @@ position: fixed; } .terminal { - padding: 10px; position: relative; overflow: hidden; } @@ -27,7 +26,6 @@ font-family: FreeMono, monospace; color: #aaa; background-color: #000; - font-size: 12px; line-height: 14px; } .terminal .cmd span { diff --git a/lib/client/terminal/jquery-terminal/jquery.terminal.js b/lib/client/terminal/jquery-terminal/jquery.terminal.js index 31abe6d8..dadc8880 100644 --- a/lib/client/terminal/jquery-terminal/jquery.terminal.js +++ b/lib/client/terminal/jquery-terminal/jquery.terminal.js @@ -1656,7 +1656,9 @@ function get_stack(caller) { div = $('
').html(encodeHTML(string)); } output.append(div); - div.width('100%'); + /* + div.width('100%'); + */ scroll_to_bottom(); return div; } diff --git a/lib/server/socket.js b/lib/server/socket.js index 44064d59..8482dfeb 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -20,7 +20,7 @@ exports.listen = function(pServer){ socket.on('message', function(pCommand) { console.log(pCommand); - exec(pCommand, exec); + exec(pCommand, getExec); }); }); @@ -33,7 +33,7 @@ exports.listen = function(pServer){ * @param stdout * @param stderr */ -function exec(error, stdout, stderr) { +function getExec(error, stdout, stderr) { if(stdout){ console.log(stdout); Socket.send(stdout); diff --git a/server.js b/server.js index ad6d25d8..93f324b0 100644 --- a/server.js +++ b/server.js @@ -111,6 +111,9 @@ var CloudFunc = cloudRequire(CloudServer.LIBDIR + '/cloudfunc'); CloudServer.AppCache = cloudRequire(CloudServer.LIBDIRSERVER + '/appcache'); +CloudServer.Socket = cloudRequire(CloudServer.LIBDIRSERVER + + '/socket'); + CloudServer.Obj = cloudRequire(CloudServer.LIBDIRSERVER + '/object'); if(CloudServer.Obj){ @@ -177,6 +180,9 @@ CloudServer.start = function (pConfig) { try { this.Server = http.createServer(this._controller); this.Server.listen(this.Port, this.IP); + + if(CloudServer.Socket) + CloudServer.Socket.listen(this.Server); console.log('Cloud Commander server running at http://' + this.IP + ':' + this.Port);