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