]> jfr.im git - irc/quakenet/qwebirc.git/blame - js/ui/baseuiwindow.js
Add command history.
[irc/quakenet/qwebirc.git] / js / ui / baseuiwindow.js
CommitLineData
94b18192
CP
1var UIWindow = new Class({
2 Implements: [Events],
3 initialize: function(parentObject, client, type, name, identifier) {
4 this.parentObject = parentObject;
5 this.type = type;
6 this.name = name;
7 this.active = false;
8 this.client = client;
9 this.identifier = identifier;
381fddfd
CP
10 this.hilighted = false;
11 this.scrolltimer = null;
9b63b053
CP
12 this.commandhistory = this.parentObject.commandhistory;
13 //new CommandHistory();
94b18192
CP
14 },
15 updateNickList: function(nicks) {
16 },
17 updateTopic: function(topic) {
18 },
19 close: function() {
381fddfd
CP
20 if($defined(this.scrolltimer)) {
21 $clear(this.scrolltimer);
22 this.scrolltimer = null;
23 }
24
94b18192
CP
25 this.parentObject.__closed(this);
26 this.fireEvent("close", this);
27 },
28 select: function() {
29 this.active = true;
30 this.parentObject.__setActiveWindow(this);
381fddfd 31 if(this.hilighted)
349b99ed 32 this.setHilighted(false);
94b18192
CP
33 },
34 deselect: function() {
35 this.active = false;
36 },
381fddfd
CP
37 addLine: function(type, line, colour, element, parent, scrollparent) {
38 if(!this.active && !this.hilighted)
349b99ed
CP
39 this.setHilighted(true);
40
381fddfd
CP
41 if(type)
42 line = this.parentObject.theme.message(type, line);
43
44 Colourise(IRCTimestamp(new Date()) + " " + line, element);
45
46 this.scrollAdd(element);
94b18192
CP
47 },
48 errorMessage: function(message) {
49 this.addLine("", message, "red");
381fddfd
CP
50 },
51 setHilighted: function(state) {
52 this.hilighted = state;
53 },
54 scrollAdd: function(element) {
55 var parent = this.lines;
56 var scrollparent = parent;
57
58 if($defined(this.scroller))
59 scrollparent = this.scroller;
60
61 var prev = parent.getScroll();
62 var prevbottom = parent.getScrollSize().y;
63 var prevsize = parent.getSize();
64
65 /* scroll in bursts, else the browser gets really slow */
66 if($defined(element)) {
67 parent.appendChild(element);
68 if(this.scrolltimer || (prev.y + prevsize.y == prevbottom)) {
69 if(this.scrolltimer)
70 $clear(this.scrolltimer);
349b99ed 71 this.scrolltimer = this.scrollAdd.delay(50, this, [null, null]);
381fddfd
CP
72 }
73 } else {
74 scrollparent.scrollTo(prev.x, parent.getScrollSize().y);
75 this.scrolltimer = null;
76 }
9b63b053
CP
77 },
78 historyExec: function(line) {
79 this.commandhistory.addLine(line);
80 this.client.exec(line);
94b18192
CP
81 }
82});