mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feautre(console) add jq-console
This commit is contained in:
parent
7c08ffd8ac
commit
3888ca78b3
4 changed files with 1688 additions and 1 deletions
|
|
@ -3,7 +3,7 @@
|
|||
"menu",
|
||||
"view",
|
||||
"help",
|
||||
"console",
|
||||
"jq_console",
|
||||
"terminal", {
|
||||
"name": "storage",
|
||||
"data": [{
|
||||
|
|
|
|||
130
lib/client/jq_console.js
Normal file
130
lib/client/jq_console.js
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
var CloudCmd, Util, DOM, $;
|
||||
(function(CloudCmd, Util, DOM){
|
||||
'use strict';
|
||||
|
||||
CloudCmd.Jq_console = new ConsoleProto(CloudCmd, Util, DOM);
|
||||
|
||||
function ConsoleProto(CloudCmd, Util, DOM){
|
||||
var Name = 'Console',
|
||||
Key = CloudCmd.Key,
|
||||
Images = DOM.Images,
|
||||
Console = this;
|
||||
|
||||
this.init = function(pCallBack){
|
||||
Util.loadOnLoad([
|
||||
Console.show,
|
||||
load,
|
||||
CloudCmd.View,
|
||||
DOM.jqueryLoad,
|
||||
]);
|
||||
|
||||
DOM.Events.addKey(listener);
|
||||
|
||||
delete Console.init;
|
||||
};
|
||||
|
||||
this.show = function(){
|
||||
var lElement, jqconsole;
|
||||
|
||||
Images.showLoad({top:true});
|
||||
|
||||
lElement = DOM.anyload({
|
||||
name : 'div',
|
||||
className : 'console'
|
||||
});
|
||||
|
||||
jqconsole = $(lElement).jqconsole('header', 'JS> ');
|
||||
|
||||
// Abort prompt on Ctrl+Z.
|
||||
jqconsole.RegisterShortcut('Z', function() {
|
||||
jqconsole.AbortPrompt();
|
||||
handler();
|
||||
});
|
||||
|
||||
// Move to line start Ctrl+A.
|
||||
jqconsole.RegisterShortcut('A', function() {
|
||||
jqconsole.MoveToStart();
|
||||
handler();
|
||||
});
|
||||
|
||||
// Move to line end Ctrl+E.
|
||||
jqconsole.RegisterShortcut('E', function() {
|
||||
jqconsole.MoveToEnd();
|
||||
handler();
|
||||
});
|
||||
|
||||
jqconsole.RegisterMatching('{', '}', 'brace');
|
||||
jqconsole.RegisterMatching('(', ')', 'paran');
|
||||
jqconsole.RegisterMatching('[', ']', 'bracket');
|
||||
// Handle a command.
|
||||
var handler = function(command) {
|
||||
if (command) {
|
||||
try {
|
||||
jqconsole.Write('==> ' + window.eval(command) + '\n');
|
||||
} catch (e) {
|
||||
jqconsole.Write('ERROR: ' + e.message + '\n');
|
||||
}
|
||||
}
|
||||
jqconsole.Prompt(true, handler, function(command) {
|
||||
// Continue line if can't compile the command.
|
||||
try {
|
||||
Function(command);
|
||||
} catch (e) {
|
||||
if (/[\[\{\(]$/.test(command)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
// Initiate the first prompt.
|
||||
handler();
|
||||
|
||||
|
||||
CloudCmd.View.show(lElement);
|
||||
};
|
||||
|
||||
|
||||
this.hide = function(){
|
||||
CloudCmd.View.hide();
|
||||
};
|
||||
|
||||
function load(pCallBack){
|
||||
Util.time(Name + ' load');
|
||||
|
||||
var lDir = CloudCmd.LIBDIRCLIENT + 'terminal/jq-console/',
|
||||
lFiles = [
|
||||
lDir + 'jqconsole.js',
|
||||
lDir + 'jqconsole.css',
|
||||
CloudCmd.LIBDIRCLIENT + 'terminal/jquery-terminal/jquery-migrate-1.0.0.js'
|
||||
];
|
||||
|
||||
DOM.anyLoadInParallel(lFiles, function(){
|
||||
console.timeEnd(Name + ' load');
|
||||
|
||||
Util.exec(pCallBack);
|
||||
});
|
||||
}
|
||||
|
||||
function listener(pEvent){
|
||||
var lF10 = Key.F10,
|
||||
lESC = Key.ESC,
|
||||
lIsBind = Key.isBind(),
|
||||
lKey = pEvent.keyCode;
|
||||
|
||||
switch(lKey){
|
||||
case lF10:
|
||||
Console.show();
|
||||
break;
|
||||
case lESC:
|
||||
Console.hide();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
})(CloudCmd, Util, DOM);
|
||||
45
lib/client/terminal/jq-console/jqconsole.css
Normal file
45
lib/client/terminal/jq-console/jqconsole.css
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#console {
|
||||
height: 400px;
|
||||
width: 750px;
|
||||
position:relative;
|
||||
background-color: black;
|
||||
border: 2px solid #CCC;
|
||||
margin: 0 auto;
|
||||
margin-top: 50px;
|
||||
}
|
||||
.jqconsole {
|
||||
padding: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.jqconsole-cursor {
|
||||
background-color: #999;
|
||||
}
|
||||
.jqconsole-blurred .jqconsole-cursor {
|
||||
background-color: #666;
|
||||
}
|
||||
.jqconsole-prompt {
|
||||
color: #0d0;
|
||||
}
|
||||
.jqconsole-old-prompt {
|
||||
color: #0b0;
|
||||
font-weight: normal;
|
||||
}
|
||||
.jqconsole-input {
|
||||
color: #dd0;
|
||||
}
|
||||
.jqconsole-old-input {
|
||||
color: #bb0;
|
||||
font-weight: normal;
|
||||
}
|
||||
.brace {
|
||||
color: #00FFFF;
|
||||
}
|
||||
.paran {
|
||||
color: #FF00FF;
|
||||
}
|
||||
.bracket {
|
||||
color: #FFFF00;
|
||||
}
|
||||
.jqconsole-composition {
|
||||
background-color: red;
|
||||
}
|
||||
1512
lib/client/terminal/jq-console/jqconsole.js
Normal file
1512
lib/client/terminal/jq-console/jqconsole.js
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue