mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
fix(console) View -> View || View.show
This commit is contained in:
parent
5b366af07e
commit
d1f1b5977b
1 changed files with 61 additions and 56 deletions
|
|
@ -6,15 +6,18 @@ var CloudCmd, Util, DOM, $;
|
|||
|
||||
function ConsoleProto(CloudCmd, Util, DOM){
|
||||
var Name = 'Console',
|
||||
Element,
|
||||
Key = CloudCmd.Key,
|
||||
Images = DOM.Images,
|
||||
Console = this;
|
||||
|
||||
this.init = function(pCallBack){
|
||||
var lViewFunc = CloudCmd.View.show || CloudCmd.View;
|
||||
|
||||
Util.loadOnLoad([
|
||||
Console.show,
|
||||
load,
|
||||
CloudCmd.View,
|
||||
lViewFunc,
|
||||
DOM.jqueryLoad,
|
||||
]);
|
||||
|
||||
|
|
@ -24,67 +27,69 @@ var CloudCmd, Util, DOM, $;
|
|||
};
|
||||
|
||||
this.show = function(){
|
||||
var lElement, jqconsole;
|
||||
var 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();
|
||||
});
|
||||
if (!Element) {
|
||||
Element = DOM.anyload({
|
||||
name : 'div',
|
||||
className : 'console'
|
||||
});
|
||||
|
||||
// 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 = $(Element).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();
|
||||
|
||||
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);
|
||||
CloudCmd.View.show(Element, function(){
|
||||
$('.jqconsole-prompt')[0].focus();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue