-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.js
41 lines (31 loc) · 826 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
$(document).ready(function()
{
$('#prompt').focus();
$('#prompt').keyup(function(e) {
if(e.keyCode == 13)
{
var command = $(this).val();
$(this).val("");
sendCommand(command);
}
});
sendCommand('look', true);
});
function sendCommand(pCommand, pSilent)
{
if (!pSilent)
{
$("#main").html($("#main").html() + "<br/><div class='command'> >> <span>" + pCommand + '</span></div>');
}
$.ajax({
type: "POST",
url: "command.php",
data: 'command='+pCommand,
success: commandDone
});
}
function commandDone(data)
{
$("#main").html($("#main").html() + data + "<br/> ");
$('html, body').animate({scrollTop: $("#main").height() + $("#prompt").height()}, 800, "linear");
}