Hola gente! Cómo les va? Hoy les vengo con un poco de código web. Por cuestiones que no vienen al caso, hoy se me ocurrió incorporar una especie de consola interactiva a mi página web. Después de pensarlo un rato, siendo que iba a ser una consola simple, decidí hacerlo con js.
Primero les dejo una imagen y luego les paso el código.

Muy simple como ven...
Ahora los códigos.
shell.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Interactive shell</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="functions.js"></script>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js?ver=1.4.2'></script>
</head>
<body onload="createPrompt()">
<div class="shell" id="shell"></div>
</body>
</html>
style.css
div.shell {
border:3px solid;
width:1000px;
height:300px;
background-image:url(http://mcflashfun.com/files/theme/header-footer-bg.jpg?10692);
font-family:monospace;
overflow:auto;
}
p, ul{
color:#999;
}
span {
font-weight:bold;
}
span.prompt_inicial {
color:#9AFE2E;
}
span.prompt_final {
color:#199;
}
input.cmd {
background-color:transparent;
border:0px solid;
font-family:monospace;
color:#999;
}
functions.css
var prompt = '<p class="prompt">\
<span class="prompt_inicial">root@root:</span>\<span class="prompt_final">~# </span>\
<input class="cmd" id="active_cmd"type="text" maxlength="20" onkeypress="runCmd(event)"/>\
</p>'
function createPrompt() {
$("#active_cmd").attr( "id", "inactive_cmd" );
$(".shell").append(prompt);
$("#active_cmd").focus();
}
function ayuda() {
var ayuda = "<p>Utiliza alguno de los siguientes comandos para ver información adicional:\
<ul>\
<li>ayuda</li>\
<li>info</li>\
<li>aplicaciones</li>\
<li>limpiar</li>\
</ul>\
</p>"
$(".shell").append(ayuda);
}
function info() {
$(".shell").append("<p>info</p>");
}
function aplicaciones() {
$(".shell").append("<p>aplicaciones</p>");
}
function limpiar() {
$(".shell").html("");
}
function error(text) {
var error = "<p>'" + text + "' no se reconoce como un comando.</p>"
$(".shell").append(error);
}
function runCmd(e) {
if (e.keyCode == 13) {
var text = $("#active_cmd").val();
if (text == "ayuda") {
ayuda();
} else if (text == "info") {
info();
} else if (text == "aplicaciones") {
aplicaciones();
} else if (text == "limpiar") {
limpiar();
} else if (text == "") {
} else {
error(text);
}
createPrompt();
}
}
Por último, quería pedir disculpas a aquellos que la tienen clara con desarrollo web y que probablemente tengan que ver unos cuantos errores imperdonables jeje. Bueno, algún día (espero) voy a mejorar

Espero que le sirva a alguno como base para hacer algo copado.
Saludos!
WhiZ
P.D.: Algo importante. Tiene XSS pero ni ganas de hacer el filtro. Si alguno tiene ganas, adelante jeje.