]>
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 this.regex
= new RegExp('\\b' + RegExp
.escape(nick
) + '\\b', "i");
12 if(text
.match(this.regex
))
18 qwebirc
.ui
.Beeper
= new Class({
19 initialize: function(uiOptions
) {
20 this.uiOptions
= uiOptions
;
22 this.soundInited
= false;
23 this.soundReady
= false;
25 if(this.uiOptions
.BEEP_ON_MENTION
)
28 soundInit: function() {
31 if(!$defined(Browser
.Plugins
.Flash
) || Browser
.Plugins
.Flash
.version
< 8)
33 this.soundInited
= true;
35 this.soundPlayer
= new qwebirc
.sound
.SoundPlayer();
36 this.soundPlayer
.addEvent("ready", function() {
37 this.soundReady
= true;
40 this.soundPlayer
.go();
43 if(!this.soundReady
|| !this.uiOptions
.BEEP_ON_MENTION
)
46 this.soundPlayer
.beep();
50 qwebirc
.ui
.Flasher
= new Class({
51 initialize: function(uiOptions
) {
52 this.uiOptions
= uiOptions
;
54 this.windowFocused
= false;
55 this.canUpdateTitle
= true;
56 this.titleText
= document
.title
;
58 var favIcons
= $$("link[rel=icon]"), favIconParent
= $$("head");
59 if(favIcons
&& favIcons
.length
> 0 && favIconParent
&& favIconParent
.length
> 0) {
60 this.favIcon
= favIcons
[0];
61 this.favIconParent
= favIconParent
[0];
62 this.favIconVisible
= true;
63 this.emptyFavIcon
= new Element("link");
64 this.emptyFavIcon
.rel
= "shortcut icon";
65 this.emptyFavIcon
.href
= "/images/empty_favicon.ico";
67 this.flashing
= false;
69 window
.addEvent("focus", function() { this.windowFocused
= true; this.cancelFlash(); console
.log("focus") }.bind(this));
70 window
.addEvent("blur", function() { this.windowFocused
= false; console
.log("blue") }.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
;