mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
added ability to execute commands on server thrue terminal
This commit is contained in:
parent
aa7befc238
commit
b52910a2cf
7 changed files with 21 additions and 20 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 () {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue