]>
jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/baseuiwindow.js
1 qwebirc
.ui
.HILIGHT_NONE
= 0;
2 qwebirc
.ui
.HILIGHT_ACTIVITY
= 1;
3 qwebirc
.ui
.HILIGHT_SPEECH
= 2;
4 qwebirc
.ui
.HILIGHT_US
= 3;
6 qwebirc
.ui
.Window
= new Class({
8 initialize: function(parentObject
, client
, type
, name
, identifier
) {
9 this.parentObject
= parentObject
;
14 this.identifier
= identifier
;
15 this.hilighted
= qwebirc
.ui
.HILIGHT_NONE
;
16 this.scrolltimer
= null;
17 this.commandhistory
= this.parentObject
.commandhistory
;
18 this.scrolleddown
= true;
19 this.lastNickHash
= {};
20 //new CommandHistory();
22 updateNickList: function(nicks
) {
24 updateTopic: function(topic
, element
) {
25 qwebirc
.ui
.Colourise("[" + topic
+ "]", element
, this.client
.exec
, this.parentObject
.urlDispatcher
.bind(this.parentObject
), this);
28 if($defined(this.scrolltimer
)) {
29 $clear(this.scrolltimer
);
30 this.scrolltimer
= null;
33 this.parentObject
.__closed(this);
34 this.fireEvent("close", this);
38 this.parentObject
.__setActiveWindow(this);
40 this.setHilighted(qwebirc
.ui
.HILIGHT_NONE
);
42 this.scrollToBottom();
44 deselect: function() {
45 if(!this.parentObject
.singleWindow
)
46 this.scrolleddown
= this.scrolledDown();
47 if($defined(this.scrolltimer
)) {
48 $clear(this.scrolltimer
);
49 this.scrolltimer
= null;
54 addLine: function(type
, line
, colour
, element
) {
55 var hilight
= qwebirc
.ui
.HILIGHT_NONE
;
57 hilight
= qwebirc
.ui
.HILIGHT_ACTIVITY
;
59 if(type
.match(/(NOTICE|ACTION|MSG)$/)) {
60 if(this.type
== qwebirc
.ui
.WINDOW_QUERY
) {
61 hilight
= qwebirc
.ui
.HILIGHT_US
62 } else if(!type
.match(/^OUR/) && this.client
.hilightController
.match(line
["m"])) {
63 hilight
= qwebirc
.ui
.HILIGHT_US
;
65 hilight
= qwebirc
.ui
.HILIGHT_SPEECH
;
70 if(!this.active
&& (hilight
!= qwebirc
.ui
.HILIGHT_NONE
))
71 this.setHilighted(hilight
);
74 line
= this.parentObject
.theme
.message(type
, line
, hilight
== qwebirc
.ui
.HILIGHT_US
);
76 qwebirc
.ui
.Colourise(qwebirc
.irc
.IRCTimestamp(new Date()) + " " + line
, element
, this.client
.exec
, this.parentObject
.urlDispatcher
.bind(this.parentObject
), this);
77 this.scrollAdd(element
);
79 errorMessage: function(message
) {
80 this.addLine("", message
, "red");
82 setHilighted: function(state
) {
83 if(state
== qwebirc
.ui
.HILIGHT_NONE
|| state
>= this.hilighted
)
84 this.hilighted
= state
;
86 scrolledDown: function() {
90 var parent
= this.lines
;
92 var prev
= parent
.getScroll();
93 var prevbottom
= parent
.getScrollSize().y
;
94 var prevsize
= parent
.getSize();
97 if(prevbottom
< prevsize
.y
)
98 prevbottom
= prevsize
.y
;
100 return prev
.y
+ prevsize
.y
== prevbottom
;
102 scrollToBottom: function() {
103 var parent
= this.lines
;
104 var scrollparent
= parent
;
106 if($defined(this.scroller
))
107 scrollparent
= this.scroller
;
109 scrollparent
.scrollTo(parent
.getScroll().x
, parent
.getScrollSize().y
);
111 scrollAdd: function(element
) {
112 var parent
= this.lines
;
114 /* scroll in bursts, else the browser gets really slow */
115 if($defined(element
)) {
116 var sd
= this.scrolledDown();
117 parent
.appendChild(element
);
120 $clear(this.scrolltimer
);
121 this.scrolltimer
= this.scrollAdd
.delay(50, this, [null]);
124 this.scrollToBottom();
125 this.scrolltimer
= null;
128 updateNickList: function(nicks
) {
131 var lnh
= this.lastNickHash
;
133 for(var i
=0;i
<nicks
.length
;i
++) {
137 l
= this.nickListAdd(n
, i
);
146 this.nickListRemove(k
, lnh
[k
]);
148 this.lastNickHash
= nickHash
;
150 nickListAdd: function(position
, nick
) {
152 nickListRemove: function(nick
, stored
) {
154 historyExec: function(line
) {
155 this.commandhistory
.addLine(line
);
156 this.client
.exec(line
);