Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed history bug.

 o commandResult calls newPromptBox which sets promptText to the empty string
 o addToHistory uses the value of promptText to push into the history array
 o thus, whenever commandResult was called before addToHistory, an empty
   string would be placed on the history array

Now, addToHistory is always called before commandResult so it pushes the
command to the history array in all cases.
  • Loading branch information...
commit 6c326e8f7f57b851d6bc78abad2b7d02f9e839ed 1 parent 421b5c1
@spratt spratt authored committed
Showing with 3 additions and 10 deletions.
  1. +2 −4 demo.html
  2. +1 −6 jquery.console.js
View
6 demo.html
@@ -53,7 +53,7 @@
welcomeMessage:'Enter some JavaScript expressions to evaluate.'
});
controller2.promptText('5 * 4');
- /* Second console */
+ /* Third console */
var console3 = $('<div class="console2">');
$('body').append(console3);
console3.console({
@@ -63,9 +63,7 @@
else return true;
},
commandHandle:function(line,report){
- setTimeout(function(){
- report(line);
- },500);
+ report(line);
},
animateScroll:true,
promptHistory:true
View
7 jquery.console.js
@@ -346,26 +346,21 @@
// Handle a command
function handleCommand() {
if (typeof config.commandHandle == 'function') {
+ addToHistory(promptText);
var ret = config.commandHandle(promptText,function(msgs){
commandResult(msgs);
});
if (typeof ret == 'boolean') {
if (ret) {
// Command succeeded without a result.
- addToHistory(promptText);
commandResult();
} else {
- addToHistory(promptText);
commandResult('Command failed.',
"jquery-console-message-error");
}
} else if (typeof ret == "string") {
- addToHistory(promptText);
commandResult(ret,"jquery-console-message-success");
- } else if (typeof ret == 'undefined') {
- addToHistory(promptText);
} else if (ret.length) {
- addToHistory(promptText);
commandResult(ret);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.