Looks good I'll try adding that this evening, btw I got a command-recall method going so that you can use the up/down arrows to scroll back and forth through your last ten inputted commands using the following:
in client.js adding these near the top as globals:
// Command recall variables
var lastCommands = new Array(); // Initially setting up the array
var commandRecall = -1; // Needed to track for each up/down arrow
var input_limit = 10; // Remember the last 10 inputs so ideally arrows can cycle them
Then adding this new function:
function keyPressed(value)
{
// ow_Write("KEY PRESS: "+value);
switch(value)
{
case 38:
if (commandRecall < 10 && lastCommands[commandRecall+1])
{
commandRecall++;
document.getElementById("user_input").value = lastCommands[commandRecall];
}
break;
case 40:
if (commandRecall > 0 && lastCommands[commandRecall-1])
{
commandRecall--;
document.getElementById("user_input").value = lastCommands[commandRecall];
}
break;
}
}
Then adding this instead the line that clears the user input inside of the send() function:
if (s)
{
for (n = input_limit; n >= 0; n--)
{
if (n > 0 && lastCommands[n-1])
lastCommands[n] = lastCommands[n-1];
if (n == 0)
lastCommands[n] = s;
}
}
document.getElementById("user_input").value = "";
commandRecall = -1;
and finally adding some keystroke capturing event hooks into the index.php:
document.addEventListener('keydown', function(event)
{
document.getElementById("user_input").focus();
if (event.keyCode == 38)
{
keyPressed(event.keyCode);
}
else if (event.keyCode == 40)
{
keyPressed(event.keyCode);
}
});
Net result is you can up or down arrow through your last ten commands ala typical mud client or shell :)