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 gSessionId;
|
||||||
var gCredentials;
|
var gCredentials;
|
||||||
var gErrorCount = 0;
|
var gErrorCount = 0;
|
||||||
|
var gCommandHistory = [];
|
||||||
|
|
||||||
|
var kMaxCommandHistory = 16;
|
||||||
|
|
||||||
function enter(event) {
|
function enter(event) {
|
||||||
if (event.keyCode == 13) {
|
if (event.keyCode == 13) {
|
||||||
|
gCommandHistory.push(document.getElementById("input").value);
|
||||||
|
if (gCommandHistory.length > kMaxCommandHistory) {
|
||||||
|
gCommandHistory.shift();
|
||||||
|
}
|
||||||
send();
|
send();
|
||||||
event.preventDefault();
|
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
|
} else if (event.keyCode == 186
|
||||||
&& !event.metaKey
|
&& !event.metaKey
|
||||||
&& !event.altKey
|
&& !event.altKey
|
||||||
|
Loading…
Reference in New Issue
Block a user