]>
jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/baseuiwindow.js
82c5af7bf6fee015d940f603469409d3c9b71f4b
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 //new CommandHistory();
21 updateNickList: function(nicks
) {
23 updateTopic: function(topic
, element
) {
24 qwebirc
.ui
.Colourise("[" + topic
+ "]", element
, this.client
.exec
, this.parentObject
.urlDispatcher
.bind(this.parentObject
), this);
27 if($defined(this.scrolltimer
)) {
28 $clear(this.scrolltimer
);
29 this.scrolltimer
= null;
32 this.parentObject
.__closed(this);
33 this.fireEvent("close", this);
37 this.parentObject
.__setActiveWindow(this);
39 this.setHilighted(qwebirc
.ui
.HILIGHT_NONE
);
41 this.scrollToBottom();
43 deselect: function() {
44 if(!this.parentObject
.singleWindow
)
45 this.scrolleddown
= this.scrolledDown();
46 if($defined(this.scrolltimer
)) {
47 $clear(this.scrolltimer
);
48 this.scrolltimer
= null;
53 addLine: function(type
, line
, colour
, element
) {
54 var hilight
= qwebirc
.ui
.HILIGHT_NONE
;
56 hilight
= qwebirc
.ui
.HILIGHT_ACTIVITY
;
58 if(type
.match(/(NOTICE|ACTION|MSG)$/)) {
59 if(this.type
== qwebirc
.ui
.WINDOW_QUERY
) {
60 hilight
= qwebirc
.ui
.HILIGHT_US
61 } else if(!type
.match(/^OUR/) && this.client
.hilightController
.match(line
["m"])) {
62 hilight
= qwebirc
.ui
.HILIGHT_US
;
64 hilight
= qwebirc
.ui
.HILIGHT_SPEECH
;
69 if(!this.active
&& (hilight
!= qwebirc
.ui
.HILIGHT_NONE
))
70 this.setHilighted(hilight
);
73 line
= this.parentObject
.theme
.message(type
, line
, hilight
== qwebirc
.ui
.HILIGHT_US
);
75 qwebirc
.ui
.Colourise(qwebirc
.irc
.IRCTimestamp(new Date()) + " " + line
, element
, this.client
.exec
, this.parentObject
.urlDispatcher
.bind(this.parentObject
), this);
76 this.scrollAdd(element
);
78 errorMessage: function(message
) {
79 this.addLine("", message
, "red");
81 setHilighted: function(state
) {
82 if(state
== qwebirc
.ui
.HILIGHT_NONE
|| state
>= this.hilighted
)
83 this.hilighted
= state
;
85 scrolledDown: function() {
89 var parent
= this.lines
;
91 var prev
= parent
.getScroll();
92 var prevbottom
= parent
.getScrollSize().y
;
93 var prevsize
= parent
.getSize();
96 if(prevbottom
< prevsize
.y
)
97 prevbottom
= prevsize
.y
;
99 return prev
.y
+ prevsize
.y
== prevbottom
;
101 scrollToBottom: function() {
102 var parent
= this.lines
;
103 var scrollparent
= parent
;
105 if($defined(this.scroller
))
106 scrollparent
= this.scroller
;
108 scrollparent
.scrollTo(parent
.getScroll().x
, parent
.getScrollSize().y
);
110 scrollAdd: function(element
) {
111 var parent
= this.lines
;
113 /* scroll in bursts, else the browser gets really slow */
114 if($defined(element
)) {
115 var sd
= this.scrolledDown();
116 parent
.appendChild(element
);
119 $clear(this.scrolltimer
);
120 this.scrolltimer
= this.scrollAdd
.delay(50, this, [null]);
123 this.scrollToBottom();
124 this.scrolltimer
= null;
127 historyExec: function(line
) {
128 this.commandhistory
.addLine(line
);
129 this.client
.exec(line
);