]>
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 favIcons
= $$("link[rel=icon]"), favIconParent
= $$("head");
60 if(favIcons
&& favIcons
.length
> 0 && favIconParent
&& favIconParent
.length
> 0) {
61 this.favIcon
= favIcons
[0];
62 this.favIconParent
= favIconParent
[0];
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";
68 this.flashing
= false;
71 document
.addEvent("mousedown", this.cancelFlash
.bind(this));
72 document
.addEvent("keydown", this.cancelFlash
.bind(this));
74 this.canFlash
= false;
78 if(!this.uiOptions
.FLASH_ON_MENTION
|| this.windowFocused
|| !this.canFlash
|| this.flashing
)
81 this.titleText
= document
.title
; /* just in case */
82 var flashA = function() {
84 this.canUpdateTitle
= false;
85 document
.title
= "Activity!";
87 this.flasher
= flashB
.delay(500);
90 var flashB = function() {
92 this.canUpdateTitle
= true;
93 document
.title
= this.titleText
;
95 this.flasher
= flashA
.delay(500);
101 cancelFlash: function() {
102 if(!this.canFlash
|| !$defined(this.flasher
))
105 this.flashing
= false;
107 $clear(this.flasher
);
111 document
.title
= this.titleText
;
112 this.canUpdateTitle
= true;
114 hideFavIcon: function() {
115 if(this.favIconVisible
) {
116 this.favIconVisible
= false;
117 this.favIconParent
.removeChild(this.favIcon
);
118 this.favIconParent
.appendChild(this.emptyFavIcon
);
121 showFavIcon: function() {
122 if(!this.favIconVisible
) {
123 this.favIconVisible
= true;
124 this.favIconParent
.removeChild(this.emptyFavIcon
);
125 this.favIconParent
.appendChild(this.favIcon
);
128 updateTitle: function(text
) {
129 this.titleText
= text
;
130 return this.canUpdateTitle
;
132 focusChange: function(value
) {
133 this.windowFocused
= value
;