]>
Commit | Line | Data |
---|---|---|
1 | qwebirc.ui.HilightController = new Class({\r | |
2 | initialize: function(parent) {\r | |
3 | this.parent = parent;\r | |
4 | this.regex = null;\r | |
5 | this.prevnick = null;\r | |
6 | },\r | |
7 | match: function(text) {\r | |
8 | var nick = this.parent.nickname;\r | |
9 | if(nick != this.prevnick) {\r | |
10 | var classes = '[\\s\\.,;:]';\r | |
11 | this.regex = new RegExp('(^|' + classes + ')' + RegExp.escape(nick) + '(' + classes + '|$)', "i");\r | |
12 | }\r | |
13 | if(text.match(this.regex))\r | |
14 | return true;\r | |
15 | return false;\r | |
16 | }\r | |
17 | });\r | |
18 | \r | |
19 | qwebirc.ui.Beeper = new Class({\r | |
20 | initialize: function(uiOptions) {\r | |
21 | this.uiOptions = uiOptions;\r | |
22 | \r | |
23 | this.soundInited = false;\r | |
24 | this.soundReady = false;\r | |
25 | \r | |
26 | if(this.uiOptions.BEEP_ON_MENTION)\r | |
27 | this.soundInit();\r | |
28 | },\r | |
29 | soundInit: function() {\r | |
30 | if(this.soundInited)\r | |
31 | return;\r | |
32 | if(!$defined(Browser.Plugins.Flash) || Browser.Plugins.Flash.version < 8)\r | |
33 | return;\r | |
34 | this.soundInited = true;\r | |
35 | \r | |
36 | this.soundPlayer = new qwebirc.sound.SoundPlayer();\r | |
37 | this.soundPlayer.addEvent("ready", function() {\r | |
38 | this.soundReady = true;\r | |
39 | }.bind(this));\r | |
40 | \r | |
41 | this.soundPlayer.go();\r | |
42 | },\r | |
43 | beep: function() {\r | |
44 | if(!this.soundReady || !this.uiOptions.BEEP_ON_MENTION)\r | |
45 | return;\r | |
46 | \r | |
47 | this.soundPlayer.beep();\r | |
48 | }\r | |
49 | });\r | |
50 | \r | |
51 | qwebirc.ui.Flasher = new Class({\r | |
52 | initialize: function(uiOptions) {\r | |
53 | this.uiOptions = uiOptions;\r | |
54 | \r | |
55 | this.windowFocused = false;\r | |
56 | this.canUpdateTitle = true;\r | |
57 | this.titleText = document.title;\r | |
58 | \r | |
59 | var favIcons = $$("link[rel=icon]"), favIconParent = $$("head");\r | |
60 | if(favIcons && favIcons.length > 0 && favIconParent && favIconParent.length > 0) {\r | |
61 | this.favIcon = favIcons[0];\r | |
62 | this.favIconParent = favIconParent[0];\r | |
63 | this.favIconVisible = true;\r | |
64 | this.emptyFavIcon = new Element("link");\r | |
65 | this.emptyFavIcon.rel = "shortcut icon";\r | |
66 | this.emptyFavIcon.href = "/images/empty_favicon.ico";\r | |
67 | \r | |
68 | this.flashing = false;\r | |
69 | \r | |
70 | this.canFlash = true;\r | |
71 | document.addEvent("mousedown", this.cancelFlash.bind(this));\r | |
72 | document.addEvent("keydown", this.cancelFlash.bind(this));\r | |
73 | } else {\r | |
74 | this.canFlash = false;\r | |
75 | } \r | |
76 | },\r | |
77 | flash: function() {\r | |
78 | if(!this.uiOptions.FLASH_ON_MENTION || this.windowFocused || !this.canFlash || this.flashing)\r | |
79 | return;\r | |
80 | \r | |
81 | this.titleText = document.title; /* just in case */ \r | |
82 | var flashA = function() {\r | |
83 | this.hideFavIcon();\r | |
84 | this.canUpdateTitle = false;\r | |
85 | document.title = "Activity!";\r | |
86 | \r | |
87 | this.flasher = flashB.delay(500);\r | |
88 | }.bind(this);\r | |
89 | \r | |
90 | var flashB = function() {\r | |
91 | this.showFavIcon();\r | |
92 | this.canUpdateTitle = true;\r | |
93 | document.title = this.titleText;\r | |
94 | \r | |
95 | this.flasher = flashA.delay(500);\r | |
96 | }.bind(this);\r | |
97 | \r | |
98 | this.flashing = true;\r | |
99 | flashA();\r | |
100 | },\r | |
101 | cancelFlash: function() {\r | |
102 | if(!this.canFlash || !$defined(this.flasher))\r | |
103 | return;\r | |
104 | \r | |
105 | this.flashing = false;\r | |
106 | \r | |
107 | $clear(this.flasher);\r | |
108 | this.flasher = null;\r | |
109 | \r | |
110 | this.showFavIcon();\r | |
111 | document.title = this.titleText;\r | |
112 | this.canUpdateTitle = true;\r | |
113 | },\r | |
114 | hideFavIcon: function() {\r | |
115 | if(this.favIconVisible) {\r | |
116 | this.favIconVisible = false;\r | |
117 | this.favIconParent.removeChild(this.favIcon);\r | |
118 | this.favIconParent.appendChild(this.emptyFavIcon);\r | |
119 | }\r | |
120 | },\r | |
121 | showFavIcon: function() {\r | |
122 | if(!this.favIconVisible) {\r | |
123 | this.favIconVisible = true;\r | |
124 | this.favIconParent.removeChild(this.emptyFavIcon);\r | |
125 | this.favIconParent.appendChild(this.favIcon);\r | |
126 | }\r | |
127 | },\r | |
128 | updateTitle: function(text) {\r | |
129 | this.titleText = text;\r | |
130 | return this.canUpdateTitle;\r | |
131 | },\r | |
132 | focusChange: function(value) {\r | |
133 | this.windowFocused = value;\r | |
134 | \r | |
135 | if(value)\r | |
136 | this.cancelFlash();\r | |
137 | }\r | |
138 | });\r |