forked from cory/tildefriends
Added a rudimentary command history.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3190 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
8002ce96d6
commit
df2c0b108f
@ -4,11 +4,32 @@ var gHaveIndex = -1;
|
||||
var gSessionId;
|
||||
var gCredentials;
|
||||
var gErrorCount = 0;
|
||||
var gCommandHistory = [];
|
||||
|
||||
var kMaxCommandHistory = 16;
|
||||
|
||||
function enter(event) {
|
||||
if (event.keyCode == 13) {
|
||||
gCommandHistory.push(document.getElementById("input").value);
|
||||
if (gCommandHistory.length > kMaxCommandHistory) {
|
||||
gCommandHistory.shift();
|
||||
}
|
||||
send();
|
||||
event.preventDefault();
|
||||
} else if (event.keyCode == 38) {
|
||||
if (gCommandHistory.length) {
|
||||
var input = document.getElementById("input");
|
||||
gCommandHistory.unshift(input.value);
|
||||
input.value = gCommandHistory.pop();
|
||||
event.preventDefault();
|
||||
}
|
||||
} else if (event.keyCode == 40) {
|
||||
if (gCommandHistory.length) {
|
||||
var input = document.getElementById("input");
|
||||
gCommandHistory.push(input.value);
|
||||
input.value = gCommandHistory.shift();
|
||||
event.preventDefault();
|
||||
}
|
||||
} else if (event.keyCode == 186
|
||||
&& !event.metaKey
|
||||
&& !event.altKey
|
||||
|
Loading…
Reference in New Issue
Block a user