-
Notifications
You must be signed in to change notification settings - Fork 0
/
console.js
48 lines (40 loc) · 1.3 KB
/
console.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
var gamescreen;
if (!gamescreen) gamescreen = {}; // initialise the top-level module if it does not exist
gamescreen.console = function (where) {
$(where).attr("class", "console-small");
var frameInfo = $("<div class=\"console-frameinfo\"></div>").appendTo($(where));
var permInfo = $("<div class=\"console-permanent\"></div>").appendTo($(where));
var i = 0;
return {
frame_start: function() {
$(frameInfo).html("");
},
frame_end: function() {
},
frame_log: function(text) {
//$(frameInfo).html($(frameInfo).html() + "<sptext);
$("<span class=\"console-frameinfo_entry\">" + text + "</span>").appendTo($(frameInfo));
},
large: function() {
$(where).attr("class", "console-large");
},
small: function() {
$(where).attr("class", "console-small");
},
log: function (text) {
console.log("[C]: " + text);
$("<span class=\"console-log\">" + "[" + i + "] " + text + "</span>").appendTo($(permInfo));
//$(permInfo).html($(permInfo).html() + "[" + i + "] " + text + "\n");
i++;
$(permInfo).scrollTop(50000); // TODO: magic hack number! figure out how to get height of children
}
};
};
gamescreen.console.util = {
point: function (x,y) {
return "[" + x + "," + y + "]";
},
rect: function(x1,y1,x2,y2) {
return "[" + x1 + "," + y1 + "]x[" + x2 + "," + y2 + "]";
}
};