Skip to content
This repository has been archived by the owner on Nov 28, 2018. It is now read-only.

Commit

Permalink
Fixed history bug.
Browse files Browse the repository at this point in the history
 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
spratt authored and chrisdone committed Jun 3, 2010
1 parent 421b5c1 commit 6c326e8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
6 changes: 2 additions & 4 deletions demo.html
Expand Up @@ -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({
Expand All @@ -63,9 +63,7 @@
else return true;
},
commandHandle:function(line,report){
setTimeout(function(){
report(line);
},500);
report(line);
},
animateScroll:true,
promptHistory:true
Expand Down
7 changes: 1 addition & 6 deletions jquery.console.js
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 6c326e8

Please sign in to comment.