]>
jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/notifications.js
1 qwebirc
.ui
.HilightController
= new Class({
2 initialize: function(parent
) {
7 match: function(text
) {
8 var nick
= this.parent
.nickname
;
9 if(nick
!= this.prevnick
) {
10 var classes
= '[\\s\\.,;:]';
11 this.regex
= new RegExp('(^|' + classes
+ ')' + RegExp
.escape(nick
) + '(' + classes
+ '|$)', "i");
13 if(text
.match(this.regex
))
19 qwebirc
.ui
.Beeper
= new Class({
20 initialize: function(uiOptions
) {
21 this.uiOptions
= uiOptions
;
23 this.soundInited
= false;
24 this.soundReady
= false;
26 if(this.uiOptions
.BEEP_ON_MENTION
)
29 soundInit: function() {
32 if(!$defined(Browser
.Plugins
.Flash
) || Browser
.Plugins
.Flash
.version
< 8)
34 this.soundInited
= true;
36 this.soundPlayer
= new qwebirc
.sound
.SoundPlayer();
37 this.soundPlayer
.addEvent("ready", function() {
38 this.soundReady
= true;
41 this.soundPlayer
.go();
44 if(!this.soundReady
|| !this.uiOptions
.BEEP_ON_MENTION
)
47 this.soundPlayer
.beep();
51 qwebirc
.ui
.Flasher
= new Class({
52 initialize: function(uiOptions
) {
53 this.uiOptions
= uiOptions
;
55 this.windowFocused
= false;
56 this.canUpdateTitle
= true;
57 this.titleText
= document
.title
;
59 var favIcon
= this._getFavIcon();
60 if($defined(favIcon
)) {
61 this.favIcon
= favIcon
;
62 this.favIconParent
= favIcon
.parentNode
;
63 this.favIconVisible
= true;
64 this.emptyFavIcon
= new Element("link");
65 this.emptyFavIcon
.rel
= "shortcut icon";
66 this.emptyFavIcon
.href
= qwebirc
.global
.staticBaseURL
+ "images/empty_favicon.ico";
67 this.emptyFavIcon
.type
= "image/x-icon";
68 this.flashing
= false;
71 document
.addEvent("mousedown", this.cancelFlash
.bind(this));
72 document
.addEvent("keydown", this.cancelFlash
.bind(this));
74 this.canFlash
= false;
77 _getFavIcon: function() {
78 var favIcons
= $$("head link");
79 for(var i
=0;i
<favIcons
.length
;i
++)
80 if(favIcons
[i
].getAttribute("rel") == "shortcut icon")
84 if(!this.uiOptions
.FLASH_ON_MENTION
|| this.windowFocused
|| !this.canFlash
|| this.flashing
)
87 this.titleText
= document
.title
; /* just in case */
88 var flashA = function() {
90 this.canUpdateTitle
= false;
91 document
.title
= "Activity!";
93 this.flasher
= flashB
.delay(500);
96 var flashB = function() {
98 this.canUpdateTitle
= true;
99 document
.title
= this.titleText
;
101 this.flasher
= flashA
.delay(500);
104 this.flashing
= true;
107 cancelFlash: function() {
108 if(!this.canFlash
|| !$defined(this.flasher
))
111 this.flashing
= false;
113 $clear(this.flasher
);
117 document
.title
= this.titleText
;
118 this.canUpdateTitle
= true;
120 hideFavIcon: function() {
121 if(this.favIconVisible
) {
122 /* only seems to work in firefox */
123 this.favIconVisible
= false;
124 this.favIconParent
.removeChild(this.favIcon
);
125 this.favIconParent
.appendChild(this.emptyFavIcon
);
128 showFavIcon: function() {
129 if(!this.favIconVisible
) {
130 this.favIconVisible
= true;
131 this.favIconParent
.removeChild(this.emptyFavIcon
);
132 this.favIconParent
.appendChild(this.favIcon
);
135 updateTitle: function(text
) {
136 this.titleText
= text
;
137 return this.canUpdateTitle
;
139 focusChange: function(value
) {
140 this.windowFocused
= value
;