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