rendered paste body <script language="javascript">
//<!--
var chat_history = [];
var index = -1;
var limit = 10;
$("#input_form").bind("submit", function(e) {
if($("#input_message").val() !== "") {
index = -1;
// limiting the array
if(chat_history.length == limit) {
delete chat_history[limit-1];
}
chat_history.unshift($("#input_message").set("value", "").get(0).focus().val());
$("#input_form").get(0).submit();
return false;
}
});
$("#input_message").bind("keydown", function(e) {
// increase or decrease index
if(e.keyCode == 38 || e.keyCode == 40) {
if(e.keyCode == 38) {
if(index < chat_history.length) {
index++;
}
} else {
if(index >= 0) {
index--;
}
}
// returning the string
ret = "";
if(typeof chat_history[index] != "undefined") {
ret = chat_history[index];
}
$(this).val(ret);
}
});
//-->
</script>