2016-10-17 10:24:39 +02:00
|
|
|
//Terminal
|
|
|
|
var post = function(input) {
|
|
|
|
$("#terminal-input").before('<tr class="posted"><td style="color: #66ff33;">' + input + '</td></tr>');
|
|
|
|
window.scrollTo(0, document.body.scrollHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
//command is checked on enter key press
|
|
|
|
$(document).keyup(function(event) {
|
|
|
|
if (event.keyCode == 13) {
|
|
|
|
var command = $('input[class=terminal-input]').val();
|
|
|
|
if (command.length > 0) {
|
|
|
|
post("> " + command);
|
|
|
|
|
2016-10-17 23:23:23 +02:00
|
|
|
//TODO Do i have to switch the order of these two?
|
2016-10-18 23:37:53 +02:00
|
|
|
Terminal.executeCommand(command);
|
2016-10-17 23:23:23 +02:00
|
|
|
$('input[class=terminal-input]').val("");
|
2016-10-17 10:24:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-10-18 23:37:53 +02:00
|
|
|
var Terminal.executeCommand = function(command) {
|
2016-10-17 10:24:39 +02:00
|
|
|
var commandArray = command.split();
|
|
|
|
|
|
|
|
if (commandArray.length == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (commandArray[0]) {
|
2016-10-17 23:23:23 +02:00
|
|
|
case "analyze":
|
|
|
|
//TODO Analyze the system for ports
|
|
|
|
break;
|
|
|
|
case "clear":
|
|
|
|
case "cls":
|
|
|
|
//TODO
|
|
|
|
break;
|
|
|
|
case "connect":
|
2016-10-18 23:37:53 +02:00
|
|
|
//TODO Disconnect from current server in terminal and connect to new one..maybe rename this to telnet?
|
2016-10-17 23:23:23 +02:00
|
|
|
break;
|
|
|
|
case "df":
|
|
|
|
//TODO
|
|
|
|
break;
|
|
|
|
case "hack":
|
|
|
|
//TODO Hack the current PC (usually for money)
|
|
|
|
//You can't hack your home pc or servers you purchased
|
|
|
|
if (Player.currentServer.purchasedByPlayer) {
|
|
|
|
post("Cannot hack your own machines! You are currently connected to your home PC or one of your purchased servers");
|
|
|
|
} else {
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "help":
|
|
|
|
//TODO
|
|
|
|
break;
|
|
|
|
case "hostname":
|
|
|
|
//Print the hostname of current system
|
|
|
|
post(Player.currentServer.hostname);
|
|
|
|
break;
|
|
|
|
case "ifconfig":
|
|
|
|
//Print the IP address of the current system
|
|
|
|
post(Player.currentServer.ip);
|
|
|
|
break;
|
|
|
|
case "kill":
|
|
|
|
//TODO
|
|
|
|
break;
|
|
|
|
case "ls":
|
|
|
|
//TODO
|
|
|
|
break;
|
2016-10-18 23:37:53 +02:00
|
|
|
case "netstat":
|
2016-10-19 23:43:49 +02:00
|
|
|
case "scan":
|
2016-10-18 23:37:53 +02:00
|
|
|
//TODO Displays available network connections using TCP
|
2016-10-17 23:23:23 +02:00
|
|
|
case "ps":
|
|
|
|
//TODO
|
|
|
|
break;
|
|
|
|
case "rm":
|
|
|
|
//TODO
|
|
|
|
break;
|
|
|
|
case "run":
|
|
|
|
//TODO
|
|
|
|
break;
|
2016-10-18 23:37:53 +02:00
|
|
|
case "scp":
|
|
|
|
//TODO
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
|
2016-10-17 10:24:39 +02:00
|
|
|
}
|
2016-10-17 23:23:23 +02:00
|
|
|
}
|
|
|
|
|
2016-10-18 23:37:53 +02:00
|
|
|
var Terminal.runProgram = function(programName) {
|
2016-10-17 23:23:23 +02:00
|
|
|
|
|
|
|
}
|