source: branches/2.2/jabberit_messenger/jmessenger/js/jscode/loadIM.js @ 3680

Revision 3680, 45.3 KB checked in by alexandrecorreia, 13 years ago (diff)

Ticket #1091 - Bloqueio das salas de bate-papo por OU dentro do modulo IM

  • Property svn:executable set to *
Line 
1(function()
2{
3        var _autoStatus;
4        var _autoStatusTime             = 60000; // 1 minuto
5        var addUser                                     = null;
6        var conn                                        = null;
7        var fullName                            = "";
8        var path                                        = "";
9        var _preferencesIM                      = "";
10        var selectEditable                      = null;
11        var showhidden                          = null;
12        var statusUserIM                        = "";
13        var _statusMessage                      = "";
14        var timeoutId                           = null;
15        var userCurrent                         = null;
16        var _timeOutNotification        = "";
17        var Xtools                                      = null;
18        var zIndex                                      = 9001;
19        var windowPopUp                         = [];
20       
21        // Images
22        var add_user = new Image();
23        add_user.src = path_jabberit + 'templates/default/images/adduser_azul.png';
24
25        var arrow_down = new Image();
26        arrow_down.src = path_jabberit + 'templates/default/images/arrow_down.gif';
27
28        var arrow_right = new Image();
29        arrow_right.src = path_jabberit + 'templates/default/images/arrow_right.gif';
30       
31        function actionButton()
32        {
33                if( arguments.length > 0 )
34                {
35                        var e                   = arguments[0];
36                        var _element    = ( e.target ) ? e.target : e.srcElement;
37                        var jid         = arguments[1];
38                        var coord       = null;
39
40                        if ( !e )
41                                e = window.event;
42
43                        var _X = e.clientX + document.body.scrollLeft - document.body.clientLeft;
44                        var _Y = e.clientY + document.body.scrollTop  - document.body.clientTop;
45                               
46                        coord = { X : _X, Y : _Y };
47               
48
49                        var _onContextMenu = function()
50                        {
51                                return false;
52                        };
53                       
54                        window.document.oncontextmenu   = _onContextMenu;
55                       
56                        if( e.button )
57                        {
58                                if( e.button > 1 )
59                                        optionsItensContact( jid, coord );
60                                else
61                                        TrophyIM.rosterClick(jid);
62                        }       
63                        else if( e.which )
64                        {
65                                if( e.which > 1 )
66                                        optionsItensContact( jid, coord );
67                                else
68                                        if( e.target.id )
69                                                TrophyIM.rosterClick(jid);
70                        }
71                       
72                        setTimeout(function()
73                        {
74                                window.document.oncontextmenu = function()
75                                {
76                                        return true;
77                                };
78                               
79                        },500);
80                }
81        }
82
83        function addContact()
84        {
85                if( arguments.length > 0 )
86                        addUser.add();
87                else
88                        addUser.show();
89        }
90       
91        function addIcon()
92        {
93               
94                var div_write_msg       = ( getElement('em_div_write_msg') != null ) ? getElement('em_div_write_msg') : null ;
95                var StatusBar           = ( getElement('divStatusBar') != null ) ? getElement('divStatusBar') : null ;
96                var StatusBarIM         = ( getElement('JabberMessenger') != null ) ?  getElement('JabberMessenger') : null;
97               
98                /**************************************************************************
99                 *
100                 * Quando estiver habilitada a opção fora de escritório nos filtros.
101                 * 
102                 */
103
104                if( ( div_write_msg && StatusBarIM ) != null )
105                {               
106                        div_write_msg.parentNode.insertBefore(StatusBarIM, div_write_msg);
107                        StatusBarIM.style.paddingLeft = '33px';
108                        return;
109                }
110               
111                /**************************************************************************/
112               
113                if ( !StatusBarIM )
114                {
115                        StatusBarIM = document.createElement('div');
116                        StatusBarIM.setAttribute('id', 'JabberMessenger');
117                }
118               
119                if( StatusBar )
120                {
121                        StatusBar.style.paddingLeft = '33px';
122                       
123                        var _div = document.createElement('div');
124                                _div.appendChild(StatusBar.parentNode.removeChild(StatusBar.previousSibling));
125                       
126                                StatusBar.parentNode.insertBefore( _div, StatusBar);
127                       
128                        var _fastMenu = top.document.createElement('div');
129                                _fastMenu.setAttribute('id', 'fast_menu_jabber_expresso');
130                                _fastMenu.style.background              = 'no-repeat';
131                                _fastMenu.style.backgroundImage = 'url(' + arrow_down.src + ')';
132                                _fastMenu.style.float                   = 'left';
133                                _fastMenu.style.height                  = '15px';
134                                _fastMenu.style.left                    = '7px';
135                                _fastMenu.style.margin                  = '8 0 0 10px';
136                                _fastMenu.style.padding                 = '0px';
137                                _fastMenu.style.position                = 'absolute';
138                                _fastMenu.style.width                   = '15px';
139                                _fastMenu.style.cursor                  = 'pointer';
140
141                        StatusBarIM.insertBefore( _fastMenu, StatusBarIM.firstChild );
142                       
143                        // Add event onclick element _fastMenu
144                        configEvents( _fastMenu, 'onclick', function(){ fastMenu(_fastMenu); });
145
146                        var _statusJabber = top.document.createElement('div');
147                                _statusJabber.setAttribute('id','status_jabber_expresso');
148                                _statusJabber.style.background          = 'no-repeat';
149                                _statusJabber.style.backgroundImage = 'url(' + add_user.src +')';
150                                _statusJabber.style.float                       = 'left';
151                                _statusJabber.style.height                      = '18px';
152                                _statusJabber.style.left                        = '19px';
153                                _statusJabber.style.margin                      = '0 0 0 10px';
154                                _statusJabber.style.padding                     = '0px';
155                                _statusJabber.style.position            = 'absolute';
156                                _statusJabber.style.width                       = '18px';
157                                _statusJabber.style.cursor                      = 'pointer';
158                                _statusJabber.style.zindex                      = '999999';
159                       
160                        StatusBarIM.insertBefore( _statusJabber, StatusBarIM.firstChild );
161                       
162                        StatusBar.insertBefore( StatusBarIM, StatusBar.firstChild );
163
164                        // Add event onclick element _statusJabber
165                        if( _preferencesIM[0] == "openWindowJabberit:true" )
166                        {
167                                configEvents( _statusJabber, 'onclick', function(){ rosterDiv(); });
168                        }
169                        else
170                        {
171                                configEvents( _statusJabber, 'onclick', function(){ TrophyIM.load(); });
172                        }
173                }
174        }
175
176        function addNewUser()
177        {
178                addUser.newUser();
179        }
180       
181        function autoStatus()
182        {
183                var _div_status = ( getElement('status_jabber_expresso') != null ) ?  getElement('status_jabber_expresso') : null;
184               
185                if ( _autoStatus )
186                        clearTimeout(_autoStatus);
187
188                if ( _div_status != null )
189                {
190                        var _status = _div_status.style.backgroundImage;
191                                _status = _status.substr(_status.lastIndexOf('/') + 1);
192                                _status = _status.substr(0, _status.indexOf('.'));
193                               
194                        if( _status == "xa" && _div_status.getAttribute('autoStatus') )
195                        {
196                                if( getStatusMessage() != "")
197                                        TrophyIM.setPresence("available", getStatusMessage());
198                                else
199                                        TrophyIM.setPresence("available");
200                               
201                                _div_status.removeAttribute('autoStatus');
202                                loadscript.setStatusJabber("Disponível","available");
203                        }
204                }
205               
206                var TimeStatus = _preferencesIM[2].split(':');
207
208                if( TimeStatus[1] )
209                        _autoStatus = setTimeout( function(){ autoStatusHandler();}, parseInt(TimeStatus[1]) * _autoStatusTime );
210                else
211                        _autoStatus = setTimeout( function(){ autoStatusHandler();}, parseInt(_autoStatusTime));
212        }
213       
214        function autoStatusHandler()
215        {
216                var _div_status = ( getElement('status_jabber_expresso') != null ) ?  getElement('status_jabber_expresso') : null;
217               
218                if ( _div_status != null )
219                {
220                        var _status = _div_status.style.backgroundImage;
221                                _status = _status.substr(_status.lastIndexOf('/') + 1);
222                                _status = _status.substr(0, _status.indexOf('.'));
223                       
224                        if( _status == "available" )
225                        {
226                                if(getStatusMessage() != "")
227                                        TrophyIM.setPresence("xa", getStatusMessage());
228                                else
229                                        TrophyIM.setPresence("xa");
230
231                                _div_status.setAttribute('autoStatus','true');
232                               
233                                loadscript.setStatusJabber("Não Disponível","xa");
234                        }
235                }
236        }
237
238        function clrAllContacts()
239        {
240                getElement("JabberIMRoster").innerHTML = "";
241        }
242       
243        function configEvents(pObj, pEvent, pHandler)
244        {
245                if ( typeof pObj == 'object' )
246                {
247                        if ( pEvent.substring(0, 2) == 'on' )
248                                pEvent = pEvent.substring(2, pEvent.length );
249
250                        if ( arguments.length == 3 )
251                        {
252                                if ( pObj.addEventListener )
253                                        pObj.addEventListener(pEvent, pHandler, false );
254                                else if ( pObj.attachEvent )
255                                        pObj.attachEvent( 'on' + pEvent, pHandler );
256                        }
257                        else if ( arguments.length == 4 )
258                        {
259                                if ( pObj.removeEventListener )
260                                        pObj.removeEventListener( pEvent, pHandler, false );
261                                else if ( pObj.detachEvent )
262                                        pObj.detachEvent( 'on' + pEvent, pHandler );
263                        }
264                }
265        }
266
267        function disabledNotificationNewUsers()
268        {
269                var _notification       = getElement('notification_new_users_jabber') ;
270                var _statusJabber       = getElement('status_jabber_expresso');
271
272                _notification.style.display = 'none';
273               
274                _statusJabber.style.background = "url('"+path_jabberit+"templates/default/images/" + statusUserIM + ".gif') no-repeat";
275               
276                if( _timeOutNotification )
277                        clearTimeout(_timeOutNotification );
278               
279                TrophyIM.controll.notificationNewUsers = 0;
280        }
281       
282        function enabledNotificationNewUsers()
283        {
284                var _notification       = getElement('notification_new_users_jabber') ;
285                var _statusJabber       = getElement('status_jabber_expresso');
286       
287                if( _notification && _statusJabber )
288                {       
289                        if ( _notification.style.display == 'none' )
290                        {
291                                _notification.style.display = 'block';
292                               
293                                _statusJabber.style.background = "url('"+path_jabberit+"templates/default/images/alert_mini.png') no-repeat";
294                               
295                                if( _timeOutNotification )
296                                        clearTimeout(_timeOutNotification );
297
298                                _timeOutNotification = setTimeout( function(){ enabledNotificationNewUsers(); }, 2000 );
299                        }
300                        else
301                        {
302                                _notification.style.display = 'none';
303                               
304                                _statusJabber.style.background = "url('"+path_jabberit+"templates/default/images/" + statusUserIM + ".gif') no-repeat";
305                               
306                                if( _timeOutNotification )
307                                        clearTimeout(_timeOutNotification );
308
309                                _timeOutNotification = setTimeout( function(){ enabledNotificationNewUsers(); }, 800 );
310                        }
311                }
312        }
313
314        function fastMenu()
315        {
316                if( arguments.length > 0 )
317                {
318                        var element = arguments[0];
319
320                        if( showhidden == null )
321                                showhidden = new ShowHidden(300);
322
323                        var _options =  [
324                                                ['Adicionar Contato', 'loadscript.addContact();' ],
325                                                ['Preferências', 'loadscript.preferences();']
326                                        ];
327
328                        if( im_chatroom == "false" )   
329                        {       
330                                _options[2] = [ 'Sala(s) de Bate-Papo','loadscript.getListRooms();'];
331                        }
332
333                        var _itens = "";
334                       
335                        for( var i in _options )
336                        {
337                                if( _options[i].constructor == Function )
338                                        continue;
339                               
340                                _itens += '<img src="'+arrow_right.src+'"/>';
341                                _itens += '<span style="cursor:pointer; margin:3px;" onclick='+_options[i][1]+'>';
342                                _itens += _options[i][0] + '</span><br/>';
343                        }
344                       
345                        var _optionsItens = document.createElement("div");
346                                _optionsItens.id        = "fastMenu_Jabber";                           
347                                _optionsItens.style.marginTop   = "19px";
348                                _optionsItens.style.marginLeft  = "-8px";
349                                _optionsItens.className         = "x-menu";
350                                _optionsItens.style.zIndex      = '999999';
351                                _optionsItens.innerHTML         = _itens;
352                                _optionsItens.onclick           = function(){ showhidden.hiddenObject(false); };
353                                _optionsItens.onmouseout        = function(){ showhidden.hiddenObject(false); };
354                                _optionsItens.onmouseover       = function(){ showhidden.hiddenObject(true); };
355                                                                                 
356                                showhidden.action('onmouseover', 'onmouseout', _optionsItens);
357                               
358                        element.parentNode.appendChild( _optionsItens );
359                }
360        }
361       
362        function getElement( elementId )
363        {
364                return document.getElementById( elementId );
365        }
366       
367        function getIsIE()
368        {
369                return SnifferBrowser.isCompatible('is_ie');
370        }
371       
372        function getPhotoUser( jid )
373        {
374                try
375                {
376                        var _divPhoto = getElement( jid + '__photo' );
377       
378                        if( _divPhoto.style.backgroundImage.indexOf('photo.png') > 0 )
379                        {
380                                var _imgUser  = path_jabberit + 'inc/WebService.php?' + Date.parse( new Date );
381                                        _imgUser += '&photo_ldap=' + jid;
382       
383                                _divPhoto.style.backgroundImage = 'url(' + _imgUser + ')';
384                        }
385                }catch(e){}
386        }
387       
388        function getShowContactsOffline()
389        {
390                if( _preferencesIM[3] )
391                {
392                        var showOffline = _preferencesIM[3].split(":");
393                       
394                        if( showOffline[1] === "true")
395                                return true;
396                        else
397                                return false;
398                }
399               
400                return true;
401        }
402       
403        function getSmiles( String )
404        {
405                String = String.replace( /:\)|:-\)/g    , " <img src='"+path_jabberit+"templates/default/images/smiles/1.gif'/> ");
406                String = String.replace( /:-D/g                 , " <img src='"+path_jabberit+"templates/default/images/smiles/2.gif'/> ");
407                String = String.replace( /;-\)/g                , " <img src='"+path_jabberit+"templates/default/images/smiles/3.gif'/> ");
408                String = String.replace( /=-O/g                 , " <img src='"+path_jabberit+"templates/default/images/smiles/4.gif'/> ");
409                String = String.replace( /:P/g                  , " <img src='"+path_jabberit+"templates/default/images/smiles/5.gif'/> ");
410                String = String.replace( /8-\)/g                , " <img src='"+path_jabberit+"templates/default/images/smiles/6.gif'/> ");
411                String = String.replace( /\>:o/g                , " <img src='"+path_jabberit+"templates/default/images/smiles/7.gif'/> ");
412                String = String.replace( /:-\$/g                , " <img src='"+path_jabberit+"templates/default/images/smiles/8.gif'/> ");
413                String = String.replace( /:s|:-X/g              , " <img src='"+path_jabberit+"templates/default/images/smiles/9.gif'/> ");
414                String = String.replace( /:-\(/g                , " <img src='"+path_jabberit+"templates/default/images/smiles/10.gif'/> ");
415                String = String.replace( /:\'\(/g               , " <img src='"+path_jabberit+"templates/default/images/smiles/11.gif'/> ");
416                String = String.replace( /:\|/g                 , " <img src='"+path_jabberit+"templates/default/images/smiles/12.gif'/> ");
417                String = String.replace( /O:-\)/g               , " <img src='"+path_jabberit+"templates/default/images/smiles/13.gif'/> ");
418                String = String.replace( /\*\*@#%/g             , " <img src='"+path_jabberit+"templates/default/images/smiles/14.gif'/> ");
419                String = String.replace( /\(I\)/g               , " <img src='"+path_jabberit+"templates/default/images/smiles/15.gif'/> ");
420                String = String.replace( /C28I/g                , " <img src='"+path_jabberit+"templates/default/images/smiles/16.gif'/> ");
421                String = String.replace( /CS2A/g                , " <img src='"+path_jabberit+"templates/default/images/smiles/17.gif' style='width:42px;height:36px;'/> ");
422 
423                return String;
424        }
425       
426        function getStatusUserIM()
427        {
428                return statusUserIM;
429        }
430       
431        function getStatusMessage()
432        {
433                return _statusMessage;
434        }
435       
436        function getUserCurrent()
437        {
438                return userCurrent;
439        }
440       
441        function getZindex()
442        {
443                return zIndex++;
444        }
445       
446        function groupsHidden()
447        {
448                if( arguments.length > 0 )
449                {
450                        var _element = arguments[0];
451                                _element.style.background = "url('"+path_jabberit+"templates/default/images/arrow_right.gif') no-repeat center left";
452                                _element.onclick = function(){ groupsVisible(_element);};
453                               
454                                // Hidden all
455                                var _elementNext = _element.nextSibling;
456                               
457                                while( _elementNext )
458                                {       
459                                        if( _elementNext.nodeType == 1 )
460                                                _elementNext.style.display = "none";
461                                       
462                                        _elementNext = _elementNext.nextSibling;
463                                }
464                }
465        }
466       
467        function groupsVisible()
468        {
469                if( arguments.length > 0 )
470                {
471                        var _element = arguments[0];
472                                _element.style.background = "url('"+path_jabberit+"templates/default/images/arrow_down.gif') no-repeat center left";
473                                _element.onclick = function(){ groupsHidden(_element);};
474
475                                // Display all
476                                var _elementNext = _element.nextSibling;
477                               
478                                while( _elementNext )
479                                {       
480                                        if( _elementNext.nodeType == 1 && _elementNext.nodeName.toLowerCase() == "div" )
481                                        {
482                                                var is_off = _elementNext.style.backgroundImage.indexOf("unavailable");
483
484                                                if( is_off > 0 && !getShowContactsOffline())
485                                                {
486                                                        _elementNext.style.display = "none";
487                                                        getElement("span_show_" + _elementNext.id ).style.display = "none";
488                                                       
489                                                }
490                                                else
491                                                {
492                                                        _elementNext.style.display = "block";
493                                                        getElement("span_show_" + _elementNext.id ).style.display = "block";
494                                                }
495                                        }
496
497                                        _elementNext = _elementNext.nextSibling;
498                                }
499                }
500        }
501       
502        function keyPressSearch()
503        {
504                if( arguments.length > 0 )
505                {
506                        var ev          = arguments[0];
507                        var element     = arguments[1];
508       
509                        if ( ev.keyCode == 13 )
510                                if( element.value.length >= 3 )
511                                        searchUser( element.value );   
512                                else
513                                        alert( i18n.YOUR_SEARCH_ARGUMENT_MUST_BE_LONGER_THAN_3_CHARACTERS + '.' );
514                }
515        }
516
517       
518        function loginPage()
519        {
520                var paramsLoginPage =
521                {
522                        'username' : ((( Base64.decode(getUserCurrent().jid) )) ? Base64.decode(getUserCurrent().jid) : ""),
523                        'password' : ((( Base64.decode(getUserCurrent().password) )) ? Base64.decode(getUserCurrent().password) : "")
524                }
525               
526                var winLoginPage =
527                {       
528                         id_window              : "window_login_page",
529                         width                  : 260,
530                         height                 : 120,
531                         top                    : 100,
532                         left                   : 400,
533                         draggable              : true,
534                         visible                : "display",
535                         resizable              : true,
536                         zindex                 : zIndex++,
537                         title                  : "Expresso Messenger - Login",
538                         closeAction    : "remove",
539                         content                : Xtools.parse(Xtools.xml("login_page"), "loginPage.xsl", paramsLoginPage)     
540                };
541
542                _winBuild( winLoginPage );
543        }
544
545        function loadScripts(pFiles)
546        {
547                // Load JavaScript
548                var loadJavaScript = function(pJs)
549                {
550                        var newScript = document.createElement("script");
551                                newScript.setAttribute("type", "text/javascript");
552                                newScript.setAttribute("src", pJs );
553                               
554                        return newScript;
555                };
556               
557                // Load CSS
558                var loadStyleSheet = function(pCss)
559                {
560                        var newStyle = document.createElement("link");
561                                newStyle.setAttribute("rel", "stylesheet");
562                                newStyle.setAttribute("type", "text/css");
563                                newStyle.setAttribute("href", pCss);
564                               
565                        return newStyle;
566                };
567               
568                for(var i = 0; i < pFiles.length; i++)
569                {
570                        if( pFiles[i].indexOf(".js") > -1 )
571                                document.getElementsByTagName("head")[0].appendChild(loadJavaScript(pFiles[i]));
572                               
573                        if( pFiles[i].indexOf(".css") > -1 )
574                                document.getElementsByTagName("head")[0].appendChild(loadStyleSheet(pFiles[i]));
575                }
576        }
577       
578        function notificationNewMessage()
579        {
580                var _doc                = document;
581                var _id                 = arguments[0];
582                var _win_name   = _id.replace( /\W/g, '' );
583               
584                if ( windowPOPUP( _id ) )
585                {
586                        _doc = windowPopUp[_win_name].document;
587                }
588               
589                var oldTitle    = _doc.title;
590                var newTitle    = "## NOVA MENSAGEM ##";
591
592                if( timeoutId == null )
593                {
594                        timeoutId = setInterval(function()
595                        {
596                                _doc.title = ( _doc.title == newTitle ) ? oldTitle : newTitle;
597                        }, 1000);
598                       
599                        configEvents( _doc, 'onclick', function()
600                        {
601                                clearInterval(timeoutId);
602                                _doc.title      = oldTitle;
603                                timeoutId               = null;
604                        });
605                       
606                        configEvents( _doc, 'onkeypress', function()
607                        {
608                                clearInterval(timeoutId);
609                                _doc.title      = oldTitle;
610                                timeoutId               = null;
611                        });
612                }
613        }
614
615        function optionsItensContact()
616        {
617                if( arguments.length > 0 )
618                {
619                        var jid         = arguments[0];
620                        var coord       = arguments[1];
621                        var element = getElement('itenContact_' + jid );
622                        var action      = ( element.getAttribute("subscription") === "not-in-roster" ) ? "Adicionar" : "Autorizar";     
623                       
624                        if( showhidden == null )
625                                showhidden = new ShowHidden(300);
626
627                        var _options = [
628                                                [ action , 'loadscript.setAutorization(\''+jid+'\')'],
629                                                ['Remover' , 'loadscript.removeContact(\''+jid+'\')'],
630                                                ['Renomear' , 'loadscript.renameContact(\''+jid+'\')'],
631                                                ['Trocar grupo' , 'loadscript.renameGroup(\''+jid+'\')']
632                                                   ];
633
634                        var _itens = "";
635                       
636                        for( var i in _options )
637                        {
638                                if( typeof(_options[i]) == "object")
639                                {
640                                        _itens += '<img src="'+arrow_right.src+'"/>';
641                                        _itens += '<span style="cursor:pointer;margin:3px;font-weight:normal;" onclick='+_options[i][1]+'>';
642                                        _itens += _options[i][0] + '</span><br/>';
643                                }
644                        }
645                       
646                        var _optionsItens = document.createElement("div");
647                                _optionsItens.className         = "x-menu";
648                                _optionsItens.style.top         = coord.Y;
649                                _optionsItens.style.left        = ( coord.X - element.offsetLeft );
650                                _optionsItens.style.zIndex      = getZindex();
651                                _optionsItens.innerHTML         = _itens; 
652                                _optionsItens.onclick           = function(){ showhidden.hiddenObject(false); };
653                                _optionsItens.onmouseout        = function(){ showhidden.hiddenObject(false); };       
654                                _optionsItens.onmouseover       = function(){ showhidden.hiddenObject(true); };
655                               
656                                showhidden.action('onmouseover', 'onmouseout', _optionsItens);
657                               
658                        window.document.body.appendChild(_optionsItens);
659                }
660        }
661
662        function parse()
663        {
664                if( arguments.length == 2 )
665                        return Xtools.parse(Xtools.xml(arguments[0]), arguments[1] );
666               
667                if( arguments.length === 3 )
668                        return Xtools.parse(Xtools.xml(arguments[0]), arguments[1], arguments[2] );
669        }
670       
671        function preferences()
672        {
673                var paramPreferences =
674                {
675                        'path'  : path,
676                        'lang1' : 'Suas Preferências',
677                        'lang2' : 'Conexão',   
678                        'lang3' : 'Conectar Automaticamente o IM',
679                        'lang4' : 'Usuários OffLine',
680                        'lang5' : 'Exibir amigos Offline',
681                        'lang6' : 'Salvar',
682                        'lang7' : 'Cancelar',
683                        'lang8' : 'Janela de Contatos',
684                        'lang9' : 'Abrir janela como Pop-up',
685                        'lang10' : 'Ausente',
686                        'lang11' : 'Definir status de ausente depois de',
687                        'lang12' : 'minutos',   
688                        'lang13' : 'Mostrar Contatos', 
689                        'lang14' : 'Mostrar contatos desconectados',
690                        'langYes': 'Sim',
691                        'langNo' : 'Não'                                                                                           
692                };
693               
694               
695                var _win_preferences =
696                {
697                                id_window        : "jabberit_preferences",
698                                width            : 430,
699                                height           : 350,
700                                top                      : 150,
701                                left             : 100,
702                                draggable        : true,
703                                visible          : "display",
704                                resizable        : true,
705                                zindex           : zIndex++,
706                                title            : 'Expresso Messenger - Preferências',
707                                closeAction  : "remove",
708                                content          : Xtools.parse(Xtools.xml('preferences'), 'preferences.xsl', paramPreferences)
709                };
710
711                _winBuild(_win_preferences);
712               
713               
714                var _pButtons = {
715                                'lang1' : 'Salvar',
716                                'lang2' : 'Fechar',
717                                'onclickClose' : '_winBuild("jabberit_preferences","remove");',
718                                'onclickSubmit' : 'javascript:loadscript.setPreferences();'
719                };
720               
721                document.getElementById('buttons_preferences_jabberit').innerHTML = Xtools.parse(Xtools.xml('buttons_main'), 'buttons.xsl', _pButtons);
722               
723                // Element openWindowJabberit
724                var value1                      = _preferencesIM[0].split(':');
725                var element1            = document.getElementById(value1[0]);
726                var valueSelect1        = value1[1];
727               
728                for(var i = 0; i < element1.options.length; i++)
729                        if( element1.options[i].value == valueSelect1 )
730                                element1.options[i].selected = true;
731
732                // Element openWindowJabberitPopUp
733                var value2                      = _preferencesIM[1].split(':');
734                       
735                // Element flagAwayIM
736                var value3              = _preferencesIM[2].split(':');
737                var element3    = document.getElementById(value3[0]);
738                element3.value  = value3[1];
739               
740                // Element showContactsOfflineJabberit
741                var value4                      = _preferencesIM[3].split(':');
742                var element4            = document.getElementById(value4[0]);
743                var valueSelect4        = value4[1];
744                for(var i = 0; i < element4.options.length; i++)
745                        if( element4.options[i].value == valueSelect4 )
746                                element4.options[i].selected = true;
747        }
748       
749        function removeContact( jid )
750        {
751                TrophyIM.removeContact( jid );
752        }
753       
754        function removeElement( )
755        {
756                if( arguments.length > 0 )
757                {
758                        var _element = arguments[0]
759                       
760                        if( _element != null )
761                        {
762                                _element.parentNode.removeChild( _element );
763                        }
764                }
765        }
766       
767        function removeGroup()
768        {
769                var _parent = arguments[0];
770               
771                if( _parent.childNodes.length <= 2 )
772                        _parent.parentNode.removeChild(_parent);
773        }
774       
775        function renameContact()
776        {
777                if( arguments.length > 0 )
778                {
779                        var _jid        = arguments[0];
780                       
781                        TrophyIM.renameContact( _jid );
782                }
783        }
784       
785        function renameGroup()
786        {
787                if( arguments.length > 0 )
788                {
789                        var _jid        = arguments[0];
790                       
791                        TrophyIM.renameGroup( _jid );
792                }
793        }
794       
795        function rosterDiv()
796        {
797                var _rosterDiv = function()
798                {
799
800                        var winRosterDiv =
801                        {
802                                 id_window              : "window_Roster_im",
803                                 width                  : 250,
804                                 height                 : 410,
805                                 top                    : 50,
806                                 left                   : -1500,
807                                 leftOld                : 50,
808                                 draggable              : true,
809                                 visible                : "display",
810                                 resizable              : true,
811                                 zindex                 : zIndex++,
812                                 title                  : "Expresso Messenger - Contatos",
813                                 closeAction    : "hidden",
814                                 content                : ""   
815                        };
816
817                        if( _preferencesIM[0] == "openWindowJabberit:false" )
818                        {
819                                winRosterDiv.left               = 50;
820                                winRosterDiv.leftOld    = -1500;
821                        }
822                       
823                        if( SnifferBrowser.isCompatible('ie8','firefox3','epiphany2','iceweasel3') )
824                        {       
825                                var _idUser     = Base64.decode(getUserCurrent().jid);
826                               
827                                var paramListContact =
828                                {
829                                        'idUser'                : _idUser,
830                                        'full_name'             : (( fullName.length < 25 ) ? fullName : ( fullName.substring( 0, 25) + "...")),
831                                        'path_jabberit' : path_jabberit,
832                                        'help_expresso' : help_expresso,
833                                        'zIndex_'               : zIndex++
834                                };
835               
836                                winRosterDiv.content = Xtools.parse(Xtools.xml("contacts_list"),"contactsList.xsl", paramListContact)   
837                               
838                        }
839                        else
840                        {
841                                var paramList =
842                                {
843                                        'path_jabberit' : path_jabberit
844                                };
845                               
846                                winRosterDiv.width              = 280;
847                                winRosterDiv.height             = 430;
848                                winRosterDiv.content    = Xtools.parse(Xtools.xml("navigator"),"navigatorCompatible.xsl", paramList);
849                        }
850                       
851                        _winBuild( winRosterDiv );                             
852
853                        // Photo User
854                        getPhotoUser(_idUser);
855                }
856               
857                setTimeout( function(){ _rosterDiv(); }, 200 );
858        }
859
860        function searchUser()
861        {
862                var _input      = getElement('search_user_jabber');
863               
864                if( _input.value.length >= 3 )
865                        addUser.search();
866                else
867                        alert( i18n.YOUR_SEARCH_ARGUMENT_MUST_BE_LONGER_THAN_3_CHARACTERS + '.' );
868        }
869       
870        function setAutorization()
871        {
872                var divItenContact = null;
873               
874                if( arguments.length > 0 )
875                {
876                        var jidTo = arguments[0];
877               
878                        if( getElement('itenContact_' + jidTo) )
879                                divItenContact = getElement('itenContact_' + jidTo );
880                }
881               
882        if( divItenContact )
883        {       
884                var subscription = divItenContact.getAttribute('subscription');
885
886                switch(subscription)
887                {
888                                case 'from':
889                                       
890                                        TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid ), 'subscribe');
891                                break;
892
893                                case 'subscribe' :
894                                       
895                                        TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid ), 'subscribed');
896                                break;
897                               
898                                case 'none' :                                   
899                               
900                                TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid ), 'subscribe');
901                                break;
902                               
903                        case 'to' :                             
904                               
905                                TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid ), 'subscribed');                             
906                                removeElement( getElement('itenContactNotification_' + jidTo ) );                               
907                                break;
908
909                        case 'not-in-roster':
910                                       
911                                TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid), 'subscribed');
912                                addUser.add( jidTo );
913                                        break;
914                }
915        }
916        }
917       
918        function setMessageStatus()
919        {
920                if( arguments.length > 0 )
921                {
922                        var _element = arguments[0];
923                        var _parent      = _element.parentNode;                 
924
925                        if( _element.nodeName.toLowerCase() == "label")
926                        {
927                                var _input                              = document.createElement("input");
928                                        _input.size                     = "35";
929                                        _input.maxlength        = "35";
930                                        _input.style.border = "0";
931                                        _input.value            = _element.innerHTML;
932                                       
933                                // OnkeyUp
934                                configEvents( _input, "onkeyup", function(e)
935                                                {
936                                                        if( e.keyCode == 13 ) loadscript.setMessageStatus(_input, _element);
937                                                }
938                                );
939                               
940                                // Onblur       
941                            configEvents(_input, "onblur", function(){ loadscript.setMessageStatus(_input, _element)});         
942
943                           
944                                if( _parent != null )
945                                {       
946                                        // Remove label
947                                        if( _element != null )
948                                                _parent.removeChild( _element );
949                                               
950                                        // Add Input
951                                        if( _input != null )
952                                                _parent.appendChild( _input );
953                                }
954
955                                _input.focus();
956                                _input.select();
957                        }
958                        else
959                        {
960                                var _label              = arguments[1];
961                                _statusMessage  = _element.value.replace(/^\(+|\)+$/g,"");
962                               
963                                if( ( _statusMessage = _statusMessage.replace(/^\s+|\s+$|^\n|\n$/g,"") ) != "")
964                                        _label.innerHTML = "( " + _statusMessage + " )";
965                                else
966                                        _label.innerHTML = "( " + i18n.TYPE_YOUR_MESSAGE_HERE_STATUS + " )";
967                               
968                                if( _parent != null )
969                                {       
970                                        // Remove Input
971                                        if( _element != null )
972                                                _parent.removeChild( _element );
973                                               
974                                        // Add Label
975                                        if( _label != null )
976                                                _parent.appendChild( _label );
977                                }
978                               
979                                // Send Status Message
980                                _statusMessage = ( ( _statusMessage !=  i18n.TYPE_YOUR_MESSAGE_HERE_STATUS ) ? _statusMessage : "" );                           
981                               
982                                TrophyIM.setPresence("status", _statusMessage );
983                        }       
984                }
985        }
986       
987        function setPreferences()
988        {
989                // Element openWindowJabberit
990                var elementOpenW        = document.getElementById('openWindowJabberit');
991                var value                       = '';
992               
993                for(var i = 0 ; i < elementOpenW.options.length; i++)
994                        if( elementOpenW.options[i].selected == true)
995                        {
996                                value = 'preferences1=openWindowJabberit:' + elementOpenW.options[i].value;
997                                _preferencesIM[0] = 'openWindowJabberit:' + elementOpenW.options[i].value;
998                        }
999
1000                // Element openWindowJabberitPopUp
1001                value += '&preferences2=openWindowJabberitPopUp:false';
1002                _preferencesIM[1] = 'openWindowJabberitPopUp:false';
1003               
1004                // Element flagAwayIM
1005                var elementFlagIM = document.getElementById('flagAwayIM');
1006               
1007                if( elementFlagIM.value.length > 0 && parseInt(elementFlagIM.value) > 0 )
1008                {
1009                        _preferencesIM[2] = 'flagAwayIM:' + elementFlagIM.value;
1010                        value += '&preferences3=flagAwayIM:' + elementFlagIM.value;
1011                }
1012                else
1013                {
1014                        alert('Informe um valor igual ou maior que 1!');
1015                        return false;
1016                }
1017
1018                // Element showContactsOfflineJabberit
1019                var elementShowOffline  = document.getElementById('showContactsOfflineJabberit');
1020               
1021                for(var i = 0 ; i < elementShowOffline.options.length; i++)
1022                        if( elementShowOffline.options[i].selected == true)
1023                        {
1024                                _preferencesIM[3] = 'showContactsOfflineJabberit:' + elementShowOffline.options[i].value;
1025                                value += '&preferences4=showContactsOfflineJabberit:' + elementShowOffline.options[i].value;
1026                        }
1027               
1028                // Save Preferences
1029                conn.go('p.pf.setPreferences',
1030                                 function(data)
1031                                 {
1032                                        if( data == 'false' )
1033                                        {
1034                                                alert('Erro salvando suas preferências!');
1035                                        }
1036
1037                                        _winBuild('jabberit_preferences', 'remove');
1038                                 },
1039                                 value);
1040        }
1041       
1042        function setPresence()
1043        {
1044                if( arguments.length > 0 )
1045                {
1046                        var element = arguments[0];
1047                       
1048                        if( showhidden == null )
1049                                showhidden = new ShowHidden(300);
1050                       
1051                        var _status = [
1052                                               ['Afastado', 'away', '<img src="'+path_jabberit+'templates/default/images/away.gif" />'],
1053                                               ['Disponível', 'available', '<img src="'+path_jabberit+'templates/default/images/available.gif" />'],
1054                                               ['Livre p/ Conversa', 'chat', '<img src="'+path_jabberit+'templates/default/images/chat.gif" />'],
1055                                               ['Não Disponível', 'xa', '<img src="'+path_jabberit+'templates/default/images/xa.gif" />'],
1056                                               ['Ocupado', 'dnd', '<img src="'+path_jabberit+'templates/default/images/dnd.gif" />'],
1057                                               ['Desconectado', 'unavailable', '<img src="'+path_jabberit+'templates/default/images/unavailable.gif" />'],
1058                                               ['Mensagem de Status...', 'status', '<img src="'+path_jabberit+'templates/default/images/message_normal.gif" />'],                                               
1059                                          ];
1060                       
1061                        var _itens = "";
1062                       
1063                        for( var i in _status )
1064                        {
1065                                if( typeof( _status[i]) == "object" )
1066                                {
1067                                        _itens += '<span style="cursor:pointer;" onclick="TrophyIM.setPresence(\''+_status[i][1]+'\'); loadscript.setStatusJabber(\''+_status[i][0]+'\',\''+_status[i][1]+'\');">';
1068                                        _itens += _status[i][2]+ "<span style='margin:3px;'>" + _status[i][0] + "</span></span><br/>";
1069                                }
1070                        }
1071                       
1072                        var _statusItens = document.createElement("div");
1073                                _statusItens.style.marginTop    = "65px";
1074                                _statusItens.style.marginLeft   = "67px";
1075                                _statusItens.className                  = "x-menu";
1076                                _statusItens.style.zIndex               = '99999';
1077                                _statusItens.innerHTML                  = _itens; 
1078                                _statusItens.onclick                    = function(){ showhidden.hiddenObject(false); };
1079                                                                                 
1080                                showhidden.action('onmouseover', 'onmouseout', _statusItens);
1081                               
1082                        element.parentNode.onmouseout   = function(){ showhidden.hiddenObject(false); };
1083                        element.parentNode.onmouseover  = function(){ showhidden.hiddenObject(true); };
1084                        element.parentNode.appendChild(_statusItens);
1085                }
1086        }
1087
1088        function setSelectEditable(element, top, left )
1089        {
1090                if( getElement('selectBox0') == null )
1091                        selectEditable.create(element, top, left );
1092        }
1093
1094        function setStatusJabber()
1095        {
1096                if( arguments.length > 0 )
1097                {
1098                        if( arguments[1] != 'status' )
1099                        {
1100                                var _text       = arguments[0];
1101                                var _img        = statusUserIM = arguments[1];
1102                               
1103                                getElement('statusJabberText').innerHTML                = _text;
1104                                getElement('statusJabberImg').style.background  = "url('"+path_jabberit+"templates/default/images/"+_img+".gif')";
1105                                getElement('status_jabber_expresso').style.background = "url('"+path_jabberit+"templates/default/images/"+_img+".gif') no-repeat";
1106                        }
1107                }       
1108        }
1109
1110        function _setUserCurrent( _user )
1111        {
1112                userCurrent =
1113                {
1114                        'jid'           : _user.jid.substring(11, _user.jid.length),
1115                        'password'      : _user.password.substring(11, _user.password.length)
1116                }               
1117        }
1118       
1119        function setUserCurrent()
1120        {
1121                if( getUserCurrent() == null )
1122                {
1123                        conn.go('p.ff.data_0',
1124                                                function(_User)
1125                                                {
1126                                                        conn.go('p.ff.data_1',
1127                                                                        function(_pass)
1128                                                                        {
1129                                                                                _setUserCurrent( { jid : _User, password : _pass } );
1130                                                                        });
1131                                                });
1132                }
1133        }
1134
1135        var _stylesheets = [ ];
1136        var _links = document.getElementsByTagName( 'link' );
1137       
1138        for ( var i = 0; i < _links.length; i++ )
1139                if ( _links.item( i ).type && _links.item( i ).type.toLowerCase( ) == 'text/css' )
1140                        _stylesheets[ _stylesheets.length ] = _links.item( i ); 
1141       
1142        function windowPOPUP()
1143        {
1144                var _id = arguments[0];
1145                var _win_name = _id.replace( /\W/g, '' );
1146
1147                if ( arguments.length == 1 )
1148                {
1149                        if ( windowPopUp[_win_name] )
1150                                return true;
1151                        else
1152                                return false;
1153                }
1154               
1155                if( arguments.length == 2 )
1156                {       
1157                        if( !windowPopUp[_win_name] )
1158                        {
1159                                windowPopUp[_win_name] = window.open( '', _win_name + '__popup', 'height=355,width=380,top=50,left=50,toolbar=no,menubar=no,resizable=no,scrollbars=no,status=no,location=no,titlebar=no');
1160                                var tmp = windowPopUp[_win_name].document;
1161                               
1162                                tmp.write('<html><head>');
1163                                tmp.write('</head><body>');
1164                                tmp.write('</body></html>');
1165                                tmp.close();
1166                               
1167                                for ( var i = 0; i < _stylesheets.length; i++ )
1168                                        tmp.documentElement.getElementsByTagName( 'head' ).item(0).appendChild( _stylesheets[ i ].cloneNode( true ) );
1169
1170                                var divPOP = getElement( _id + "__popUp" );
1171                                        divPOP.style.background = "url('"+path_jabberit+"templates/default/images/icon_down.png') no-repeat";
1172                                        divPOP.innerHTML = "PopIn";
1173                                       
1174                                function _close( )
1175                                {
1176                                        windowPopUp[_win_name].close();
1177                                        configEvents( divPOP ,'onclick', _close, true );
1178                                }
1179                                       
1180                                configEvents( divPOP ,'onclick', _close );
1181
1182                                var _content = tmp.documentElement.getElementsByTagName( 'body' ).item(0).appendChild( getElement(_id + '__chatBox' ).parentNode );
1183
1184                                _content.firstChild.scrollTop = _content.firstChild.scrollHeight;
1185
1186                                configEvents( windowPopUp[_win_name] ,'onbeforeunload', function()
1187                                {
1188                                        delete windowPopUp[_win_name];
1189                                        divPOP.style.background = "url('"+path_jabberit+"templates/default/images/icon_up.png') no-repeat";
1190                                        divPOP.innerHTML = "PopUp";
1191                                        divPOP.onclick  = function(){ loadscript.windowPOPUP( _id , true ); };
1192                                        _winBuild( 'window_chat_area_' + _id, "display" ).content( true );
1193                                });
1194
1195                                _winBuild( 'window_chat_area_' + _id, 'hidden' );
1196                        }
1197                }
1198        }
1199       
1200        function windowNotificationNewUsers()
1201        {
1202                var _users = Xtools.xml('notification_new_users');
1203               
1204                for( var user in TrophyIM.rosterObj.roster )
1205                {
1206                        if ( TrophyIM.rosterObj.roster[ user ].constructor == Function )
1207                                continue;
1208
1209                        if( TrophyIM.rosterObj.roster[ user ].contact.jid != Base64.decode( loadscript.getUserCurrent().jid) )
1210                        {
1211                                var _subscription = TrophyIM.rosterObj.roster[user].contact.subscription;
1212                               
1213                                if ( _subscription == 'to' || _subscription == 'not-in-roster' )
1214                                {
1215                                        var _user       = _users.createElement('user');
1216                                        var _jid        = _users.createElement('jid');
1217                                        var _status     = _users.createElement('status');
1218                                        _jid.appendChild( _users.createTextNode(TrophyIM.rosterObj.roster[user].contact.jid) );
1219                                        _status.appendChild( _users.createTextNode( _subscription ) );
1220                                        _user.appendChild( _jid );
1221                                        _user.appendChild( _status );
1222                                        _users.documentElement.appendChild( _user );
1223                                }
1224                        }
1225                }
1226               
1227                var paramsNotification =
1228                {
1229                        'lang_1' : "Notificação",       
1230                        'lang_2' : "O(s) usuário(s) abaixo pedem sua autorização.",
1231                        'lang_3' : "Autorizar",
1232                        'lang_4' : "Remover"
1233                };
1234               
1235                var winNotification =
1236                {       
1237                         id_window              : "window_notification_new_users",
1238                         width                  : 400,
1239                         height                 : 300,
1240                         top                    : 100,
1241                         left                   : 400,
1242                         draggable              : true,
1243                         visible                : "display",
1244                         resizable              : true,
1245                         zindex                 : zIndex++,
1246                         title                  : "Expresso Messenger - Notificação de Novos Usuários",
1247                         closeAction    : "remove",
1248                         content                : Xtools.parse( _users , "notificationNewUsers.xsl", paramsNotification )       
1249                };
1250
1251                _winBuild( winNotification );
1252        }
1253
1254        function createChatRooms()
1255        {
1256                _winBuild("window_List_Rooms_jabberit_messenger","remove");
1257               
1258                var paramCreateChatRoom =
1259                {
1260                        'lang_nameChatRoom'     : "Nome da Sala",
1261                        'lang_nickName'         : "Apelido"
1262                };
1263               
1264                var winCreateChatRooms =
1265                {       
1266                         id_window              : "window_create_chat_rooms",
1267                         width                  : 360,
1268                         height                 : 160,
1269                         top                    : 100,
1270                         left                   : 410,
1271                         draggable              : true,
1272                         visible                : "display",
1273                         resizable              : true,
1274                         zindex                 : loadscript.getZIndex(),
1275                         title                  : "Expresso Messenger - Criar Sala de Bate Papo",
1276                         closeAction    : "remove",
1277                         content                : Xtools.parse( Xtools.xml("create_chat_room"), "createChatRoom.xsl", paramCreateChatRoom )
1278                };
1279               
1280                _winBuild( winCreateChatRooms );
1281
1282                var _pButtons =
1283                {
1284                        'lang1'                 : 'Ingressar',
1285                        'lang2'                 : 'Fechar',
1286                        'onclickClose'  : '_winBuild("window_create_chat_rooms","remove");',
1287                        'onclickSubmit' : 'TrophyIM.createChatRooms(); _winBuild("window_create_chat_rooms","remove");'
1288                };
1289
1290                // Add Buttons
1291                document.getElementById('buttons_createChatRoom').innerHTML = Xtools.parse(Xtools.xml('buttons_main'), 'buttons.xsl', _pButtons);
1292               
1293        }
1294       
1295        function listRooms( element )
1296        {
1297                element = element.getElementsByTagName( 'item' );
1298
1299                var _roomsCount = 0;
1300                var _xml                = Xtools.xml('listRooms');
1301                var _listRooms  = _xml.documentElement;
1302               
1303                var show = function( )
1304                {
1305                        if ( _roomsCount != element.length )
1306                                return false;
1307                       
1308                        var paramsListRooms =
1309                        {
1310                                "path_jabberit" : path_jabberit
1311                        };
1312                       
1313                        var winListRooms =
1314                {       
1315                                 id_window              : "window_List_Rooms_jabberit_messenger",
1316                         width                  : 450,
1317                         height                 : 300,
1318                         top                    : 100,
1319                         left                   : 400,
1320                         draggable              : true,
1321                         visible                : "display",
1322                         resizable              : true,
1323                         zindex                 : loadscript.getZIndex(),
1324                         title                  : "Expresso Messenger - Salas de Bate Papo",
1325                         closeAction    : "remove",
1326                         content                : Xtools.parse( _xml, "listRooms.xsl", paramsListRooms )
1327                };
1328                       
1329                        _winBuild( winListRooms );
1330                       
1331                        var _pButtons =
1332                        {
1333                                'lang1'                 : 'Criar Nova Sala',
1334                                'lang2'                 : 'Fechar',
1335                                'onclickClose'  : '_winBuild("window_List_Rooms_jabberit_messenger","remove");',
1336                                'onclickSubmit' : 'loadscript.createChatRooms();'
1337                        };
1338
1339                        // Add Buttons
1340                        document.getElementById('buttons_addChatRoom').innerHTML = Xtools.parse(Xtools.xml('buttons_main'), 'buttons.xsl', _pButtons);
1341                };
1342
1343                var _add_room = function( _room )
1344        {
1345                        _roomsCount++;
1346
1347                        var _ROOM               = _xml.createElement('room');
1348                        var _JIDROOM    = _xml.createElement('jidRoom');
1349                        var nameRoom    = _room.getAttribute( 'from' );
1350
1351                        _ROOM.setAttribute( 'nameRoom', unescape((nameRoom.substring(0, nameRoom.indexOf("@"))).toUpperCase()) );
1352                        _JIDROOM.appendChild( _xml.createTextNode(nameRoom) );
1353                        _ROOM.appendChild( _JIDROOM );
1354
1355                        // Get fields elements;
1356                        var _fields = _room.getElementsByTagName( 'field' );
1357
1358                        for ( var f = 0; f < _fields.length; f++ )
1359                        {
1360                                if ( _fields[ f ].getAttribute( 'var' ) )
1361                                {
1362                                        if ( _fields[ f ].firstChild.hasChildNodes( ) && _fields[ f ].getAttribute( 'var' ) == 'muc#roominfo_description' )
1363                                        {
1364                                                var _description        = _xml.createElement("description");
1365                                                        _description.appendChild( _xml.createTextNode( _fields[ f ].firstChild.firstChild.nodeValue ) );
1366                                                        _ROOM.appendChild( _description );
1367                                        }
1368
1369                                        if ( _fields[ f ].firstChild.hasChildNodes( ) && _fields[ f ].getAttribute( 'var' ) == 'muc#roominfo_occupants' )
1370                                        {
1371                                                var _occupants = _xml.createElement("occupants")
1372                                                        _occupants.appendChild( _xml.createTextNode( _fields[ f ].firstChild.firstChild.nodeValue) );
1373                                                        _ROOM.appendChild( _occupants );
1374                                        }
1375                                }
1376                        }
1377
1378                        // Get feature elements;
1379                        var _feature = _room.getElementsByTagName( 'feature' );
1380                       
1381                        for( var f = 0 ; f < _feature.length; f++ )
1382                        {
1383                                if ( _feature[ f ].getAttribute( 'var' ) )
1384                                {
1385                                        if( _feature[ f ].getAttribute( 'var' ) == 'muc_unsecured' )
1386                                        {
1387                                                var _password = _xml.createElement("password");
1388                                                        _password.appendChild( _xml.createTextNode("false") );
1389                                                        _ROOM.appendChild( _password );
1390                                        }
1391                                        else if( _feature[ f ].getAttribute( 'var' ) == 'muc_passwordprotected' )
1392                                        {
1393                                                var _password = _xml.createElement("password");
1394                                                        _password.appendChild( _xml.createTextNode("true") );
1395                                                        _ROOM.appendChild( _password );
1396                                        }       
1397                                }
1398                        }
1399                       
1400                        _listRooms.appendChild( _ROOM );
1401                       
1402                        show( );
1403        };
1404               
1405                var _get_room_info = function( _room )
1406                {
1407                TrophyIM.connection.sendIQ(
1408                                $iq( { "to" : _room, "type" : "get" } ).c( "query",{xmlns: Strophe.NS.DISCO_INFO } ),
1409                                _add_room,
1410                                function( a )
1411                                {
1412                                        _roomsCount++;
1413                               
1414                                        show( );
1415                                       
1416                                }, 500 );
1417                };
1418
1419                if( element.length > 0 )
1420                {
1421                        for ( var i = 0; i < element.length; i++ )
1422                        {
1423                                _get_room_info( element[ i ].getAttribute( 'jid' ) );
1424                        }
1425                }
1426                else
1427                {
1428                        show();
1429                }
1430        }
1431       
1432        function getListRooms()
1433        {
1434                TrophyIM.getListRooms();       
1435        }
1436       
1437        function joinRoom( jidRoom, nameRoom )
1438        {
1439                var append_nick = function( room, nick )
1440            {
1441                var room_nick = room;
1442               
1443                if ( nick )
1444                {
1445                    room_nick += "/" + nick;
1446                }
1447               
1448                return room_nick;
1449            }
1450               
1451            if( document.getElementById( 'window_chat_room_' + jidRoom + '__main' ) != null )
1452            {
1453                _winBuild('window_chat_room_' + jidRoom, 'display');
1454            }
1455            else
1456            {
1457                    var nickName = Base64.decode( loadscript.getUserCurrent().jid );
1458                        nickName = nickName.substring(0, nickName.indexOf('@'));
1459                   
1460                    var _prompt = prompt("Deseja informar um Apelido ?", nickName );
1461                   
1462                    if( _prompt )
1463                    {   
1464                                _prompt = _prompt.replace(/^\s+|\s+$|^\n|\n$/g,"");
1465                           
1466                            var room_nick       = append_nick( jidRoom, nickName );
1467                           
1468                            var nickChat        = nickName.toString();
1469                               
1470                            if( _prompt && _prompt != "" )
1471                            {
1472                                nickChat                = _prompt.toString();
1473                                var room_nick   = append_nick( jidRoom, _prompt );
1474                            }
1475                           
1476                            TrophyIM.makeChatRoom( jidRoom , nameRoom );
1477
1478                            TrophyIM.activeChatRoom.name[ TrophyIM.activeChatRoom.name.length ] = room_nick;
1479                           
1480                            TrophyIM.joinChatRoom( room_nick);
1481                         
1482                            setTimeout(function()
1483                            {
1484                                var _message    =  nickName.toUpperCase() + " entrou como : "  + nickChat;
1485                                   
1486                                    TrophyIM.sendMessageChatRoom( jidRoom , _message );
1487                                   
1488                            }, 500);
1489                           
1490                    }
1491            }
1492           
1493            _winBuild("window_List_Rooms_jabberit_messenger","remove");
1494        }
1495       
1496        function loadIM()
1497        {
1498                if( arguments.length > 0 )
1499                {
1500                        var files = [
1501                                                path_jabberit + 'templates/default/css/button.css',
1502                                                path_jabberit + 'templates/default/css/common.css',
1503                                                path_jabberit + 'templates/default/css/selectEditableStyle.css',
1504                                                path_jabberit + 'templates/default/css/' + theme_jabberit
1505                                    ];
1506                        // FullName
1507                        fullName = arguments[0];
1508                       
1509                        // Preferences
1510                        _preferencesIM = arguments[1].split(";");
1511                       
1512                        if( !_preferencesIM[3] ) _preferencesIM[3] = "showContactsOfflineJabberit:true";
1513                       
1514                        loadScripts(files);
1515                       
1516                        setTimeout(function()
1517                        {
1518                                // Object Xtools       
1519                                if( Xtools == null )
1520                                        Xtools = new xtools(path_jabberit);
1521                               
1522                                // Object Conector
1523                                if( conn == null )
1524                                        conn = new AjaxConnector(path_jabberit);
1525                               
1526                                // Object Add User
1527                                if( addUser == null )
1528                                        addUser = new addUserIM(Xtools, conn);
1529
1530                               
1531                                // Object SelectEditable
1532                                if( selectEditable == null )
1533                                        selectEditable = new SelectEditable();
1534                                       
1535                                // Add Jabber in StatusBar;
1536                                addIcon();
1537                               
1538                                // Auto Connect
1539                                setTimeout(function()
1540                                {
1541                                        if( _preferencesIM[0] === 'openWindowJabberit:true' )
1542                                        {
1543                                                if( SnifferBrowser.isCompatible('ie8','firefox3','epiphany2','iceweasel3') )
1544                                                        TrophyIM.load();
1545                                        }
1546                                       
1547                                },1500);
1548                               
1549                                // Auto Status
1550                                autoStatus();
1551                                configEvents( document, 'onmousemove', autoStatus );
1552                                configEvents( document, 'onkeypress', autoStatus );
1553                               
1554                        }, 2000);
1555                }
1556        }
1557
1558        loadIM.prototype.adIcon                         = addIcon;
1559        loadIM.prototype.actionButton           = actionButton;
1560        loadIM.prototype.addContact                     = addContact;
1561        loadIM.prototype.addNewUser                     = addNewUser;
1562        loadIM.prototype.clrAllContacts         = clrAllContacts;
1563        loadIM.prototype.configEvents           = configEvents;
1564        loadIM.prototype.createChatRooms        = createChatRooms;
1565        loadIM.prototype.disabledNotificationNewUsers   = disabledNotificationNewUsers;
1566        loadIM.prototype.enabledNotificationNewUsers    = enabledNotificationNewUsers; 
1567        loadIM.prototype.getListRooms           = getListRooms;
1568        loadIM.prototype.getIsIE                        = getIsIE;
1569        loadIM.prototype.getPhotoUser           = getPhotoUser;
1570        loadIM.prototype.getSmiles                      = getSmiles;
1571        loadIM.prototype.getStatusUserIM        = getStatusUserIM;
1572        loadIM.prototype.getStatusMessage       = getStatusMessage;
1573        loadIM.prototype.getShowContactsOffline = getShowContactsOffline;
1574        loadIM.prototype.getUserCurrent         = getUserCurrent;
1575        loadIM.prototype.getZIndex                      = getZindex;
1576        loadIM.prototype.groupsHidden           = groupsHidden;
1577        loadIM.prototype.groupsVisible          = groupsVisible;
1578        loadIM.prototype.joinRoom                       = joinRoom;     
1579        loadIM.prototype.keyPressSearch         = keyPressSearch;       
1580        loadIM.prototype.listRooms                      = listRooms;
1581        loadIM.prototype.loginPage                      = loginPage;
1582        loadIM.prototype.notification           = notificationNewMessage;
1583        loadIM.prototype.parse                          = parse;
1584        loadIM.prototype.preferences            = preferences;
1585        loadIM.prototype.searchUser                     = searchUser
1586        loadIM.prototype.setAutorization        = setAutorization;
1587        loadIM.prototype.setMessageStatus       = setMessageStatus;
1588        loadIM.prototype.setPreferences         = setPreferences;
1589        loadIM.prototype.setPresence            = setPresence;
1590        loadIM.prototype.setStatusJabber        = setStatusJabber;
1591        loadIM.prototype.setSelectEditable      = setSelectEditable;
1592        loadIM.prototype.setUserCurrent         = setUserCurrent;
1593        loadIM.prototype.removeContact          = removeContact;
1594        loadIM.prototype.removeElement          = removeElement;
1595        loadIM.prototype.removeGroup            = removeGroup;
1596        loadIM.prototype.renameContact          = renameContact;
1597        loadIM.prototype.renameGroup            = renameGroup;
1598        loadIM.prototype.rosterDiv                      = rosterDiv;
1599        loadIM.prototype.windowNotificationNewUsers  = windowNotificationNewUsers;
1600        loadIM.prototype.windowPOPUP            = windowPOPUP;
1601       
1602        window.LoadIM = loadIM;
1603       
1604        // Necessário para não ocasionar problema no ExpressoMail
1605        // quando os itens abaixo não são criados pelo próprio ExpressoMail
1606        if( SnifferBrowser.isCompatible('is_ie') )
1607        {
1608                configEvents( window, 'onload', function( )
1609                {
1610                        if ( ! document.getElementById( 'cc_msg_err_serialize_data_unknown' ) )
1611                        {
1612                                var fix = document.createElement('input');
1613                                        fix.type        = 'hidden';
1614                                        fix.id          = 'cc_msg_err_serialize_data_unknown';
1615                               
1616                                        document.appendChild( fix );
1617                        }
1618                        if ( ! window.showMessage )
1619                                window.showMessage = function(){};
1620                });
1621        }
1622       
1623})();
Note: See TracBrowser for help on using the repository browser.