1 | (function() |
---|
2 | { |
---|
3 | var _autoStatusTime = 60000; // 1 minuto |
---|
4 | var _autoStatus; |
---|
5 | var _conn = new JITConnector(path_jabberit); |
---|
6 | var _xtools = new JITXTools(path_jabberit); |
---|
7 | var _showhidden = new ShowHidden(300); |
---|
8 | var myWindow = ''; |
---|
9 | var flagMouseOver = ''; |
---|
10 | var flagOpenIM = ''; |
---|
11 | var flagOpenPopup = ''; |
---|
12 | var flagAwayIM = ''; |
---|
13 | var itensSubMenu = []; |
---|
14 | |
---|
15 | // Sniffer Browser |
---|
16 | var agt=navigator.userAgent.toLowerCase(); |
---|
17 | var is_major = parseInt(navigator.appVersion); |
---|
18 | var is_minor = parseFloat(navigator.appVersion); |
---|
19 | var is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) |
---|
20 | && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) |
---|
21 | && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)); |
---|
22 | var is_gecko = (agt.indexOf('gecko') != -1); |
---|
23 | var is_gecko1_5 = (agt.indexOf('firefox/1.5') != -1 || agt.indexOf('firefox/2') != -1 || agt.indexOf('iceweasel/2') != -1); |
---|
24 | var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)); |
---|
25 | var is_ie3 = (is_ie && (is_major < 4)); |
---|
26 | var is_ie4 = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) ); |
---|
27 | var is_ie4up = (is_ie && (is_major >= 4)); |
---|
28 | var is_ie5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) ); |
---|
29 | var is_ie5_5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1)); |
---|
30 | var is_ie5up = (is_ie && !is_ie3 && !is_ie4); |
---|
31 | var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5); |
---|
32 | var is_ie6 = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) ); |
---|
33 | var is_ie6up = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5); |
---|
34 | var is_win = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) ); |
---|
35 | |
---|
36 | if ( !(document.getElementById('jabberit_messenger_content')) ) |
---|
37 | { |
---|
38 | var _jabberit_content = document.createElement('div'); |
---|
39 | _jabberit_content.setAttribute('id', 'jabberit_messenger_content'); |
---|
40 | _jabberit_content = document.body.appendChild(_jabberit_content); |
---|
41 | } |
---|
42 | |
---|
43 | var _window = new JITWindows(_xtools, _jabberit_content); |
---|
44 | var _ldap = new JITLdap( _conn, _xtools, _window, is_ie ); |
---|
45 | |
---|
46 | function addContacts() |
---|
47 | { |
---|
48 | _ldap.add(myWindow); |
---|
49 | } |
---|
50 | |
---|
51 | function addIcon() |
---|
52 | { |
---|
53 | |
---|
54 | var StatusBar = document.getElementById('divStatusBar'); |
---|
55 | |
---|
56 | /** |
---|
57 | * @quando estiver habilitada a opção fora de escritório nos filtros. |
---|
58 | */ |
---|
59 | |
---|
60 | if( div_write_msg = document.getElementById('em_div_write_msg') ) |
---|
61 | { |
---|
62 | var StatusBarIM = document.getElementById('JabberMessenger'); |
---|
63 | div_write_msg.parentNode.insertBefore(StatusBarIM, div_write_msg); |
---|
64 | StatusBarIM.style.paddingLeft = '33px'; |
---|
65 | return; |
---|
66 | } |
---|
67 | |
---|
68 | if( StatusBar ) |
---|
69 | { |
---|
70 | StatusBar.style.paddingLeft = '33px'; |
---|
71 | |
---|
72 | var _div = document.createElement('div'); |
---|
73 | _div.appendChild(StatusBar.parentNode.removeChild(StatusBar.previousSibling)); |
---|
74 | StatusBar.parentNode.insertBefore(_div,StatusBar); |
---|
75 | |
---|
76 | var divJabber = document.createElement('div'); |
---|
77 | divJabber.setAttribute('id', 'JabberMessenger'); |
---|
78 | |
---|
79 | var _status = top.document.createElement('div'); |
---|
80 | _status.setAttribute('id', 'jabberit_login'); |
---|
81 | _status.style.background = 'no-repeat'; |
---|
82 | _status.style.backgroundImage = 'url(' + jabberit_group_open.src + ')'; |
---|
83 | _status.style.float = 'left'; |
---|
84 | _status.style.height = '15px'; |
---|
85 | _status.style.left = '7px'; |
---|
86 | _status.style.margin = '8 0 0 10px'; |
---|
87 | _status.style.padding = '0px'; |
---|
88 | _status.style.position = 'absolute'; |
---|
89 | _status.style.width = '15px'; |
---|
90 | _status.style.cursor = 'pointer'; |
---|
91 | |
---|
92 | divJabber.insertBefore(_status,divJabber.firstChild); |
---|
93 | |
---|
94 | var _menu; |
---|
95 | _menu = top.document.createElement('div'); |
---|
96 | _menu.setAttribute('id','fast_menu_jabberit'); |
---|
97 | _menu.style.backgroundColor = 'cecece'; |
---|
98 | _menu.style.border = '1px dashed #000'; |
---|
99 | _menu.style.display = 'none'; |
---|
100 | _menu.style.margin = '20px 5px 0px -15px'; |
---|
101 | _menu.style.position = 'absolute'; |
---|
102 | _menu.style.zIndex = '99999'; |
---|
103 | _menu.onmouseout = function(){ _showhidden.hiddenObject(false); }; |
---|
104 | _menu.onmouseover = function(){ _showhidden.hiddenObject(true); }; |
---|
105 | |
---|
106 | divJabber.insertBefore(_menu, divJabber.firstChild); |
---|
107 | |
---|
108 | var _menu_div = top.document.createElement('div'); |
---|
109 | _menu_div.setAttribute('id','status_Jabber_Expresso'); |
---|
110 | _menu_div.style.background = 'no-repeat'; |
---|
111 | _menu_div.style.backgroundImage = 'url(' + jabberit_add_user.src + ')'; |
---|
112 | _menu_div.style.float = 'left'; |
---|
113 | _menu_div.style.height = '18px'; |
---|
114 | _menu_div.style.left = '19px'; |
---|
115 | _menu_div.style.margin = '0 0 0 10px'; |
---|
116 | _menu_div.style.padding = '0px'; |
---|
117 | _menu_div.style.position = 'absolute'; |
---|
118 | _menu_div.style.width = '18px'; |
---|
119 | _menu_div.style.cursor = 'pointer'; |
---|
120 | _menu_div.style.zindex = '99999999'; |
---|
121 | |
---|
122 | statusJabberExpresso = _menu_div; |
---|
123 | |
---|
124 | divJabber.insertBefore(_menu_div, divJabber.firstChild); |
---|
125 | StatusBar.insertBefore(divJabber, StatusBar.firstChild); |
---|
126 | |
---|
127 | configEvents(_menu_div,'onclick',showWindow); |
---|
128 | |
---|
129 | configEvents( |
---|
130 | _status, |
---|
131 | 'onclick', |
---|
132 | function() |
---|
133 | { |
---|
134 | var _options = [ |
---|
135 | ['Add Contacts',addContacts], |
---|
136 | ['Help',helpJabberit], |
---|
137 | ['Preferences', preferences], |
---|
138 | ['Change Status', subMenuChangeStatus] |
---|
139 | ]; |
---|
140 | |
---|
141 | var _style_text = 'cursor: pointer; padding:2px 2px 2px 15px; border-bottom:1px solid #dedede; background: no-repeat url(' + jabberit_group_close.src + ');'; |
---|
142 | |
---|
143 | var _xml = _xtools.xml('menu'); |
---|
144 | var _option; |
---|
145 | var _item; |
---|
146 | var _action; |
---|
147 | var _style; |
---|
148 | |
---|
149 | for ( var i in _options ) |
---|
150 | { |
---|
151 | _option = _xml.createElement('option'); |
---|
152 | |
---|
153 | _item = _xml.createElement('item'); |
---|
154 | _item.appendChild(_xml.createTextNode(jabberitGetLang(_options[i][0]))); |
---|
155 | |
---|
156 | _style = _xml.createElement('style'); |
---|
157 | _style.appendChild(_xml.createTextNode(_style_text)); |
---|
158 | |
---|
159 | _option.appendChild(_item); |
---|
160 | _option.appendChild(_style); |
---|
161 | |
---|
162 | _xml.documentElement.appendChild(_option); |
---|
163 | } |
---|
164 | |
---|
165 | _menu.innerHTML = _xtools.parse(_xml, 'options.xsl'); |
---|
166 | _showhidden.action('onmouseover', 'onmouseout', _menu); |
---|
167 | |
---|
168 | _item = _menu.firstChild; |
---|
169 | |
---|
170 | for ( var i in _options ) |
---|
171 | { |
---|
172 | _item.childNodes[i].setAttribute('presence', _options[i]); |
---|
173 | configEvents( |
---|
174 | _item.childNodes[i], |
---|
175 | 'onclick', |
---|
176 | _options[i][1] |
---|
177 | ); |
---|
178 | } |
---|
179 | }); |
---|
180 | } |
---|
181 | } |
---|
182 | |
---|
183 | function autoStatus() |
---|
184 | { |
---|
185 | |
---|
186 | if ( _autoStatus ) |
---|
187 | clearTimeout(_autoStatus); |
---|
188 | |
---|
189 | var _div_status = document.getElementById('status_Jabber_Expresso'); |
---|
190 | if ( _div_status ) |
---|
191 | { |
---|
192 | var _status = _div_status.style.backgroundImage; |
---|
193 | _status = _status.substr(_status.lastIndexOf('/') + 1); |
---|
194 | _status = _status.substr(0, _status.indexOf('.')); |
---|
195 | if ( _status == 'xa' && _div_status.getAttribute('autoStatus') ) |
---|
196 | { |
---|
197 | _div_status.removeAttribute('autoStatus'); |
---|
198 | changeStatusJava("2"); |
---|
199 | } |
---|
200 | } |
---|
201 | |
---|
202 | var TimeStatus = flagAwayIM.split(':'); |
---|
203 | |
---|
204 | if( TimeStatus[1] ) |
---|
205 | _autoStatus = setTimeout(autoStatusHandler, parseInt(TimeStatus[1])*_autoStatusTime); |
---|
206 | else |
---|
207 | _autoStatus = setTimeout(autoStatusHandler, parseInt(_autoStatusTime)); |
---|
208 | } |
---|
209 | |
---|
210 | function autoStatusHandler() |
---|
211 | { |
---|
212 | var _div_status = document.getElementById('status_Jabber_Expresso'); |
---|
213 | if ( _div_status ) |
---|
214 | { |
---|
215 | var _status = _div_status.style.backgroundImage; |
---|
216 | _status = _status.substr(_status.lastIndexOf('/') + 1); |
---|
217 | _status = _status.substr(0, _status.indexOf('.')); |
---|
218 | if ( _status == 'available' ) |
---|
219 | { |
---|
220 | _div_status.setAttribute('autoStatus','true'); |
---|
221 | changeStatusJava("5"); |
---|
222 | } |
---|
223 | } |
---|
224 | } |
---|
225 | |
---|
226 | function changeLabel() |
---|
227 | { |
---|
228 | if( arguments.length > 0 ) |
---|
229 | { |
---|
230 | var element = arguments[0].parentNode.parentNode.firstChild; |
---|
231 | |
---|
232 | if(arguments[0].checked) |
---|
233 | element.innerHTML = "<span style='color:red;'>Digite o Email .: </span>"; |
---|
234 | else |
---|
235 | element.innerHTML = "Nome do Contato .: "; |
---|
236 | } |
---|
237 | } |
---|
238 | |
---|
239 | function changeStatusJava() |
---|
240 | { |
---|
241 | if(arguments.length > 0 ) |
---|
242 | { |
---|
243 | try |
---|
244 | { |
---|
245 | var status = arguments[0]; |
---|
246 | var msg = ( arguments[1] ) ? arguments[1] : ""; |
---|
247 | |
---|
248 | // If Layer; |
---|
249 | if( elementIframe = document.getElementById('iframe_applet_jabberit') ) |
---|
250 | { |
---|
251 | if( !is_ie ) |
---|
252 | elementIframe.contentDocument.applets[0].changeStatusfromExpresso(status, msg); |
---|
253 | else |
---|
254 | elementIframe.contentWindow.document.applets[0].changeStatusfromExpresso(status, msg); |
---|
255 | } |
---|
256 | else // If Pop-Up |
---|
257 | { |
---|
258 | myWindow.document.applets[0].changeStatusfromExpresso(status, msg); |
---|
259 | } |
---|
260 | |
---|
261 | } |
---|
262 | catch(e) |
---|
263 | { |
---|
264 | if( confirm('Deseja conectar o IM ?') ) |
---|
265 | showWindow(); |
---|
266 | } |
---|
267 | } |
---|
268 | } |
---|
269 | |
---|
270 | function configEvents(pObj, pEvent, pHandler) |
---|
271 | { |
---|
272 | if ( typeof pObj == 'object' ) |
---|
273 | { |
---|
274 | if ( pEvent.substring(0, 2) == 'on' ) |
---|
275 | pEvent = pEvent.substring(2, pEvent.length); |
---|
276 | |
---|
277 | if ( pObj.addEventListener ) |
---|
278 | pObj.addEventListener(pEvent, pHandler, false); |
---|
279 | else if ( pObj.attachEvent ) |
---|
280 | pObj.attachEvent('on' + pEvent, pHandler); |
---|
281 | } |
---|
282 | } |
---|
283 | |
---|
284 | function closeWindow() |
---|
285 | { |
---|
286 | myWindow = ''; |
---|
287 | } |
---|
288 | |
---|
289 | function getElementStatus() |
---|
290 | { |
---|
291 | return document.getElementById('status_Jabber_Expresso'); |
---|
292 | } |
---|
293 | |
---|
294 | function getPreferences() |
---|
295 | { |
---|
296 | if( flagOpenIM == '' ) |
---|
297 | { |
---|
298 | _conn.go("$this.db_im.getPreferences", |
---|
299 | function(data) |
---|
300 | { |
---|
301 | var autoConnect = ''; |
---|
302 | flagOpenIM = data; |
---|
303 | |
---|
304 | if( data.indexOf(';') != -1) |
---|
305 | { |
---|
306 | var temp = data.split(';'); |
---|
307 | autoConnect = flagOpenIM = temp[0]; |
---|
308 | |
---|
309 | // Open as Pop-Up |
---|
310 | flagOpenPopup = 'openWindowJabberitPopUp:false'; |
---|
311 | |
---|
312 | if( temp[1] ) |
---|
313 | { |
---|
314 | if( temp[1] == 'openWindowJabberitPopUp:true' || temp[1] == 'openWindowJabberitPopUp:false') |
---|
315 | flagOpenPopup = temp[1]; |
---|
316 | } |
---|
317 | |
---|
318 | // Away |
---|
319 | flagAwayIM = 'flagAwayIM:5'; |
---|
320 | |
---|
321 | if( temp[2] ) |
---|
322 | { |
---|
323 | flagAwayIM = temp[2]; |
---|
324 | } |
---|
325 | } |
---|
326 | else |
---|
327 | { |
---|
328 | autoConnect = flagOpenIM; |
---|
329 | } |
---|
330 | |
---|
331 | if( autoConnect == 'openWindowJabberit:true' ) |
---|
332 | { |
---|
333 | setTimeout('loadscript.showW();', 2500); |
---|
334 | } |
---|
335 | }); |
---|
336 | } |
---|
337 | |
---|
338 | } |
---|
339 | |
---|
340 | function helpJabberit() |
---|
341 | { |
---|
342 | var myWindowHelp = window.open( path_jabberit + 'help.php', 'HelpjabberIM', 'width=800,height=495,top=50,left=50,scrollbars=yes'); |
---|
343 | } |
---|
344 | |
---|
345 | function keyPressSearch() |
---|
346 | { |
---|
347 | var ev = arguments[0]; |
---|
348 | var element = arguments[1]; |
---|
349 | |
---|
350 | if ( ev.keyCode == 13 ) |
---|
351 | if( element.value.length >= 4 ) |
---|
352 | _ldap.search( element.value ); |
---|
353 | else |
---|
354 | alert(jabberitGetLang('Your search argument must be longer than 4 characters.')); |
---|
355 | } |
---|
356 | |
---|
357 | function openPopup() |
---|
358 | { |
---|
359 | var widPopup = '220'; |
---|
360 | |
---|
361 | if( is_ie ) |
---|
362 | widPopup = '250'; |
---|
363 | |
---|
364 | try{ |
---|
365 | |
---|
366 | if(!myWindow ) |
---|
367 | { |
---|
368 | myWindow = window.open('','JabberIM','width='+widPopup+',height=400,top=50,left=50,toolbar=0,menubar=0,resizable=0,scrollbars=0,status=0,location=0,titlebar=0'); |
---|
369 | myWindow.close(); |
---|
370 | myWindow = window.open(path_jabberit + 'client.php','JabberIM','width='+widPopup+',height=400,top=50,left=50,toolbar=0,menubar=0,resizable=0,scrollbars=0,status=0,location=0,titlebar=0'); |
---|
371 | myWindow.blur(); |
---|
372 | configEvents(myWindow,'onbeforeunload', closeWindow ); |
---|
373 | } |
---|
374 | else |
---|
375 | { |
---|
376 | for( var i = 15 ; i > 0 ; i-- ) |
---|
377 | { |
---|
378 | myWindow.moveBy(i,0); myWindow.moveBy(-i,0); |
---|
379 | } |
---|
380 | myWindow.focus(); |
---|
381 | } |
---|
382 | } |
---|
383 | catch(e) |
---|
384 | { |
---|
385 | delete myWindow; |
---|
386 | myWindow = window.open(path_jabberit + 'client.php','JabberIM','width='+widPopup+',height=400,top=50,left=50,toolbar=0,menubar=0,resizable=0,scrollbars=0,status=0,location=0,titlebar=0'); |
---|
387 | myWindow.blur(); |
---|
388 | configEvents(myWindow,'onbeforeunload', closeWindow ); |
---|
389 | } |
---|
390 | } |
---|
391 | |
---|
392 | function openWindow() |
---|
393 | { |
---|
394 | var _win_contacts = _window.load('jabberit_contacts'); |
---|
395 | |
---|
396 | var flagOpenAux = ''; |
---|
397 | |
---|
398 | if( flagOpenIM.indexOf(';') != -1 ) |
---|
399 | { |
---|
400 | var aux = flagOpenIM.split(';'); |
---|
401 | flagOpenAux = aux[0]; |
---|
402 | } |
---|
403 | else |
---|
404 | flagOpenAux = flagOpenIM; |
---|
405 | |
---|
406 | if( flagOpenAux == 'openWindowJabberit:false' ) |
---|
407 | { |
---|
408 | if( !is_ie ) |
---|
409 | _win_contacts.size(220,400); |
---|
410 | else |
---|
411 | _win_contacts.size(250,400); |
---|
412 | } |
---|
413 | else |
---|
414 | { |
---|
415 | if( !is_ie ) |
---|
416 | { |
---|
417 | _win_contacts.size(1,1); |
---|
418 | _win_contacts.wm.style.visibility = 'hidden'; |
---|
419 | } |
---|
420 | else |
---|
421 | { |
---|
422 | _win_contacts.size(0,0); |
---|
423 | } |
---|
424 | } |
---|
425 | |
---|
426 | _win_contacts.bc.style.display = "none"; |
---|
427 | _win_contacts.bx.style.display = "none"; |
---|
428 | |
---|
429 | if( _win_contacts.bz.removeEventListener ) |
---|
430 | _win_contacts.bz.removeEventListener('click',_win_contacts.button, false); |
---|
431 | else |
---|
432 | _win_contacts.bz.detachEvent('onclick',_win_contacts.button); |
---|
433 | |
---|
434 | configEvents( |
---|
435 | _win_contacts.bz, |
---|
436 | "onclick", |
---|
437 | function() |
---|
438 | { |
---|
439 | _win_contacts.size(1,1); |
---|
440 | _win_contacts.wm.style.visibility = 'hidden'; |
---|
441 | _win_contacts.position(50,50); |
---|
442 | _win_contacts.title(''); |
---|
443 | } |
---|
444 | ); |
---|
445 | |
---|
446 | var _params = {'path' : path_jabberit}; |
---|
447 | _win_contacts.content(_xtools.parse(_xtools.xml('contacts_jabberit'), 'contacts_jabberit.xsl', _params)); |
---|
448 | |
---|
449 | if( flagOpenAux == 'openWindowJabberit:false' ) |
---|
450 | { |
---|
451 | if( !is_ie ) |
---|
452 | { |
---|
453 | _win_contacts.wm.style.visibility = "visible"; |
---|
454 | _win_contacts.size(220,400); |
---|
455 | _win_contacts.title('.:: Expresso - JMessenger ::.'); |
---|
456 | } |
---|
457 | else |
---|
458 | { |
---|
459 | _win_contacts.size(250,400); |
---|
460 | _win_contacts.title('.:: Expresso - JMessenger ::.'); |
---|
461 | } |
---|
462 | _win_contacts.position(50,50); |
---|
463 | } |
---|
464 | else |
---|
465 | { |
---|
466 | if( !is_ie ) |
---|
467 | _win_contacts.wm.style.visibility = "hidden"; |
---|
468 | } |
---|
469 | } |
---|
470 | |
---|
471 | function preferences() |
---|
472 | { |
---|
473 | if( !(_window.get('jabberit_preferences')) ) |
---|
474 | { |
---|
475 | var _win_preferences = _window.load('jabberit_preferences'); |
---|
476 | _win_preferences.size(400,310); |
---|
477 | _win_preferences.position(150,100); |
---|
478 | _win_preferences.title('.:: Expresso - JMessenger '+jabberitGetLang('Preferences')+'::.'); |
---|
479 | _win_preferences.bc.style.display = "none"; |
---|
480 | _win_preferences.bx.style.display = "none"; |
---|
481 | _win_preferences.wc.style.padding = "5px"; |
---|
482 | |
---|
483 | if( _win_preferences.bz.removeEventListener ) |
---|
484 | _win_preferences.bz.removeEventListener('click',_win_preferences.button, false); |
---|
485 | else |
---|
486 | _win_preferences.bz.detachEvent('onclick',_win_preferences.button); |
---|
487 | |
---|
488 | configEvents( |
---|
489 | _win_preferences.bz, |
---|
490 | "onclick", |
---|
491 | function() |
---|
492 | { |
---|
493 | _win_preferences.size(1,1); |
---|
494 | _win_preferences.wm.style.visibility = 'hidden'; |
---|
495 | _win_preferences.position(50,50); |
---|
496 | _win_preferences.title(''); |
---|
497 | }); |
---|
498 | |
---|
499 | var _params = {'path' : path_jabberit, |
---|
500 | 'lang1' : jabberitGetLang('Your Preferences'), |
---|
501 | 'lang2' : jabberitGetLang('Connection'), |
---|
502 | 'lang3' : jabberitGetLang('Enable Auto Login IM'), |
---|
503 | 'lang4' : jabberitGetLang('Users OffLine'), |
---|
504 | 'lang5' : jabberitGetLang('Show friends Offline'), |
---|
505 | 'lang6' : jabberitGetLang('Save'), |
---|
506 | 'lang7' : jabberitGetLang('Cancel'), |
---|
507 | 'lang8' : jabberitGetLang('Window'), |
---|
508 | 'lang9' : jabberitGetLang('Open as Pop-Up Window'), |
---|
509 | 'lang10' : jabberitGetLang('Away Presence'), |
---|
510 | 'lang11' : jabberitGetLang('Set status to away after'), |
---|
511 | 'lang12' : jabberitGetLang('minutes'), |
---|
512 | 'langYes': jabberitGetLang('Yes'), |
---|
513 | 'langNo' : jabberitGetLang('No') |
---|
514 | }; |
---|
515 | _win_preferences.content(_xtools.parse(_xtools.xml('preferences_jabberit'), 'preferences_jabberit.xsl', _params)); |
---|
516 | _win_preferences.wc.lastChild.lastChild.onclick = _win_preferences.close; |
---|
517 | } |
---|
518 | else |
---|
519 | { |
---|
520 | var _win_preferences = _window.get('jabberit_preferences'); |
---|
521 | _win_preferences.wm.style.visibility = "visible"; |
---|
522 | _win_preferences.position(150,100); |
---|
523 | _win_preferences.title('.:: Expresso - JMessenger '+jabberitGetLang('Preferences')+'::.'); |
---|
524 | _win_preferences.size(320,250); |
---|
525 | } |
---|
526 | |
---|
527 | // Element openWindowJabberit |
---|
528 | var value1 = flagOpenIM.split(':'); |
---|
529 | var element1 = document.getElementById(value1[0]); |
---|
530 | var valueSelect1 = value1[1]; |
---|
531 | |
---|
532 | for(var i = 0; i < element1.options.length; i++) |
---|
533 | if( element1.options[i].value == valueSelect1 ) |
---|
534 | element1.options[i].selected = true; |
---|
535 | |
---|
536 | |
---|
537 | // Element openWindowJabberitPopUp |
---|
538 | var value2 = flagOpenPopup.split(':'); |
---|
539 | var element2 = document.getElementById(value2[0]); |
---|
540 | var valueSelect2 = value2[1]; |
---|
541 | |
---|
542 | for(var i = 0; i < element2.options.length; i++) |
---|
543 | if( element2.options[i].value == valueSelect2 ) |
---|
544 | element2.options[i].selected = true; |
---|
545 | |
---|
546 | // Element flagAwayIM |
---|
547 | var value3 = flagAwayIM.split(':'); |
---|
548 | var element3 = document.getElementById(value3[0]); |
---|
549 | element3.value = value3[1]; |
---|
550 | |
---|
551 | } |
---|
552 | |
---|
553 | function searchUser() |
---|
554 | { |
---|
555 | var element = arguments[0].previousSibling; |
---|
556 | |
---|
557 | if( element.value.length >= 4 ) |
---|
558 | _ldap.search( element.value ); |
---|
559 | else |
---|
560 | alert(jabberitGetLang('Your search argument must be longer than 4 characters.')); |
---|
561 | } |
---|
562 | |
---|
563 | function setItensStatusMenu() |
---|
564 | { |
---|
565 | if( arguments.length > 0 ) |
---|
566 | { |
---|
567 | var key = parseInt(arguments[0].substring(0, arguments[0].indexOf('-'))); |
---|
568 | var value = arguments[0].substring(arguments[0].indexOf('-') + 1 ); |
---|
569 | |
---|
570 | itensSubMenu[key] = value.toString(); |
---|
571 | } |
---|
572 | } |
---|
573 | |
---|
574 | function setPreferences() |
---|
575 | { |
---|
576 | // Element openWindowJabberit |
---|
577 | var elementOpenW = document.getElementById('openWindowJabberit'); |
---|
578 | var value = ''; |
---|
579 | var flagReload = false; |
---|
580 | |
---|
581 | for(var i = 0 ; i < elementOpenW.options.length; i++) |
---|
582 | if( elementOpenW.options[i].selected == true) |
---|
583 | { |
---|
584 | value = 'preferences1=openWindowJabberit:' + elementOpenW.options[i].value; |
---|
585 | flagOpenIM = 'openWindowJabberit:' + elementOpenW.options[i].value; |
---|
586 | } |
---|
587 | |
---|
588 | // Element openWindowJabberitPopUp |
---|
589 | var elementOpenPop = document.getElementById('openWindowJabberitPopUp'); |
---|
590 | |
---|
591 | for(var i = 0; i < elementOpenPop.options.length; i++ ) |
---|
592 | if( elementOpenPop.options[i].selected == true ) |
---|
593 | { |
---|
594 | value += '&preferences2=openWindowJabberitPopUp:' + elementOpenPop.options[i].value; |
---|
595 | |
---|
596 | if( flagOpenPopup != 'openWindowJabberitPopUp:' + elementOpenPop.options[i].value) |
---|
597 | flagReload = true; |
---|
598 | |
---|
599 | flagOpenPopup = 'openWindowJabberitPopUp:' + elementOpenPop.options[i].value; |
---|
600 | } |
---|
601 | |
---|
602 | // Element flagAwayIM |
---|
603 | var elementFlagIM = document.getElementById('flagAwayIM'); |
---|
604 | |
---|
605 | if( elementFlagIM.value.length > 0 && parseInt(elementFlagIM.value) > 0 ) |
---|
606 | { |
---|
607 | flagAwayIM = 'flagAwayIM:' + elementFlagIM.value; |
---|
608 | value += '&preferences3=flagAwayIM:' + elementFlagIM.value; |
---|
609 | } |
---|
610 | else |
---|
611 | { |
---|
612 | alert(jabberitGetLang('Enter a value greater than or equal to 1!')); |
---|
613 | return false; |
---|
614 | } |
---|
615 | |
---|
616 | _conn.go('$this.db_im.setPreferences', |
---|
617 | function(data) |
---|
618 | { |
---|
619 | if(data == 'true') |
---|
620 | { |
---|
621 | if( flagReload ) |
---|
622 | { |
---|
623 | window.location.reload(); |
---|
624 | myWindow.close(); |
---|
625 | } |
---|
626 | } |
---|
627 | else{ alert(jabberitGetLang('Error saving your preferences!')); } |
---|
628 | |
---|
629 | var _win_preferences = _window.get('jabberit_preferences'); |
---|
630 | _win_preferences.close(); |
---|
631 | }, |
---|
632 | value); |
---|
633 | } |
---|
634 | |
---|
635 | function showDiv() |
---|
636 | { |
---|
637 | var _element = ( myWindow ) ? myWindow.document.body.firstChild : null ; |
---|
638 | if( _element != null ) |
---|
639 | _element.style.visibility = 'visible'; |
---|
640 | } |
---|
641 | |
---|
642 | function showWindow() |
---|
643 | { |
---|
644 | var _win_contacts = _window.get('jabberit_contacts'); |
---|
645 | |
---|
646 | if( flagOpenPopup === 'openWindowJabberitPopUp:true' ) |
---|
647 | { |
---|
648 | openPopup(); |
---|
649 | } |
---|
650 | else |
---|
651 | { |
---|
652 | if ( _win_contacts ) |
---|
653 | { |
---|
654 | _win_contacts.wm.style.visibility = "visible"; |
---|
655 | _win_contacts.title('.:: Expresso - JMessenger ::.'); |
---|
656 | |
---|
657 | if( !is_ie ) |
---|
658 | _win_contacts.size(220,400); |
---|
659 | else |
---|
660 | _win_contacts.size(250,400); |
---|
661 | |
---|
662 | _win_contacts.position(60,60); |
---|
663 | } |
---|
664 | else |
---|
665 | openWindow(); |
---|
666 | } |
---|
667 | } |
---|
668 | |
---|
669 | function subMenuChangeStatus() |
---|
670 | { |
---|
671 | if(document.getElementById('subMenu_Change_Status_JabberIt') == null ) |
---|
672 | { |
---|
673 | var _itens = [ |
---|
674 | ['Online', 'loadscript.subMnChStIt("2",this);', 'available_jabberit.src','jabberit_group_close_black.src'], |
---|
675 | ['Free For Chat', 'loadscript.subMnChStIt("1",this);', 'chat_jabberit.src','jabberit_group_close_black.src'], |
---|
676 | ['Xa', 'loadscript.subMnChStIt("3",this);','xa_jabberit.src','jabberit_group_close_black.src'], |
---|
677 | ['Dnd', 'loadscript.subMnChStIt("4",this);','dnd_jabberit.src','jabberit_group_close_black.src'], |
---|
678 | ['Away', 'loadscript.subMnChStIt("5",this);','away_jabberit.src','jabberit_group_close_black.src'], |
---|
679 | ['Invisible', 'loadscript.subMnChStIt("6",this);','invisible_jabberit.src'] |
---|
680 | ]; |
---|
681 | |
---|
682 | var _itensMenu = "<dl style='margin:2px 2px !important;font-size:8pt !important;background: #cecece;color: #000;'>"; |
---|
683 | |
---|
684 | for(var i in _itens) |
---|
685 | { |
---|
686 | _itensMenu += '<dt onmouseover="elementOnMouseOver(this);" onmouseout="elementOnMouseOut(this, false);" style="cursor: pointer;'; |
---|
687 | if ( i != _itens.length - 1 ) |
---|
688 | _itensMenu += 'border-bottom:1px solid #dedede;'; |
---|
689 | _itensMenu += '">'; |
---|
690 | |
---|
691 | _itensMenu += "<div "; |
---|
692 | if( _itens[i][3] ) |
---|
693 | _itensMenu += "style='background: url(" + eval(_itens[i][3]) + ") no-repeat center right'"; |
---|
694 | _itensMenu += "onclick="+_itens[i][1] +"><img src='" + eval(_itens[i][2]) + "' style='margin-right:3px;'/>" + jabberitGetLang(_itens[i][0]) + "</div></dt>"; |
---|
695 | } |
---|
696 | |
---|
697 | _itensMenu += "</dl>"; |
---|
698 | |
---|
699 | var _subMenu_div = document.createElement("div"); |
---|
700 | _subMenu_div.setAttribute('id','subMenu_Change_Status_JabberIt'); |
---|
701 | _subMenu_div.style.margin = '-10px 5px 0px 0px'; |
---|
702 | _subMenu_div.style.background = '#cecece'; |
---|
703 | _subMenu_div.style.border = '1px dashed #000'; |
---|
704 | _subMenu_div.style.float = 'left'; |
---|
705 | _subMenu_div.style.position = 'absolute'; |
---|
706 | _subMenu_div.style.left = '55px'; |
---|
707 | _subMenu_div.style.width = ( is_ie ) ? '160px': '140px';; |
---|
708 | _subMenu_div.style.zindex = '99999'; |
---|
709 | _subMenu_div.innerHTML = _itensMenu; |
---|
710 | |
---|
711 | var elementParent = document.getElementById('fast_menu_jabberit'); |
---|
712 | elementParent.appendChild(_subMenu_div); |
---|
713 | } |
---|
714 | } |
---|
715 | |
---|
716 | function subMenuChangeStatusItens() |
---|
717 | { |
---|
718 | if( arguments.length > 0 ) |
---|
719 | { |
---|
720 | var status = arguments[0]; |
---|
721 | var element = arguments[1]; |
---|
722 | var msg = ""; |
---|
723 | |
---|
724 | if( itensSubMenu.length > 0 ) |
---|
725 | { |
---|
726 | var string = ""; |
---|
727 | for( var i = 0; i < itensSubMenu.length ; i++ ) |
---|
728 | { |
---|
729 | if( itensSubMenu[i] != undefined ) |
---|
730 | { |
---|
731 | string = itensSubMenu[i].substring(1); |
---|
732 | string = string.substring(0, string.indexOf("]")).toString(); |
---|
733 | |
---|
734 | if( string != "" ) |
---|
735 | { |
---|
736 | if( status == i ) |
---|
737 | { |
---|
738 | if ( ! ( string.indexOf( ',' ) < 0 ) ) |
---|
739 | { |
---|
740 | var phases = string.split(','); |
---|
741 | var _itensMenu = "<dl style='padding:1px !important; margin:2px 2px !important;font-size:8pt !important;background: #cecece;color: #000;'>"; |
---|
742 | for ( var m = 0; m < phases.length; m++ ) |
---|
743 | { |
---|
744 | _itensMenu += "<dt onmouseover='elementOnMouseOver(this);' onmouseout='elementOnMouseOut(this, false);' style='cursor: pointer;border-bottom:1px solid #dedede;'>"; |
---|
745 | _itensMenu += "<div onclick='loadscript.chgStatusJava(\""+i+"\", \""+phases[m]+"\")'><img src='" + jabberit_group_close.src + "' style='margin-right:3px;'/>" + phases[m] + "</div></dt>"; |
---|
746 | } |
---|
747 | _itensMenu += "</dl>"; |
---|
748 | } |
---|
749 | else |
---|
750 | { |
---|
751 | var _itensMenu = "<dl style='padding:1px !important; margin:2px 2px !important;font-size:8pt !important;background: #cecece;color: #000;'>"; |
---|
752 | _itensMenu += "<dt onmouseover='elementOnMouseOver(this);' onmouseout='elementOnMouseOut(this, false);' style='cursor: pointer;'>"; |
---|
753 | _itensMenu += "<div onclick='loadscript.chgStatusJava(\""+i+"\", \""+string+"\");'><img src='" + jabberit_group_close.src + "' style='margin-right:3px;'/>" + string + "</div></dt>"; |
---|
754 | _itensMenu += "</dl>"; |
---|
755 | } |
---|
756 | } |
---|
757 | |
---|
758 | for( var j = 0 ; j < 6 ; j++ ) |
---|
759 | { |
---|
760 | if( document.getElementById('ItemSubMenuJabberd_' + j) != null ) |
---|
761 | { |
---|
762 | var ElementItem = document.getElementById('ItemSubMenuJabberd_' + j); |
---|
763 | ElementItem.parentNode.removeChild(ElementItem); |
---|
764 | } |
---|
765 | } |
---|
766 | } |
---|
767 | } |
---|
768 | } |
---|
769 | |
---|
770 | if( _itensMenu ) |
---|
771 | { |
---|
772 | var _subMenuItem_div = document.createElement("div"); |
---|
773 | _subMenuItem_div.setAttribute('id','ItemSubMenuJabberd_' + status); |
---|
774 | _subMenuItem_div.style.margin = ( is_ie ) ? '-3px 5px 0px 0px' : '-20px 5px 0px 0px'; |
---|
775 | _subMenuItem_div.style.background = '#cecece'; |
---|
776 | _subMenuItem_div.style.border = '1px dashed #000'; |
---|
777 | _subMenuItem_div.style.float = 'left'; |
---|
778 | _subMenuItem_div.style.position = 'absolute'; |
---|
779 | _subMenuItem_div.style.left = ( is_ie ) ? '157px' : '140px'; |
---|
780 | _subMenuItem_div.style.width = ( is_ie ) ? '180px': '160px'; |
---|
781 | _subMenuItem_div.style.zindex = '99999'; |
---|
782 | _subMenuItem_div.innerHTML = _itensMenu; |
---|
783 | |
---|
784 | element.appendChild( _subMenuItem_div ); |
---|
785 | }else |
---|
786 | changeStatusJava(status,""); |
---|
787 | } |
---|
788 | } |
---|
789 | } |
---|
790 | |
---|
791 | function Load() |
---|
792 | { |
---|
793 | addIcon(); |
---|
794 | getPreferences(); |
---|
795 | |
---|
796 | // AutoStatus Away |
---|
797 | autoStatus(); |
---|
798 | configEvents(document, 'onmousemove', autoStatus); |
---|
799 | configEvents(document, 'onkeypress', autoStatus); |
---|
800 | } |
---|
801 | |
---|
802 | Load.prototype.adIcon = addIcon; |
---|
803 | Load.prototype.autoStatusIM = autoStatus; |
---|
804 | Load.prototype.chgStatusJava = changeStatusJava; |
---|
805 | Load.prototype.closeW = closeWindow; |
---|
806 | Load.prototype.cLabel = changeLabel; |
---|
807 | Load.prototype.getElement = getElementStatus; |
---|
808 | Load.prototype.keyPress = keyPressSearch; |
---|
809 | Load.prototype.search = searchUser; |
---|
810 | Load.prototype.setItensStatus = setItensStatusMenu; |
---|
811 | Load.prototype.setPrefe = setPreferences; |
---|
812 | Load.prototype.show = showDiv; |
---|
813 | Load.prototype.showW = showWindow; |
---|
814 | Load.prototype.subMnChStIt = subMenuChangeStatusItens; |
---|
815 | |
---|
816 | configEvents(window, 'onload', function( ) |
---|
817 | { |
---|
818 | window.loadscript = new Load; |
---|
819 | }); |
---|
820 | |
---|
821 | })(); |
---|
822 | |
---|
823 | // Functions OnMouseOver e OnMouseOut |
---|
824 | |
---|
825 | function elementOnMouseOut() |
---|
826 | { |
---|
827 | if( arguments.length > 0 ) |
---|
828 | { |
---|
829 | var _element = arguments[0]; |
---|
830 | _element.style.backgroundColor = ''; |
---|
831 | _element.style.border = ''; |
---|
832 | if( !arguments[1] ) |
---|
833 | _element.style.borderBottom = '1px solid #dedede'; |
---|
834 | } |
---|
835 | } |
---|
836 | |
---|
837 | function elementOnMouseOver() |
---|
838 | { |
---|
839 | if( arguments.length > 0 ) |
---|
840 | { |
---|
841 | var _element = arguments[0]; |
---|
842 | _element.style.backgroundColor = 'white'; |
---|
843 | _element.style.border = '1px solid black'; |
---|
844 | } |
---|
845 | } |
---|
846 | |
---|