added fake replies of "command not found"

This commit is contained in:
Joshua Seigler 2014-12-20 14:35:45 -05:00
parent edae59d5e7
commit adae1b71a7
8 changed files with 90 additions and 56 deletions

View file

@ -1,4 +1,16 @@
(function() {
function escapeHTML(html) {
var fn = function(tag) {
var charsToReplace = {
"&": "&",
"<": "&lt;",
">": "&gt;",
'"': "&#34;"
};
return charsToReplace[tag] || tag;
};
return html.replace(/[&<>"]/g, fn);
}
function syncTyping() {
var beforeSelection, selection, afterSelection;
beforeSelection = this.value.slice(0, this.selectionStart);
@ -12,4 +24,13 @@
commandline.onkeydown = syncTyping;
commandline.onkeyup = syncTyping;
commandline.onselect = syncTyping;
function handleForm() {
var scrollback = document.getElementById("scrollback");
var val = this.command.value;
this.command.value = "";
document.getElementById("typing").innerHTML = "";
scrollback.innerHTML = scrollback.innerHTML + "a>" + escapeHTML(val) + "<br>Command not found.<br>";
return false;
}
document.forms[0].onsubmit = handleForm;
})();