-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
52 lines (48 loc) · 1.41 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
run_command = function(command){
var argv = command.split(" ")
switch(argv.shift()){
case "make":
switch(argv.join(" ")){
case "all":
return $("div#nojs").html();
default:
return "<span class='error'>Unknown argument: " + argv.join(" ") + "</span>";
}
case "map":
return $("div#nojs div#location").html();
case "tickets":
return $("div#nojs div#tickets").html();
case "eval":
eval(argv.join(""));
return "";
case "help":
var retval;
retval = "<span class='text'>Commands:</span>"
retval += "<ul>";
retval += "<li>make all - All event info</li>";
retval += "<li>map - Map</li>";
retval += "<li>tickets - ticket info</li>";
retval += "<li>print - print page</li>";
retval += "<li>echo - echo a string</li>";
retval += "<li>eval - eval some js</li>";
retval += "<li>help - print this message</li>";
retval += "</ul>";
return retval;
case "print":
window.print();
return "";
case "echo":
return "<span class='text'>" + argv.join(" ") + "</span>";
default:
return "<span class='error'>COMMAND NOT FOUND</span>";
}
};
$("div#prompt").show();
$("div#prompt input").on("keydown", function(e){
if(e.keyCode == 13){
$("div#stdout").append("<span class='command'><span class='arrow'> > </span>" + String(this.value) + "</span><br />");
$("div#stdout").append(run_command(this.value) + "<br/>");
$("div#prompt input").val("");
window.scrollBy(0,999999);
}
});