1 | (function() |
---|
2 | { |
---|
3 | var fullName = ""; |
---|
4 | var path = ""; |
---|
5 | var addUser = null; |
---|
6 | var conn = null; |
---|
7 | var selectEditable = null; |
---|
8 | var showhidden = null; |
---|
9 | var timeoutId = null |
---|
10 | var userCurrent = null; |
---|
11 | var Xtools = null; |
---|
12 | var zIndex = 9001; |
---|
13 | |
---|
14 | // Images |
---|
15 | var add_user = new Image(); |
---|
16 | add_user.src = path_jabberit + 'templates/default/images/adduser_azul.png'; |
---|
17 | |
---|
18 | var arrow_down = new Image(); |
---|
19 | arrow_down.src = path_jabberit + 'templates/default/images/arrow_down.gif'; |
---|
20 | |
---|
21 | var arrow_right = new Image(); |
---|
22 | arrow_right.src = path_jabberit + 'templates/default/images/arrow_right.gif'; |
---|
23 | |
---|
24 | function actionButton() |
---|
25 | { |
---|
26 | if( arguments.length > 0 ) |
---|
27 | { |
---|
28 | var e = arguments[0]; |
---|
29 | var jid = arguments[1]; |
---|
30 | var index = arguments[2]; |
---|
31 | var coord = null; |
---|
32 | |
---|
33 | if ( !e ) |
---|
34 | e = window.event; |
---|
35 | |
---|
36 | var _X = e.clientX + document.body.scrollLeft - document.body.clientLeft; |
---|
37 | var _Y = e.clientY + document.body.scrollTop - document.body.clientTop; |
---|
38 | |
---|
39 | coord = { X : _X, Y : _Y }; |
---|
40 | |
---|
41 | window.document.oncontextmenu = function() |
---|
42 | { |
---|
43 | return false; |
---|
44 | }; |
---|
45 | |
---|
46 | if( e.button ) |
---|
47 | { |
---|
48 | if( e.button > 1 ) |
---|
49 | optionsItensContact( jid, index, coord ); |
---|
50 | else |
---|
51 | TrophyIM.rosterClick(jid); |
---|
52 | } |
---|
53 | else if( e.which ) |
---|
54 | { |
---|
55 | if( e.which > 1 ) |
---|
56 | optionsItensContact( jid, index, coord ); |
---|
57 | else |
---|
58 | if( e.target.id ) |
---|
59 | TrophyIM.rosterClick(jid); |
---|
60 | } |
---|
61 | } |
---|
62 | } |
---|
63 | |
---|
64 | function addContact() |
---|
65 | { |
---|
66 | if( arguments.length > 0 ) |
---|
67 | addUser.add(); |
---|
68 | else |
---|
69 | addUser.show(); |
---|
70 | } |
---|
71 | |
---|
72 | function addIcon() |
---|
73 | { |
---|
74 | var StatusBar = getElement('divStatusBar'); |
---|
75 | |
---|
76 | /** |
---|
77 | * @quando estiver habilitada a opção fora de escritório nos filtros. |
---|
78 | */ |
---|
79 | |
---|
80 | if( div_write_msg = getElement('em_div_write_msg') ) |
---|
81 | { |
---|
82 | var StatusBarIM = getElement('JabberMessenger'); |
---|
83 | StatusBarIM.style.paddingLeft = '33px'; |
---|
84 | |
---|
85 | div_write_msg.parentNode.insertBefore( StatusBarIM, div_write_msg ); |
---|
86 | |
---|
87 | return; |
---|
88 | } |
---|
89 | |
---|
90 | if( StatusBar ) |
---|
91 | { |
---|
92 | StatusBar.style.paddingLeft = '33px'; |
---|
93 | |
---|
94 | var _div = document.createElement('div'); |
---|
95 | _div.appendChild(StatusBar.parentNode.removeChild(StatusBar.previousSibling)); |
---|
96 | |
---|
97 | StatusBar.parentNode.insertBefore( _div, StatusBar); |
---|
98 | |
---|
99 | var divJabber = document.createElement('div'); |
---|
100 | divJabber.setAttribute('id', 'JabberMessenger'); |
---|
101 | |
---|
102 | var _fastMenu = top.document.createElement('div'); |
---|
103 | _fastMenu.setAttribute('id', 'fast_menu_jabber_expresso'); |
---|
104 | _fastMenu.style.background = 'no-repeat'; |
---|
105 | _fastMenu.style.backgroundImage = 'url(' + arrow_down.src + ')'; |
---|
106 | _fastMenu.style.float = 'left'; |
---|
107 | _fastMenu.style.height = '15px'; |
---|
108 | _fastMenu.style.left = '7px'; |
---|
109 | _fastMenu.style.margin = '8 0 0 10px'; |
---|
110 | _fastMenu.style.padding = '0px'; |
---|
111 | _fastMenu.style.position = 'absolute'; |
---|
112 | _fastMenu.style.width = '15px'; |
---|
113 | _fastMenu.style.cursor = 'pointer'; |
---|
114 | |
---|
115 | divJabber.insertBefore( _fastMenu, divJabber.firstChild ); |
---|
116 | |
---|
117 | // Add event onclick element _fastMenu |
---|
118 | configEvents( _fastMenu, 'onclick', function(){ fastMenu(_fastMenu); }); |
---|
119 | |
---|
120 | var _statusJabber = top.document.createElement('div'); |
---|
121 | _statusJabber.setAttribute('id','status_jabber_expresso'); |
---|
122 | _statusJabber.style.background = 'no-repeat'; |
---|
123 | _statusJabber.style.backgroundImage = 'url(' + add_user.src +')'; |
---|
124 | _statusJabber.style.float = 'left'; |
---|
125 | _statusJabber.style.height = '18px'; |
---|
126 | _statusJabber.style.left = '19px'; |
---|
127 | _statusJabber.style.margin = '0 0 0 10px'; |
---|
128 | _statusJabber.style.padding = '0px'; |
---|
129 | _statusJabber.style.position = 'absolute'; |
---|
130 | _statusJabber.style.width = '18px'; |
---|
131 | _statusJabber.style.cursor = 'pointer'; |
---|
132 | _statusJabber.style.zindex = '999999'; |
---|
133 | |
---|
134 | divJabber.insertBefore( _statusJabber, divJabber.firstChild ); |
---|
135 | |
---|
136 | StatusBar.insertBefore( divJabber, StatusBar.firstChild ); |
---|
137 | |
---|
138 | // Add event onclick element _statusJabber |
---|
139 | configEvents( _statusJabber, 'onclick', function(){ TrophyIM.load();}); |
---|
140 | } |
---|
141 | } |
---|
142 | |
---|
143 | function clrAllContacts() |
---|
144 | { |
---|
145 | getElement("JabberIMRoster").innerHTML = ""; |
---|
146 | } |
---|
147 | |
---|
148 | function configEvents(pObj, pEvent, pHandler) |
---|
149 | { |
---|
150 | if ( typeof pObj == 'object' ) |
---|
151 | { |
---|
152 | if ( pEvent.substring(0, 2) == 'on' ) |
---|
153 | pEvent = pEvent.substring(2, pEvent.length); |
---|
154 | |
---|
155 | if ( pObj.addEventListener ) |
---|
156 | pObj.addEventListener(pEvent, pHandler, false); |
---|
157 | else if ( pObj.attachEvent ) |
---|
158 | pObj.attachEvent('on' + pEvent, pHandler); |
---|
159 | } |
---|
160 | } |
---|
161 | |
---|
162 | function fastMenu() |
---|
163 | { |
---|
164 | if( arguments.length > 0 ) |
---|
165 | { |
---|
166 | var element = arguments[0]; |
---|
167 | |
---|
168 | if( showhidden == null ) |
---|
169 | showhidden = new ShowHidden(300); |
---|
170 | |
---|
171 | var _options = [ |
---|
172 | ['Adicionar Contato', 'loadIM.addContact();' ], |
---|
173 | ['Ajuda', 'alert("2")' ], |
---|
174 | ['Preferências', 'alert("3")'], |
---|
175 | ]; |
---|
176 | |
---|
177 | var _itens = ""; |
---|
178 | |
---|
179 | for( var i in _options ) |
---|
180 | { |
---|
181 | if( typeof(_options) == "object" ) |
---|
182 | { |
---|
183 | _itens += '<img src="'+arrow_right.src+'"/>'; |
---|
184 | _itens += '<span style="cursor:pointer; margin:3px;" onclick='+_options[i][1]+'>'; |
---|
185 | _itens += _options[i][0] + '</span><br/>'; |
---|
186 | } |
---|
187 | } |
---|
188 | |
---|
189 | var _optionsItens = document.createElement("div"); |
---|
190 | _optionsItens.style.marginTop = "19px"; |
---|
191 | _optionsItens.style.marginLeft = "-8px"; |
---|
192 | _optionsItens.className = "x-menu"; |
---|
193 | _optionsItens.style.zIndex = '999999'; |
---|
194 | _optionsItens.innerHTML = _itens; |
---|
195 | |
---|
196 | showhidden.action('onmouseover', 'onmouseout', _optionsItens); |
---|
197 | |
---|
198 | element.parentNode.onmouseout = function(){ showhidden.hiddenObject(false); }; |
---|
199 | element.parentNode.onmouseover = function(){ showhidden.hiddenObject(true); }; |
---|
200 | element.parentNode.appendChild( _optionsItens ); |
---|
201 | |
---|
202 | } |
---|
203 | } |
---|
204 | |
---|
205 | function getElement( elementId ) |
---|
206 | { |
---|
207 | return document.getElementById( elementId ); |
---|
208 | } |
---|
209 | |
---|
210 | function getPhotoUser( jid ) |
---|
211 | { |
---|
212 | var _divPhoto = getElement( jid + '__photo' ); |
---|
213 | |
---|
214 | if( _divPhoto.style.backgroundImage.indexOf('photo.png') > 0 ) |
---|
215 | { |
---|
216 | var _imgUser = path_jabberit + 'inc/WebService.php?' + Date.parse( new Date ); |
---|
217 | _imgUser += '&photo_ldap=' + jid; |
---|
218 | |
---|
219 | _divPhoto.style.backgroundImage = 'url(' + _imgUser + ')'; |
---|
220 | } |
---|
221 | } |
---|
222 | |
---|
223 | function getUserCurrent() |
---|
224 | { |
---|
225 | return userCurrent; |
---|
226 | } |
---|
227 | |
---|
228 | function getZindex() |
---|
229 | { |
---|
230 | return zIndex++; |
---|
231 | } |
---|
232 | |
---|
233 | function groupsHidden() |
---|
234 | { |
---|
235 | if( arguments.length > 0 ) |
---|
236 | { |
---|
237 | var _element = arguments[0]; |
---|
238 | _element.style.background = "url('"+path_jabberit+"templates/default/images/arrow_right.gif') no-repeat center left"; |
---|
239 | _element.onclick = function(){ groupsVisible(_element);}; |
---|
240 | |
---|
241 | // Hidden all |
---|
242 | var _elementNext = _element.nextSibling; |
---|
243 | |
---|
244 | while( _elementNext ) |
---|
245 | { |
---|
246 | if( _elementNext.nodeType == 1 ) |
---|
247 | _elementNext.style.display = "none"; |
---|
248 | |
---|
249 | _elementNext = _elementNext.nextSibling; |
---|
250 | } |
---|
251 | } |
---|
252 | } |
---|
253 | |
---|
254 | function groupsVisible() |
---|
255 | { |
---|
256 | if( arguments.length > 0 ) |
---|
257 | { |
---|
258 | var _element = arguments[0]; |
---|
259 | _element.style.background = "url('"+path_jabberit+"templates/default/images/arrow_down.gif') no-repeat center left"; |
---|
260 | _element.onclick = function(){ groupsHidden(_element);}; |
---|
261 | |
---|
262 | // Display all |
---|
263 | var _elementNext = _element.nextSibling; |
---|
264 | |
---|
265 | while( _elementNext ) |
---|
266 | { |
---|
267 | if( _elementNext.nodeType == 1 ) |
---|
268 | _elementNext.style.display = "block"; |
---|
269 | |
---|
270 | _elementNext = _elementNext.nextSibling; |
---|
271 | } |
---|
272 | } |
---|
273 | } |
---|
274 | |
---|
275 | function keyPressSearch() |
---|
276 | { |
---|
277 | if( arguments.length > 0 ) |
---|
278 | { |
---|
279 | var ev = arguments[0]; |
---|
280 | var element = arguments[1]; |
---|
281 | |
---|
282 | if ( ev.keyCode == 13 ) |
---|
283 | if( element.value.length >= 3 ) |
---|
284 | searchUser( element.value ); |
---|
285 | else |
---|
286 | alert('Your search argument must be longer than 3 characters.'); |
---|
287 | } |
---|
288 | } |
---|
289 | |
---|
290 | |
---|
291 | function loginPage() |
---|
292 | { |
---|
293 | var winLoginPage = |
---|
294 | { |
---|
295 | id_window : "window_login_page", |
---|
296 | width : 260, |
---|
297 | height : 150, |
---|
298 | top : 100, |
---|
299 | left : 400, |
---|
300 | draggable : true, |
---|
301 | visible : "display", |
---|
302 | resizable : true, |
---|
303 | zindex : zIndex++, |
---|
304 | title : "Login - Expresso Messenger", |
---|
305 | closeAction : "remove", |
---|
306 | content : Xtools.parse(Xtools.xml("login_page"), "loginPage.xsl") |
---|
307 | }; |
---|
308 | |
---|
309 | _winBuild( winLoginPage ); |
---|
310 | } |
---|
311 | |
---|
312 | function loadScripts(pFiles) |
---|
313 | { |
---|
314 | // Load JavaScript |
---|
315 | var loadJavaScript = function(pJs) |
---|
316 | { |
---|
317 | var newScript = document.createElement("script"); |
---|
318 | newScript.setAttribute("type", "text/javascript"); |
---|
319 | newScript.setAttribute("src", pJs ); |
---|
320 | |
---|
321 | return newScript; |
---|
322 | }; |
---|
323 | |
---|
324 | // Load CSS |
---|
325 | var loadStyleSheet = function(pCss) |
---|
326 | { |
---|
327 | var newStyle = document.createElement("link"); |
---|
328 | newStyle.setAttribute("rel", "stylesheet"); |
---|
329 | newStyle.setAttribute("type", "text/css"); |
---|
330 | newStyle.setAttribute("href", pCss); |
---|
331 | |
---|
332 | return newStyle; |
---|
333 | }; |
---|
334 | |
---|
335 | for(var i = 0; i < pFiles.length; i++) |
---|
336 | { |
---|
337 | if( pFiles[i].indexOf(".js") > -1 ) |
---|
338 | document.getElementsByTagName("head")[0].appendChild(loadJavaScript(pFiles[i])); |
---|
339 | |
---|
340 | if( pFiles[i].indexOf(".css") > -1 ) |
---|
341 | document.getElementsByTagName("head")[0].appendChild(loadStyleSheet(pFiles[i])); |
---|
342 | } |
---|
343 | } |
---|
344 | |
---|
345 | function notificationNewMessage() |
---|
346 | { |
---|
347 | var oldTitle = document.title; |
---|
348 | var newTitle = " ## NOVA MENSAGEM ## "; |
---|
349 | var idWindow = arguments[1]; |
---|
350 | |
---|
351 | if( timeoutId == null) |
---|
352 | { |
---|
353 | timeoutId = setInterval(function() |
---|
354 | { |
---|
355 | document.title = document.title == newTitle ? ' ' : newTitle; |
---|
356 | |
---|
357 | }, 1000); |
---|
358 | |
---|
359 | configEvents( window, 'onclick', function() |
---|
360 | { |
---|
361 | clearInterval(timeoutId); |
---|
362 | document.title = oldTitle; |
---|
363 | timeoutId = null; |
---|
364 | }); |
---|
365 | |
---|
366 | configEvents( window, 'onkeypress', function() |
---|
367 | { |
---|
368 | clearInterval(timeoutId); |
---|
369 | document.title = oldTitle; |
---|
370 | timeoutId = null; |
---|
371 | }); |
---|
372 | } |
---|
373 | } |
---|
374 | |
---|
375 | function optionsItensContact() |
---|
376 | { |
---|
377 | if( arguments.length > 0 ) |
---|
378 | { |
---|
379 | var jid = arguments[0]; |
---|
380 | var index = arguments[1]; |
---|
381 | var coord = arguments[2]; |
---|
382 | var element = getElement('itenContact_' + jid + '_' + index ); |
---|
383 | var action = ( element.getAttribute("subscription") === "not-in-roster" ) ? "Adicionar" : "Autorizar"; |
---|
384 | |
---|
385 | if( showhidden == null ) |
---|
386 | showhidden = new ShowHidden(300); |
---|
387 | |
---|
388 | var _options = [ |
---|
389 | [ action , 'loadIM.setAutorization(\''+jid+'\',\''+index+'\')'], |
---|
390 | ['Remover' , 'loadIM.removeContact(\''+jid+'\',\''+index+'\')'], |
---|
391 | ['Renomear' , 'loadIM.renameContact(\''+jid+'\',\''+index+'\')'], |
---|
392 | ['Trocar grupo' , 'loadIM.renameGroup(\''+jid+'\',\''+index+'\')'] |
---|
393 | ]; |
---|
394 | |
---|
395 | var _itens = ""; |
---|
396 | |
---|
397 | for( var i in _options ) |
---|
398 | { |
---|
399 | if( typeof(_options[i]) == "object") |
---|
400 | { |
---|
401 | _itens += '<img src="'+arrow_right.src+'"/>'; |
---|
402 | _itens += '<span style="cursor:pointer;margin:3px;font-weight:normal;" onclick='+_options[i][1]+'>'; |
---|
403 | _itens += _options[i][0] + '</span><br/>'; |
---|
404 | } |
---|
405 | } |
---|
406 | |
---|
407 | var _optionsItens = document.createElement("div"); |
---|
408 | _optionsItens.className = "x-menu"; |
---|
409 | _optionsItens.style.top = coord.Y; |
---|
410 | _optionsItens.style.left = ( coord.X - element.offsetLeft ); |
---|
411 | _optionsItens.style.zIndex = getZindex(); |
---|
412 | _optionsItens.innerHTML = _itens; |
---|
413 | _optionsItens.onclick = function(){ showhidden.hiddenObject(false); }; |
---|
414 | _optionsItens.onmouseout = function(){ showhidden.hiddenObject(false); }; |
---|
415 | _optionsItens.onmouseover = function(){ showhidden.hiddenObject(true); }; |
---|
416 | |
---|
417 | showhidden.action('onmouseover', 'onmouseout', _optionsItens); |
---|
418 | |
---|
419 | window.document.body.appendChild(_optionsItens); |
---|
420 | |
---|
421 | |
---|
422 | setTimeout(function() |
---|
423 | { |
---|
424 | window.document.oncontextmenu = function() |
---|
425 | { |
---|
426 | return true; |
---|
427 | }; |
---|
428 | |
---|
429 | },500); |
---|
430 | } |
---|
431 | } |
---|
432 | |
---|
433 | function parse() |
---|
434 | { |
---|
435 | if( arguments.length == 2 ) |
---|
436 | return Xtools.parse(Xtools.xml(arguments[0]), arguments[1] ); |
---|
437 | |
---|
438 | if( arguments.length === 3 ) |
---|
439 | return Xtools.parse(Xtools.xml(arguments[0]), arguments[1], arguments[2] ); |
---|
440 | } |
---|
441 | |
---|
442 | function removeContact(jid, index) |
---|
443 | { |
---|
444 | setTimeout(function() |
---|
445 | { |
---|
446 | TrophyIM.removeContact(jid, index); |
---|
447 | |
---|
448 | },300); |
---|
449 | } |
---|
450 | |
---|
451 | function removeElement( ) |
---|
452 | { |
---|
453 | if( arguments.length > 0 ) |
---|
454 | { |
---|
455 | var _element = arguments[0] |
---|
456 | var _parent = _element.parentNode; |
---|
457 | |
---|
458 | _parent.removeChild( _element ); |
---|
459 | } |
---|
460 | } |
---|
461 | |
---|
462 | function removeGroup() |
---|
463 | { |
---|
464 | var _parent = arguments[0]; |
---|
465 | |
---|
466 | if( _parent.childNodes.length <= 2 ) |
---|
467 | _parent.parentNode.removeChild(_parent); |
---|
468 | } |
---|
469 | |
---|
470 | function renameContact() |
---|
471 | { |
---|
472 | if( arguments.length > 0 ) |
---|
473 | { |
---|
474 | var _jid = arguments[0]; |
---|
475 | var _index = arguments[1]; |
---|
476 | |
---|
477 | TrophyIM.renameContact( _jid, _index ); |
---|
478 | } |
---|
479 | } |
---|
480 | |
---|
481 | function renameGroup() |
---|
482 | { |
---|
483 | if( arguments.length > 0 ) |
---|
484 | { |
---|
485 | var _jid = arguments[0]; |
---|
486 | var _index = arguments[1]; |
---|
487 | |
---|
488 | TrophyIM.renameGroup( _jid , _index ); |
---|
489 | } |
---|
490 | } |
---|
491 | |
---|
492 | function rosterDiv() |
---|
493 | { |
---|
494 | var paramListContact = |
---|
495 | { |
---|
496 | 'idUser' : Base64.decode(getUserCurrent().jid), |
---|
497 | 'full_name' : (( fullName.length < 25 ) ? fullName : ( fullName.substring( 0, 25) + "...")), |
---|
498 | 'path_jabberit' : path_jabberit, |
---|
499 | 'zIndex_' : zIndex++ |
---|
500 | }; |
---|
501 | |
---|
502 | var winRosterDiv = |
---|
503 | { |
---|
504 | id_window : "window_Roster_im", |
---|
505 | width : 250, |
---|
506 | height : 410, |
---|
507 | top : 50, |
---|
508 | left : 50, |
---|
509 | draggable : true, |
---|
510 | visible : "display", |
---|
511 | resizable : true, |
---|
512 | zindex : zIndex++, |
---|
513 | title : "Contatos - Expresso Messenger", |
---|
514 | closeAction : "hidden", |
---|
515 | content : Xtools.parse(Xtools.xml("contacts_list"),"contactsList.xsl", paramListContact) |
---|
516 | }; |
---|
517 | |
---|
518 | _winBuild( winRosterDiv ); |
---|
519 | |
---|
520 | // Photo User |
---|
521 | getPhotoUser(Base64.decode(getUserCurrent().jid)); |
---|
522 | } |
---|
523 | |
---|
524 | function searchUser() |
---|
525 | { |
---|
526 | var _input = getElement('search_user_jabber'); |
---|
527 | |
---|
528 | if( _input.value.length >= 3 ) |
---|
529 | addUser.search(); |
---|
530 | else |
---|
531 | alert('Your search argument must be longer than 3 characters.'); |
---|
532 | } |
---|
533 | |
---|
534 | function setAutorization(jidTo, indexTo) |
---|
535 | { |
---|
536 | var divItenContact = null; |
---|
537 | |
---|
538 | if( ( divItenContact = getElement('itenContact_' + jidTo + '_' + indexTo ))) |
---|
539 | { |
---|
540 | var subscription = divItenContact.getAttribute('subscription'); |
---|
541 | |
---|
542 | switch(subscription) |
---|
543 | { |
---|
544 | case 'from': |
---|
545 | |
---|
546 | TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid), 'subscribe'); |
---|
547 | break; |
---|
548 | |
---|
549 | case 'none' : |
---|
550 | |
---|
551 | TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid), 'subscribe'); |
---|
552 | TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid), 'subscribed'); |
---|
553 | |
---|
554 | break; |
---|
555 | |
---|
556 | case 'not-in-roster': |
---|
557 | |
---|
558 | setTimeout(function() |
---|
559 | { |
---|
560 | var _add = ""; |
---|
561 | |
---|
562 | if( ( _add = confirm("Deseja adicionar o usuario!")) ) |
---|
563 | { |
---|
564 | addUser.add( jidTo, indexTo ); |
---|
565 | } |
---|
566 | |
---|
567 | },100); |
---|
568 | |
---|
569 | break; |
---|
570 | |
---|
571 | case 'to' : |
---|
572 | |
---|
573 | TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid), 'subscribed'); |
---|
574 | |
---|
575 | case 'subscribe' : |
---|
576 | |
---|
577 | TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid), 'subscribe'); |
---|
578 | |
---|
579 | break; |
---|
580 | } |
---|
581 | } |
---|
582 | } |
---|
583 | |
---|
584 | function setPresence() |
---|
585 | { |
---|
586 | if( arguments.length > 0 ) |
---|
587 | { |
---|
588 | var element = arguments[0]; |
---|
589 | |
---|
590 | if( showhidden == null ) |
---|
591 | showhidden = new ShowHidden(300); |
---|
592 | |
---|
593 | var _status = [ |
---|
594 | ['Afastado', 'away', '<img src="'+path_jabberit+'templates/default/images/away.gif" />'], |
---|
595 | ['Disponível', 'available', '<img src="'+path_jabberit+'templates/default/images/available.gif" />'], |
---|
596 | ['Livre p/ Conversa', 'chat', '<img src="'+path_jabberit+'templates/default/images/chat.gif" />'], |
---|
597 | ['Não Disponível', 'xa', '<img src="'+path_jabberit+'templates/default/images/xa.gif" />'], |
---|
598 | ['Ocupado', 'dnd', '<img src="'+path_jabberit+'templates/default/images/dnd.gif" />'], |
---|
599 | ['Desconectado', 'unavailable', '<img src="'+path_jabberit+'templates/default/images/unavailable.gif" />'], |
---|
600 | ['Mensagem de Status...', 'status', '<img src="'+path_jabberit+'templates/default/images/message_normal.gif" />'], |
---|
601 | ]; |
---|
602 | |
---|
603 | var _itens = ""; |
---|
604 | |
---|
605 | for( var i in _status ) |
---|
606 | { |
---|
607 | if( typeof( _status[i]) == "object" ) |
---|
608 | { |
---|
609 | _itens += '<span style="cursor:pointer;" onclick="TrophyIM.setPresence(\''+_status[i][1]+'\'); loadIM.setStatusJabber(\''+_status[i][0]+'\',\''+_status[i][1]+'\');">'; |
---|
610 | _itens += _status[i][2]+ "<span style='margin:3px;'>" + _status[i][0] + "</span></span><br/>"; |
---|
611 | } |
---|
612 | } |
---|
613 | |
---|
614 | var _statusItens = document.createElement("div"); |
---|
615 | _statusItens.style.marginTop = "65px"; |
---|
616 | _statusItens.style.marginLeft = "67px"; |
---|
617 | _statusItens.className = "x-menu"; |
---|
618 | _statusItens.style.zIndex = '99999'; |
---|
619 | _statusItens.innerHTML = _itens; |
---|
620 | _statusItens.onclick = function(){ showhidden.hiddenObject(false); }; |
---|
621 | |
---|
622 | showhidden.action('onmouseover', 'onmouseout', _statusItens); |
---|
623 | |
---|
624 | element.parentNode.onmouseout = function(){ showhidden.hiddenObject(false); }; |
---|
625 | element.parentNode.onmouseover = function(){ showhidden.hiddenObject(true); }; |
---|
626 | element.parentNode.appendChild(_statusItens); |
---|
627 | } |
---|
628 | } |
---|
629 | |
---|
630 | function setSelectEditable(element) |
---|
631 | { |
---|
632 | if( getElement('selectBox0') == null ) |
---|
633 | selectEditable.create(element); |
---|
634 | } |
---|
635 | |
---|
636 | function setStatusJabber() |
---|
637 | { |
---|
638 | if( arguments.length > 0 ) |
---|
639 | { |
---|
640 | if( arguments[1] != 'status' ) |
---|
641 | { |
---|
642 | var _text = arguments[0]; |
---|
643 | var _img = arguments[1]; |
---|
644 | |
---|
645 | getElement('statusJabberText').innerHTML = _text; |
---|
646 | getElement('statusJabberImg').style.background = "url('"+path_jabberit+"templates/default/images/"+_img+".gif')"; |
---|
647 | getElement('status_jabber_expresso').style.background = "url('"+path_jabberit+"templates/default/images/"+_img+".gif') no-repeat"; |
---|
648 | } |
---|
649 | } |
---|
650 | } |
---|
651 | |
---|
652 | function teste_meu(_jid, _password ) |
---|
653 | { |
---|
654 | userCurrent = |
---|
655 | { |
---|
656 | 'jid' : _jid.substring(11, _jid.length), |
---|
657 | 'password' : _password.substring(11, _password.length) |
---|
658 | } |
---|
659 | } |
---|
660 | |
---|
661 | function setUserCurrent() |
---|
662 | { |
---|
663 | conn.go('p.ff.data_0', |
---|
664 | function(_User) |
---|
665 | { |
---|
666 | var _user = _User; |
---|
667 | |
---|
668 | conn.go('p.ff.data_1', |
---|
669 | function(_pass) |
---|
670 | { |
---|
671 | teste_meu( _user, _pass ); |
---|
672 | }); |
---|
673 | }); |
---|
674 | } |
---|
675 | |
---|
676 | function loadIM() |
---|
677 | { |
---|
678 | if( arguments.length > 0 ) |
---|
679 | { |
---|
680 | var files = [ |
---|
681 | path_jabberit + 'js/connector.js', |
---|
682 | path_jabberit + 'js/xtools.js', |
---|
683 | path_jabberit + 'js/dragdrop.js', |
---|
684 | path_jabberit + 'js/makeW.js', |
---|
685 | path_jabberit + 'js/show_hidden.js', |
---|
686 | path_jabberit + 'js/trophyim.js', |
---|
687 | path_jabberit + 'js/AddUser.js', |
---|
688 | path_jabberit + 'js/SelectEditable.js', |
---|
689 | path_jabberit + 'templates/default/css/button.css', |
---|
690 | path_jabberit + 'templates/default/css/common.css', |
---|
691 | path_jabberit + 'templates/default/css/selectEditableStyle.css', |
---|
692 | path_jabberit + 'templates/default/css/' + theme_jabberit |
---|
693 | ]; |
---|
694 | // FullName |
---|
695 | fullName = arguments[0]; |
---|
696 | |
---|
697 | loadScripts(files); |
---|
698 | |
---|
699 | setTimeout(function() |
---|
700 | { |
---|
701 | // Object Xtools |
---|
702 | if( Xtools == null ) |
---|
703 | Xtools = new xtools(path_jabberit); |
---|
704 | |
---|
705 | // Object Conector |
---|
706 | if( conn == null ) |
---|
707 | conn = new AjaxConnector(path_jabberit); |
---|
708 | |
---|
709 | // Object Add User |
---|
710 | if( addUser == null ) |
---|
711 | addUser = new addUserIM(Xtools, conn); |
---|
712 | |
---|
713 | |
---|
714 | // Object SelectEditable |
---|
715 | if( selectEditable == null ) |
---|
716 | selectEditable = new SelectEditable(); |
---|
717 | |
---|
718 | // Add Jabber in StatusBar; |
---|
719 | addIcon(); |
---|
720 | |
---|
721 | }, 1000); |
---|
722 | } |
---|
723 | } |
---|
724 | |
---|
725 | loadIM.prototype.addIcon = addIcon; |
---|
726 | loadIM.prototype.actionButton = actionButton; |
---|
727 | loadIM.prototype.addContact = addContact; |
---|
728 | loadIM.prototype.clrAllContacts = clrAllContacts; |
---|
729 | loadIM.prototype.configEvents = configEvents; |
---|
730 | loadIM.prototype.getPhotoUser = getPhotoUser; |
---|
731 | loadIM.prototype.getUserCurrent = getUserCurrent; |
---|
732 | loadIM.prototype.getZIndex = getZindex; |
---|
733 | loadIM.prototype.groupsHidden = groupsHidden; |
---|
734 | loadIM.prototype.groupsVisible = groupsVisible; |
---|
735 | loadIM.prototype.keyPressSearch = keyPressSearch; |
---|
736 | loadIM.prototype.loginPage = loginPage; |
---|
737 | loadIM.prototype.notification = notificationNewMessage; |
---|
738 | loadIM.prototype.parse = parse; |
---|
739 | loadIM.prototype.searchUser = searchUser |
---|
740 | loadIM.prototype.setAutorization = setAutorization; |
---|
741 | loadIM.prototype.setPresence = setPresence; |
---|
742 | loadIM.prototype.setStatusJabber = setStatusJabber; |
---|
743 | loadIM.prototype.setSelectEditable = setSelectEditable; |
---|
744 | loadIM.prototype.setUserCurrent = setUserCurrent; |
---|
745 | loadIM.prototype.removeContact = removeContact; |
---|
746 | loadIM.prototype.removeElement = removeElement; |
---|
747 | loadIM.prototype.removeGroup = removeGroup; |
---|
748 | loadIM.prototype.renameContact = renameContact; |
---|
749 | loadIM.prototype.renameGroup = renameGroup; |
---|
750 | loadIM.prototype.rosterDiv = rosterDiv; |
---|
751 | |
---|
752 | window.LoadIM = loadIM; |
---|
753 | |
---|
754 | })(); |
---|