Javascript Terminal v0.8.6
by Tgwizman
HTML
<canvas id="c"></canvas>
JavaScript
$_loginStage = 0;
$_parseStage = 0;
$_tempUsername = "";
$_username = "~";
$_tempUser = "";
$_tempPass = "";
$_xPos = 4;
$_yPos = 0;
$_pointer = [''];
$_line = 0;
$_textColor = '#3D3';
$_systemColor = '#3AD';
$_errorColor = '#D33';
$_bgColor = '#000';
$_canvas = document.body.children.c;
$_canvas.style.backgroundColor = $_bgColor;
$_canvas.width = window.innerWidth - 4;
$_canvas.height = window.innerHeight - 4;
$_ctx = $_canvas.getContext("2d");
$_ctx.font = '10px "Inconsolata", "Monaco", "Consolas", "Andale Mono", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace';
$_users = [
["guest",""],
["Tgwizman","password1"],
["root","adminium"],
];
$_sym = [
"$",
">",
">",
];
$_commands = [
["help","help (command)","Displays the help menu"],
["sjsl","sjsl [javascript]","Executes following command in SJSL."],
["sjsl REFL","sjsl","Brings you to a REFL for SJSL"],
["clear","clear","Clears the previous commands"],
["color","color [type] [HexColor]","Changes default colors"],
["login","login [username] [password]","Logs you into session"],
["logout","logout","Logs you out from the current session"],
];
$_color = function (color) {
$_ctx.fillStyle = color;
};
$_print = function (msg) {
$_tempUsername = $_username;
if ($_parseStage != 0) {
$_tempUsername = "";
}
msg = msg || $_tempUsername + $_sym[$_parseStage] + " ";
for (i=0;i<msg.split("\n").length;i++) {
$_xPos = 4;
$_yPos += 15;
$_ctx.fillText(msg.split("\n")[i], $_xPos, $_yPos);
console.log(msg.split("\n")[i]);
}
$_xPos += $_ctx.measureText(msg).width;
};
$_type = function (char) {
$_color($_textColor);
if ($_loginStage == 2) {
$_ctx.fillText("", $_xPos, $_yPos);
} else {
$_ctx.fillText(char, $_xPos, $_yPos);
}
$_pointer[$_line] += char;
$_xPos += $_ctx.measureText(char).width;
};
$_backspace = function (msg) {
$_xPos =...