added ability to execute commands on server thrue terminal

This commit is contained in:
coderaiser 2012-09-20 11:13:49 -04:00
parent aa7befc238
commit b52910a2cf
7 changed files with 21 additions and 20 deletions

View file

@ -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

View file

@ -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 () {

View file

@ -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);
});
});
};

View file

@ -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 {

View file

@ -1656,7 +1656,9 @@ function get_stack(caller) {
div = $('<div/>').html(encodeHTML(string));
}
output.append(div);
div.width('100%');
/*
div.width('100%');
*/
scroll_to_bottom();
return div;
}

View file

@ -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);

View file

@ -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);