Ignore:
Timestamp:
09/05/11 18:10:06 (13 years ago)
Author:
alexandrecorreia
Message:

Ticket #2260 - Sincronismo do branch2.2(versão 2.2.8) do modulo mobile para 2.4

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/jabberit_messenger/jmessenger/js/trophyim.js

    r3332 r5041  
    1717                    this.processor = new XSLTProcessor(); 
    1818                    this.processor.importStylesheet(this.xmlRender( 
    19                     '<xsl:stylesheet version="1.0"\ 
     19                        '<xsl:stylesheet version="1.0"\ 
    2020                    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\ 
    2121                    <xsl:output method="html" indent="yes"/><xsl:template\ 
     
    6868                } 
    6969                var renderObj = this.parser.parseFromString(xmlString, 
    70                 "application/xml"); 
     70                    "application/xml"); 
    7171            } catch(e) { 
    7272                alert("TrophyIM Error: Cannot create new html for page"); 
     
    8484     */ 
    8585    getHTML : function(page) 
    86         { 
     86    { 
    8787        return this.xmlParse(HTMLSnippets[page]); 
    8888    }, 
     
    9696     */ 
    9797    getScript : function(script) 
    98         { 
     98    { 
    9999        var newscript = document.createElement('script'); 
    100100        newscript.setAttribute('src', script); 
     
    112112                 
    113113 
    114         controll : { notificationNewUsers : 0 },         
    115      
    116         /** AutoConnection 
     114    controll : { 
     115        notificationNewUsers : 0 
     116    },   
     117     
     118    /** AutoConnection 
    117119        *  
    118120        */       
    119121                 
    120         autoConnection : { connect : true }, 
    121  
    122         /** Active Chat Room 
     122    autoConnection : { 
     123        connect : true 
     124    }, 
     125 
     126    /** Active Chat Room 
    123127         *  
    124128         */ 
    125129         
    126         activeChatRoom : { name : [] }, 
    127          
    128         /** Object: chatHistory 
     130    activeChatRoom : { 
     131        name : [] 
     132    }, 
     133         
     134    /** Object: chatHistory 
    129135    * 
    130136    *  Stores chat history (last 10 message) and current presence of active 
     
    132138    */ 
    133139         
    134         chatHistory : {}, 
    135          
    136         /** Constants: 
     140    chatHistory : {}, 
     141         
     142    /** Constants: 
    137143    * 
    138144    *    (Boolean) stale_roster - roster is stale and needs to be rewritten. 
    139145    */ 
    140146         
    141         constants : {stale_roster: false}, 
    142          
    143         /** PosWindow 
     147    constants : { 
     148        stale_roster: false 
     149    }, 
     150         
     151    /** PosWindow 
    144152         *  
    145153         */      
    146         posWindow : { left : 400, top : 100 },   
    147                  
    148         /** StatusConnection 
     154    posWindow : { 
     155        left : 400,  
     156        top : 100 
     157    },   
     158                 
     159    /** StatusConnection 
    149160         *  
    150161         */ 
    151162 
    152         statusConn : { connected : false }, 
    153          
    154         /** TimeOut Render Roster 
     163    statusConn : { 
     164        connected : false 
     165    }, 
     166         
     167    /** TimeOut Render Roster 
    155168         *  
    156169         *  
    157170         */ 
    158171         
    159         _timeOut : { renderRoster : null }, 
    160          
    161          
    162         /** Remove Contact ( type = set ) 
     172    _timeOut : { 
     173        renderRoster : null 
     174    }, 
     175         
     176         
     177    /** Remove Contact ( type = set ) 
    163178         *  
    164179         *  
    165180         */ 
    166181         
    167         removeResult : { idResult : [] }, 
    168          
    169      /** Function: setCookie 
     182    removeResult : { 
     183        idResult : [] 
     184    }, 
     185         
     186    /** Function: setCookie 
    170187     * 
    171188     *  Sets cookie name/value pair.  Date and path are auto-selected. 
     
    176193     */ 
    177194     
    178         setCookie : function(name, value) 
    179         { 
     195    setCookie : function(name, value) 
     196    { 
    180197        var expire = new Date(); 
    181198        expire.setDate(expire.getDate() + 365); 
     
    183200    }, 
    184201     
    185         /** Function: delCookie 
     202    /** Function: delCookie 
    186203     * 
    187204     *  Deletes cookie 
     
    191208     */ 
    192209     
    193         delCookie : function(name) 
    194         { 
     210    delCookie : function(name) 
     211    { 
    195212        var expire = new Date(); 
    196213        expire.setDate(expire.getDate() - 365); 
     
    199216    }, 
    200217     
    201         /** Function: getCookies 
     218    /** Function: getCookies 
    202219     * 
    203220     *  Retrieves all trophyim cookies into an indexed object.  Inteneded to be 
     
    208225     */ 
    209226     
    210         getCookies : function() 
    211         { 
     227    getCookies : function() 
     228    { 
    212229        var cObj = {}; 
    213230        var cookies = document.cookie.split(';'); 
     
    215232        for(var i = 0 ; i < cookies.length; i++ ) 
    216233        { 
    217                 while ( cookies[i].charAt(0) == ' ') 
     234            while ( cookies[i].charAt(0) == ' ') 
    218235            {  
    219236                cookies[i] = cookies[i].substring(1,cookies[i].length); 
     
    237254     */ 
    238255 
    239         load : function() 
    240         { 
    241         if( loadscript.getUserCurrent() == null ) 
    242         { 
    243                 loadscript.setUserCurrent();      
     256    load : function() 
     257    { 
     258        if( loadscript.getUserCurrent() == null ) 
     259        { 
     260            loadscript.setUserCurrent();          
    244261        }         
    245262 
    246         if ( !TrophyIM.statusConn.connected ) 
    247                 { 
    248                         TrophyIM.cookies = TrophyIM.getCookies(); 
    249  
    250                         //Wait a second to give scripts time to load 
    251                         setTimeout( "TrophyIM.showLogin()", 550 ); 
    252                 } 
    253                 else 
    254                 { 
    255                         loadscript.rosterDiv(); 
    256                 } 
    257    }, 
    258  
    259    /** Function: storeData 
     263        if ( !TrophyIM.statusConn.connected ) 
     264        { 
     265            TrophyIM.cookies = TrophyIM.getCookies(); 
     266 
     267            //Wait a second to give scripts time to load 
     268            setTimeout( "TrophyIM.showLogin()", 550 ); 
     269        } 
     270        else 
     271        { 
     272            loadscript.rosterDiv(); 
     273        } 
     274    }, 
     275 
     276    /** Function: storeData 
    260277     * 
    261278     *  Store all our data in the JSONStore, if it is active 
    262279     */ 
    263280      
    264    storeData : function() 
    265    { 
     281    storeData : function() 
     282    { 
    266283        if ( TrophyIM.connection && TrophyIM.connection.connected ) 
    267                 { 
     284        { 
    268285            TrophyIM.setCookie('trophyim_bosh_xid', TrophyIM.connection.jid + "|" + 
    269             TrophyIM.connection.sid + "|" +  TrophyIM.connection.rid); 
     286                TrophyIM.connection.sid + "|" +  TrophyIM.connection.rid); 
    270287            TrophyIM.rosterObj.save(); 
    271288        } 
     
    280297      
    281298    showLogin : function() 
    282         { 
     299    { 
    283300        /** 
    284301         *  
     
    288305                 */ 
    289306 
    290                 if ( typeof(JSON) != undefined && typeof(Strophe) != undefined ) 
    291         { 
    292                 TrophyIM.JSONStore = new TrophyIMJSONStore(); 
     307        if ( typeof(JSON) != undefined && typeof(Strophe) != undefined ) 
     308        { 
     309            TrophyIM.JSONStore = new TrophyIMJSONStore(); 
    293310                 
    294                         if ( TrophyIM.JSONStore.store_working && TrophyIM.cookies['trophyim_bosh_xid'] ) 
    295             { 
    296                 var xids = TrophyIM.cookies['trophyim_bosh_xid'].split("|"); 
     311            if ( TrophyIM.JSONStore.store_working && TrophyIM.cookies['trophyim_bosh_xid'] ) 
     312            { 
     313                var xids = TrophyIM.cookies['trophyim_bosh_xid'].split("|"); 
    297314                TrophyIM.delCookie('trophyim_bosh_xid'); 
    298315                TrophyIM.constants.stale_roster = true; 
    299316                         
    300                                 TrophyIM.connection                             = new Strophe.Connection(TROPHYIM_BOSH_SERVICE); 
     317                TrophyIM.connection                             = new Strophe.Connection(TROPHYIM_BOSH_SERVICE); 
    301318                TrophyIM.connection.rawInput    = TrophyIM.rawInput; 
    302319                TrophyIM.connection.rawOutput   = TrophyIM.rawOutput; 
     
    308325            else 
    309326            { 
    310                 // List Contact 
    311                                 loadscript.rosterDiv(); 
    312  
    313                                 // Get User Current; 
    314                                 var _getUserCurrent = null; 
    315                                         _getUserCurrent = loadscript.getUserCurrent(); 
     327                // List Contact 
     328                loadscript.rosterDiv(); 
     329 
     330                // Get User Current; 
     331                var _getUserCurrent = null; 
     332                _getUserCurrent = loadscript.getUserCurrent(); 
    316333                                 
    317                                 if( _getUserCurrent == null ) 
    318                                 {        
    319                                         setTimeout( "TrophyIM.showLogin()", 500 ); 
    320                                 } 
    321                                 else 
    322                                 { 
    323                                         TrophyIM.login( Base64.decode( _getUserCurrent.jid ), Base64.decode( _getUserCurrent.password )); 
    324                                 } 
     334                if( _getUserCurrent == null ) 
     335                {        
     336                    setTimeout( "TrophyIM.showLogin()", 500 ); 
     337                } 
     338                else 
     339                { 
     340                    TrophyIM.login( Base64.decode( _getUserCurrent.jid ), Base64.decode( _getUserCurrent.password )); 
     341                } 
    325342            } 
    326343        } 
    327344        else 
    328345        { 
    329                 setTimeout("TrophyIM.showLogin()", 500); 
    330         } 
    331     }, 
    332      
    333         /** Function: log 
     346            setTimeout("TrophyIM.showLogin()", 500); 
     347        } 
     348    }, 
     349     
     350    /** Function: log 
    334351     * 
    335352     *  This function logs the given message in the trophyimlog div 
     
    361378     */ 
    362379    rawInput : function (data) 
    363         { 
     380    { 
    364381        Strophe.debug("RECV: " + data); 
    365382    }, 
     
    370387     */ 
    371388    rawOutput : function (data) 
    372         { 
     389    { 
    373390        Strophe.debug("SEND: " + data); 
    374391    }, 
     
    382399     */ 
    383400    login : function() 
    384         { 
    385                 if ( TrophyIM.JSONStore.store_working ) 
    386                 {  
    387                    //In case they never logged out 
     401    { 
     402        if ( TrophyIM.JSONStore.store_working ) 
     403        {  
     404            //In case they never logged out 
    388405            TrophyIM.JSONStore.delData(['groups','roster', 'active_chat', 'chat_history']); 
    389406        } 
    390407 
    391                 TrophyIM.connection                             = new Strophe.Connection(TROPHYIM_BOSH_SERVICE); 
     408        TrophyIM.connection                             = new Strophe.Connection(TROPHYIM_BOSH_SERVICE); 
    392409        TrophyIM.connection.rawInput    = TrophyIM.rawInput; 
    393410        TrophyIM.connection.rawOutput   = TrophyIM.rawOutput; 
    394411        //Strophe.log                                   = TrophyIM.log; 
    395412         
    396                 if ( arguments.length > 0 ) 
    397                 { 
    398                         var barejid = arguments[0]; 
    399                         var password = arguments[1]; 
    400                          
    401                         TrophyIM.connection.connect( barejid + TROPHYIM_RESOURCE, password, TrophyIM.onConnect ); 
    402                 } 
    403                 else 
    404                 { 
    405                          
    406                         var barejid             = document.getElementById('trophyimjid').value 
    407                         var fulljid             = barejid + TROPHYIM_RESOURCE; 
    408                         var password    = document.getElementById('trophyimpass').value; 
    409                         var button              = document.getElementById('trophyimconnect'); 
    410                          
    411                         loadscript.setUserCurrent( barejid, password); 
    412                          
    413                         if ( button.value == 'connect' ) 
    414                         { 
    415                                 button.value = 'disconnect'; 
    416                                 //TrophyIM.connection.connect( fulljid , password, TrophyIM.onConnect ); 
     413        if ( arguments.length > 0 ) 
     414        { 
     415            var barejid = arguments[0]; 
     416            var password = arguments[1]; 
     417                         
     418            TrophyIM.connection.connect( barejid + TROPHYIM_RESOURCE, password, TrophyIM.onConnect ); 
     419        } 
     420        else 
     421        { 
     422                         
     423            var barejid         = document.getElementById('trophyimjid').value 
     424            var fulljid         = barejid + TROPHYIM_RESOURCE; 
     425            var password        = document.getElementById('trophyimpass').value; 
     426            var button          = document.getElementById('trophyimconnect'); 
     427                         
     428            loadscript.setUserCurrent( barejid, password); 
     429                         
     430            if ( button.value == 'connect' ) 
     431            { 
     432                button.value = 'disconnect'; 
     433                //TrophyIM.connection.connect( fulljid , password, TrophyIM.onConnect ); 
    417434                                 
    418                                 TrophyIM.login( barejid, password ); 
    419                                 _winBuild('window_login_page', 'remove'); 
    420                         } 
    421                 } 
    422  
    423                 TrophyIM.setCookie('trophyimjid', barejid); 
     435                TrophyIM.login( barejid, password ); 
     436                _winBuild('window_login_page', 'remove'); 
     437            } 
     438        } 
     439 
     440        TrophyIM.setCookie('trophyimjid', barejid); 
    424441    }, 
    425442         
     
    429446     */ 
    430447    logout : function() 
    431         { 
    432         TrophyIM.autoConnection.connect = false; 
     448    { 
     449        TrophyIM.autoConnection.connect = false; 
    433450         
    434         TrophyIM.delCookie('trophyim_bosh_xid'); 
     451        TrophyIM.delCookie('trophyim_bosh_xid'); 
    435452         
    436453        delete TrophyIM['cookies']['trophyim_bosh_xid']; 
     
    444461     */ 
    445462    onConnect : function(status) 
    446         { 
    447         var loading_gif = document.getElementById("JabberIMRosterLoadingGif"); 
    448                  
    449         if( status == Strophe.Status.CONNECTING ) 
    450                 { 
    451                 loading_gif.style.display = "block"; 
    452                 Strophe.info('Strophe is connecting.'); 
    453         } 
    454                  
    455                 if( status == Strophe.Status.CONNFAIL ) 
    456                 { 
    457                         TrophyIM.delCookie('trophyim_bosh_xid'); 
     463    { 
     464        var loading_gif = document.getElementById("JabberIMRosterLoadingGif"); 
     465                 
     466        if( status == Strophe.Status.CONNECTING ) 
     467        { 
     468            loading_gif.style.display = "block"; 
     469            Strophe.info('Strophe is connecting.'); 
     470        } 
     471                 
     472        if( status == Strophe.Status.CONNFAIL ) 
     473        { 
     474            TrophyIM.delCookie('trophyim_bosh_xid'); 
    458475            TrophyIM.statusConn.connected = false; 
    459476            loading_gif.style.display = "block"; 
    460477        } 
    461478                 
    462                 if( status == Strophe.Status.DISCONNECTING ) 
    463                 { 
    464                         TrophyIM.statusConn.connected = false; 
    465         } 
    466                  
    467                 if( status == Strophe.Status.DISCONNECTED ) 
    468                 { 
    469                         if( TrophyIM.autoConnection.connect ) 
    470                         { 
    471                                 loading_gif.style.display = "block"; 
     479        if( status == Strophe.Status.DISCONNECTING ) 
     480        { 
     481            TrophyIM.statusConn.connected = false; 
     482        } 
     483                 
     484        if( status == Strophe.Status.DISCONNECTED ) 
     485        { 
     486            if( TrophyIM.autoConnection.connect ) 
     487            { 
     488                loading_gif.style.display = "block"; 
    472489                                 
    473                                 TrophyIM.delCookie('trophyim_bosh_xid'); 
     490                TrophyIM.delCookie('trophyim_bosh_xid'); 
    474491                     
    475                     TrophyIM.statusConn.connected = false; 
     492                TrophyIM.statusConn.connected = false; 
    476493                     
    477                                 setTimeout(function() 
    478                                 { 
    479                             TrophyIM.showLogin(); 
     494                setTimeout(function() 
     495                { 
     496                    TrophyIM.showLogin(); 
    480497                             
    481                                 },10000); 
     498                },10000); 
    482499                                 
    483                     loadscript.clrAllContacts();         
     500                loadscript.clrAllContacts();     
    484501                     
    485                     loadscript.setStatusJabber(i18n.STATUS_ANAVAILABLE,"unavailable"); 
     502                loadscript.setStatusJabber(i18n.STATUS_ANAVAILABLE,"unavailable"); 
    486503                     
    487                     delete TrophyIM.rosterObj.roster; 
    488                     delete TrophyIM.rosterObj.groups; 
    489                         } 
    490         } 
    491                  
    492                 if( status == Strophe.Status.CONNECTED ) 
    493                 { 
    494                         loadscript.setStatusJabber(i18n.STATUS_AVAILABLE,'available'); 
    495                         TrophyIM.statusConn.connected = true; 
     504                delete TrophyIM.rosterObj.roster; 
     505                delete TrophyIM.rosterObj.groups; 
     506            } 
     507        } 
     508                 
     509        if( status == Strophe.Status.CONNECTED ) 
     510        { 
     511            loadscript.setStatusJabber(i18n.STATUS_AVAILABLE,'available'); 
     512            TrophyIM.statusConn.connected = true; 
    496513            TrophyIM.showClient(); 
    497514        } 
     
    504521     */ 
    505522    showClient : function() 
    506         { 
     523    { 
    507524        TrophyIM.setCookie('trophyim_bosh_xid', TrophyIM.connection.jid + "|" + 
    508         TrophyIM.connection.sid + "|" +  TrophyIM.connection.rid); 
     525            TrophyIM.connection.sid + "|" +  TrophyIM.connection.rid); 
    509526                 
    510527        TrophyIM.rosterObj = new TrophyIMRoster(); 
     
    514531        TrophyIM.connection.addHandler(TrophyIM.onMessage, null, 'message', null, null,  null); 
    515532         
    516                 //Get roster then announce presence. 
    517         TrophyIM.connection.send($iq({type: 'get', xmlns: Strophe.NS.CLIENT}).c('query', {xmlns: Strophe.NS.ROSTER}).tree()); 
     533        //Get roster then announce presence. 
     534        TrophyIM.connection.send($iq({ 
     535            type: 'get',  
     536            xmlns: Strophe.NS.CLIENT 
     537            }).c('query', { 
     538            xmlns: Strophe.NS.ROSTER 
     539            }).tree()); 
    518540        TrophyIM.connection.send($pres().tree()); 
    519                 setTimeout( TrophyIM.renderRoster, 1000); 
     541        setTimeout( TrophyIM.renderRoster, 1000); 
    520542    }, 
    521543         
     
    558580            var to = msg.getAttribute('to'); 
    559581            var id = msg.getAttribute('id'); 
    560             var reply = $iq({type: 'result', to: from, from: to, id: id}).c('query', 
    561             {name: "TrophyIM", version: TROPHYIM_VERSION, os: 
    562             "Javascript-capable browser"}); 
     582            var reply = $iq({ 
     583                type: 'result',  
     584                to: from,  
     585                from: to,  
     586                id: id 
     587            }).c('query', 
     588 
     589            { 
     590                name: "TrophyIM",  
     591                version: TROPHYIM_VERSION,  
     592                os: 
     593                "Javascript-capable browser" 
     594            }); 
    563595            TrophyIM.connection.send(reply.tree()); 
    564596        } 
     
    572604     
    573605    onRoster : function(msg) 
    574         { 
    575         var roster_items = msg.firstChild.getElementsByTagName('item'); 
    576                  
    577                 for (var i = 0; i < roster_items.length; i++) 
    578                 { 
    579                         with(roster_items[i]) 
    580                         { 
    581                                 var groups              = getElementsByTagName('group');         
    582                                 var group_array = []; 
     606    { 
     607        var roster_items = msg.firstChild.getElementsByTagName('item'); 
     608                 
     609        for (var i = 0; i < roster_items.length; i++) 
     610        { 
     611            with(roster_items[i]) 
     612            { 
     613                var groups              = getElementsByTagName('group');         
     614                var group_array = []; 
    583615                                 
    584                                 for( var g = 0 ; g < groups.length; g++ ) 
    585                                 { 
    586                                         if( groups[g].hasChildNodes() ) 
    587                                                 group_array[group_array.length] = groups[g].firstChild.nodeValue; 
    588                                 } 
    589  
    590                                 if( getAttribute('ask') && getAttribute('ask').toString() === "subscribe" )  
    591                                 { 
    592                                         if( getAttribute('subscription').toString() === "none" ) 
    593                                         { 
    594                                                 TrophyIM.rosterObj.addContact( getAttribute('jid'), getAttribute('ask'), getAttribute('name'), group_array ); 
    595                                         } 
     616                for( var g = 0 ; g < groups.length; g++ ) 
     617                { 
     618                    if( groups[g].hasChildNodes() ) 
     619                        group_array[group_array.length] = groups[g].firstChild.nodeValue; 
     620                } 
     621 
     622                if( getAttribute('ask') && getAttribute('ask').toString() === "subscribe" )  
     623                { 
     624                    if( getAttribute('subscription').toString() === "none" ) 
     625                    { 
     626                        TrophyIM.rosterObj.addContact( getAttribute('jid'), getAttribute('ask'), getAttribute('name'), group_array ); 
     627                    } 
    596628                                         
    597                                         if( getAttribute('subscription').toString() === "remove" ) 
    598                                         { 
    599                                                 TrophyIM.rosterObj.removeContact( getAttribute('jid').toString() ); 
    600                                         } 
    601                                 } 
    602                                 else 
    603                                 { 
    604                                         if( ( getAttribute('ask') == null && getAttribute('subscription').toString() === "remove" ) || getAttribute('subscription').toString() === "remove" ) 
    605                                         { 
    606                                                 TrophyIM.rosterObj.removeContact( getAttribute('jid').toString() ); 
    607                                         } 
    608                                         else 
    609                                         { 
    610                                                 TrophyIM.rosterObj.addContact( getAttribute('jid'), getAttribute('subscription'), getAttribute('name'), group_array ); 
    611                                         } 
    612                                 } 
    613                         } 
    614         } 
    615  
    616                 if ( msg.getAttribute('type') == 'set' ) 
    617                 { 
    618                         var _iq = $iq({type: 'reply', id: msg.getAttribute('id'), to: msg.getAttribute('from')}); 
    619                         TrophyIM.connection.send( _iq.tree()); 
    620         } 
    621  
    622                 return true; 
     629                    if( getAttribute('subscription').toString() === "remove" ) 
     630                    { 
     631                        TrophyIM.rosterObj.removeContact( getAttribute('jid').toString() ); 
     632                    } 
     633                } 
     634                else 
     635                { 
     636                    if( ( getAttribute('ask') == null && getAttribute('subscription').toString() === "remove" ) || getAttribute('subscription').toString() === "remove" ) 
     637                    { 
     638                        TrophyIM.rosterObj.removeContact( getAttribute('jid').toString() ); 
     639                    } 
     640                    else 
     641                    { 
     642                        TrophyIM.rosterObj.addContact( getAttribute('jid'), getAttribute('subscription'), getAttribute('name'), group_array ); 
     643                    } 
     644                } 
     645                } 
     646        } 
     647 
     648        if ( msg.getAttribute('type') == 'set' ) 
     649        { 
     650            var _iq = $iq({ 
     651                type: 'reply',  
     652                id: msg.getAttribute('id'),  
     653                to: msg.getAttribute('from') 
     654                }); 
     655            TrophyIM.connection.send( _iq.tree()); 
     656        } 
     657 
     658        return true; 
    623659    }, 
    624660     
     
    629665     
    630666    onPresence : function(msg) 
    631         { 
    632         // Get Presences ChatRoom 
    633         TrophyIM.onPresenceChatRoom( msg ); 
    634  
    635         var type                = msg.getAttribute('type') ? msg.getAttribute('type') : 'available'; 
     667    { 
     668        // Get Presences ChatRoom 
     669        TrophyIM.onPresenceChatRoom( msg ); 
     670 
     671        var type                = msg.getAttribute('type') ? msg.getAttribute('type') : 'available'; 
    636672        var show                = msg.getElementsByTagName('show').length ? Strophe.getText(msg.getElementsByTagName('show')[0]) : type; 
    637673        var status              = msg.getElementsByTagName('status').length ? Strophe.getText(msg.getElementsByTagName('status')[0]) : ''; 
    638674        var priority    = msg.getElementsByTagName('priority').length ? parseInt(Strophe.getText(msg.getElementsByTagName('priority')[0])) : 0; 
    639675 
    640         if( msg.getAttribute('from').toString().indexOf( TROPHYIM_CHATROOM ) < 0 ) 
    641         {        
    642                         var _from = Strophe.getBareJidFromJid( msg.getAttribute('from') ); 
    643                         var _flag = true; 
    644  
    645                 if( TrophyIM.removeResult.idResult.length > 0 ) 
    646                 { 
    647                         for( var i = 0 ; i < TrophyIM.removeResult.idResult.length; i++ ) 
    648                         { 
    649                                 if( TrophyIM.removeResult.idResult[i] == _from ) 
    650                                 { 
    651                                         _flag = false; 
     676        if( msg.getAttribute('from').toString().indexOf( TROPHYIM_CHATROOM ) < 0 ) 
     677        {        
     678            var _from = Strophe.getBareJidFromJid( msg.getAttribute('from') ); 
     679            var _flag = true; 
     680 
     681            if( TrophyIM.removeResult.idResult.length > 0 ) 
     682            { 
     683                for( var i = 0 ; i < TrophyIM.removeResult.idResult.length; i++ ) 
     684                { 
     685                    if( TrophyIM.removeResult.idResult[i] == _from ) 
     686                    { 
     687                        _flag = false; 
    652688                                         
    653                                         TrophyIM.removeResult.idResult.splice(i,1); 
     689                        TrophyIM.removeResult.idResult.splice(i,1); 
    654690                                         
    655                                         i--; 
     691                        i--; 
    656692                                         
    657                                         if( show.toLowerCase() === 'subscribe' ) 
    658                                                 _flag = true; 
    659                                 } 
    660                         } 
    661                 } 
     693                        if( show.toLowerCase() === 'subscribe' ) 
     694                            _flag = true; 
     695                    } 
     696                } 
     697            } 
    662698                 
    663                 if( _flag ) 
    664                         TrophyIM.rosterObj.setPresence( msg.getAttribute('from'), priority, show, status ); 
    665         } 
    666  
    667         return true; 
     699            if( _flag ) 
     700                TrophyIM.rosterObj.setPresence( msg.getAttribute('from'), priority, show, status ); 
     701        } 
     702 
     703        return true; 
    668704    }, 
    669705 
     
    675711    onPresenceChatRoom : function(msg) 
    676712    { 
    677         var xquery = msg.getElementsByTagName("x"); 
    678  
    679         if ( xquery.length > 0 ) 
    680         { 
    681                 for ( var i = 0; i < xquery.length; i++ ) 
    682             { 
    683                 var xmlns = xquery[i].getAttribute("xmlns"); 
    684                  
    685                 if( xmlns.indexOf("http://jabber.org/protocol/muc#user") == 0 ) 
    686                 { 
    687                         var _from       = xquery[i].parentNode.getAttribute('from'); 
    688                         var _to         = xquery[i].parentNode.getAttribute('to'); 
    689  
    690                         // Get NameChatRoom 
    691                         var nameChatRoom        = Strophe.getBareJidFromJid( _from ); 
    692                          
    693                         // Get nickName 
    694                         var nickName            = Strophe.getResourceFromJid( _from ); 
    695                          
    696                         // Get Type/Show 
    697                         var type        = ( xquery[i].parentNode.getAttribute('type') != null ) ? xquery[i].parentNode.getAttribute('type') : 'available' ; 
    698                         var show        = ( xquery[i].parentNode.firstChild.nodeName == "show" ) ? xquery[i].parentNode.firstChild.firstChild.nodeValue : type; 
    699                          
    700                         var _idElement = nameChatRoom + "_UserChatRoom__" + nickName; 
    701                            
    702                         var _UserChatRoom                                       = document.createElement("div"); 
    703                                 _UserChatRoom.id                                = _idElement; 
    704                                 _UserChatRoom.style.paddingLeft = '18px'; 
    705                                 _UserChatRoom.style.margin              = '3px 0px 0px 2px'; 
    706                                 _UserChatRoom.style.background  = 'url("'+path_jabberit+'templates/default/images/' + show + '.gif") no-repeat center left'; 
    707                                 _UserChatRoom.appendChild( document.createTextNode( nickName ) ); 
    708  
    709                         var nodeUser = document.getElementById( _idElement );    
    710                                  
    711                         if( nodeUser == null ) 
    712                         { 
    713                                 if( document.getElementById( nameChatRoom + '__roomChat__participants' ) != null ) 
    714                                 { 
    715                                         nameChatRoom = document.getElementById( nameChatRoom + '__roomChat__participants' ); 
    716                                         nameChatRoom.appendChild( _UserChatRoom ); 
    717                                 } 
    718                                 else 
    719                                 { 
    720                                         if( type != 'unavailable' ) 
    721                                         { 
    722                                                 TrophyIM.makeChatRoom( nameChatRoom, nameChatRoom.substring(0, nameChatRoom.indexOf('@'))); 
    723                                                 nameChatRoom = document.getElementById( nameChatRoom + '__roomChat__participants' ); 
    724                                                 nameChatRoom.appendChild( _UserChatRoom ); 
    725                                         } 
    726                                 } 
    727                         } 
    728                         else 
    729                         { 
    730                                 if( type == 'unavailable' ) 
    731                                 { 
    732                                         nodeUser.parentNode.removeChild( nodeUser ); 
    733                                 } 
    734                                 else if( show ) 
    735                                 { 
    736                                         nodeUser.style.backgroundImage =  'url("'+path_jabberit+'templates/default/images/' + show + '.gif")'; 
    737                                 } 
    738                         } 
     713        var xquery      = msg.getElementsByTagName("x"); 
     714        var _error      = msg.getElementsByTagName("error"); 
     715        
     716        
     717        if( _error.length > 0 ) 
     718        {     
     719            /* Room creation is denied by service policy; 
     720             * 
     721             *  <error code='403' type='auth'> 
     722             *      <forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> 
     723             *      <text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>Room creation is denied by service policy</text> 
     724             *  </error>        
     725             */ 
     726             
     727            for ( var i = 0; i < _error.length; i++ ) 
     728            { 
     729                if ( _error[i].getElementsByTagName("text") ) 
     730                {     
     731                    var _errorMsg = Strophe.getText( _error[i].getElementsByTagName("text")[0] ); 
     732                     
     733                    if( _errorMsg == "Room creation is denied by service policy" ) 
     734                    { 
     735                        alert( i18n.ROOM_CREATION_IS_DENIED_BY_SERVICE_POLICY ); 
     736                    } 
     737                    else 
     738                    { 
     739                        alert( " Informe ao seu Administrador ERRO : \n" + _errorMsg ); 
     740                    }     
     741                         
     742                } 
     743            } 
     744        } 
     745        else 
     746        { 
     747            if ( xquery.length > 0 ) 
     748            { 
     749                for ( var i = 0; i < xquery.length; i++ ) 
     750                { 
     751                    var xmlns = xquery[i].getAttribute("xmlns"); 
     752 
     753                    if( xmlns.indexOf("http://jabber.org/protocol/muc#user") == 0 ) 
     754                    { 
     755                        var _from       = xquery[i].parentNode.getAttribute('from'); 
     756                        var _to         = xquery[i].parentNode.getAttribute('to'); 
     757 
     758                        // Get NameChatRoom 
     759                        var nameChatRoom        = Strophe.getBareJidFromJid( _from ); 
     760 
     761                        // Get nickName 
     762                        var nickName            = Strophe.getResourceFromJid( _from ); 
     763 
     764                        // Get Type/Show 
     765                        var type        = ( xquery[i].parentNode.getAttribute('type') != null ) ? xquery[i].parentNode.getAttribute('type') : 'available' ; 
     766                        var show        = ( xquery[i].parentNode.firstChild.nodeName == "show" ) ? xquery[i].parentNode.firstChild.firstChild.nodeValue : type; 
     767 
     768                        var _idElement = nameChatRoom + "_UserChatRoom__" + nickName; 
     769 
     770                        var _UserChatRoom                                       = document.createElement("div"); 
     771                        _UserChatRoom.id                                = _idElement; 
     772                        _UserChatRoom.style.paddingLeft = '18px'; 
     773                        _UserChatRoom.style.margin              = '3px 0px 0px 2px'; 
     774                        _UserChatRoom.style.background  = 'url("'+path_jabberit+'templates/default/images/' + show + '.gif") no-repeat center left'; 
     775                        _UserChatRoom.appendChild( document.createTextNode( nickName ) ); 
     776 
     777                        var nodeUser = document.getElementById( _idElement );    
     778 
     779                        if( nodeUser == null ) 
     780                        { 
     781                            if( document.getElementById( nameChatRoom + '__roomChat__participants' ) != null ) 
     782                            { 
     783                                nameChatRoom = document.getElementById( nameChatRoom + '__roomChat__participants' ); 
     784                                nameChatRoom.appendChild( _UserChatRoom ); 
     785                            } 
     786                            else 
     787                            { 
     788                                if( type != 'unavailable' ) 
     789                                { 
     790                                    TrophyIM.makeChatRoom( nameChatRoom, nameChatRoom.substring(0, nameChatRoom.indexOf('@'))); 
     791                                    nameChatRoom = document.getElementById( nameChatRoom + '__roomChat__participants' ); 
     792                                    nameChatRoom.appendChild( _UserChatRoom ); 
     793                                } 
     794                            } 
     795                        } 
     796                        else 
     797                        { 
     798                            if( type == 'unavailable' ) 
     799                            { 
     800                                nodeUser.parentNode.removeChild( nodeUser ); 
     801                            } 
     802                            else if( show ) 
     803                            { 
     804                                nodeUser.style.backgroundImage =  'url("'+path_jabberit+'templates/default/images/' + show + '.gif")'; 
     805                            } 
     806                        } 
     807                    } 
    739808                } 
    740809            } 
     
    749818    onMessage : function(msg) 
    750819    { 
    751         var checkTime = function(i) 
    752         { 
    753                 if ( i < 10 ) i= "0" + i; 
     820        var checkTime = function(i) 
     821        { 
     822            if ( i < 10 ) i= "0" + i; 
    754823                 
    755                 return i; 
    756         }; 
     824            return i; 
     825        }; 
    757826         
    758                 var messageDate = function( _date ) 
    759                 { 
    760                         var _dt = _date.substr( 0, _date.indexOf( 'T' ) ).split( '-' ); 
    761                         var _hr = _date.substr( _date.indexOf( 'T' ) + 1, _date.length - _date.indexOf( 'T' ) - 2 ).split( ':' ); 
    762                          
    763                         ( _date = new Date ).setTime( Date.UTC( _dt[0], _dt[1] - 1, _dt[2], _hr[0], _hr[1], _hr[2] ) ); 
    764  
    765                         return ( _date.toLocaleDateString( ).replace( /-/g, '/' ) + ' ' + _date.toLocaleTimeString( ) ); 
    766                 }; 
    767  
    768         var data        = new Date(); 
    769         var dtNow       = checkTime(data.getHours()) + ":" + checkTime(data.getMinutes()) + ":" + checkTime(data.getSeconds()); 
     827        var messageDate = function( _date ) 
     828        { 
     829            var _dt = _date.substr( 0, _date.indexOf( 'T' ) ).split( '-' ); 
     830            var _hr = _date.substr( _date.indexOf( 'T' ) + 1, _date.length - _date.indexOf( 'T' ) - 2 ).split( ':' ); 
     831                         
     832            ( _date = new Date ).setTime( Date.UTC( _dt[0], _dt[1] - 1, _dt[2], _hr[0], _hr[1], _hr[2] ) ); 
     833 
     834            return ( _date.toLocaleDateString( ).replace( /-/g, '/' ) + ' ' + _date.toLocaleTimeString( ) ); 
     835        }; 
     836 
     837        var data        = new Date(); 
     838        var dtNow       = checkTime(data.getHours()) + ":" + checkTime(data.getMinutes()) + ":" + checkTime(data.getSeconds()); 
    770839         
    771840        var from        = msg.getAttribute('from'); 
     
    775844        var stamp       = ( delay[0] != null ) ? "<font style='color:red;'>" + messageDate(delay[0].getAttribute('stamp')) + "</font>" :  dtNow; 
    776845 
    777                 var barejid             = Strophe.getBareJidFromJid(from); 
    778                 var jidChatRoom = Strophe.getResourceFromJid(from); 
    779                 var jid_lower   = barejid.toLowerCase(); 
    780                 var contact             = ""; 
    781                 var state               = ""; 
    782  
    783                 var chatBox     = document.getElementById(jid_lower + "__chatState"); 
    784                 var chatStateOnOff = null; 
    785                 var active      = msg.getElementsByTagName('active'); 
    786                  
    787                 contact = barejid.toLowerCase(); 
    788                 contact = contact.substring(0, contact.indexOf('@')); 
     846        var barejid             = Strophe.getBareJidFromJid(from); 
     847        var jidChatRoom = Strophe.getResourceFromJid(from); 
     848        var jid_lower   = barejid.toLowerCase(); 
     849        var contact             = ""; 
     850        var state               = ""; 
     851 
     852        var chatBox     = document.getElementById(jid_lower + "__chatState"); 
     853        var chatStateOnOff = null; 
     854        var active      = msg.getElementsByTagName('active'); 
     855                 
     856        contact = barejid.toLowerCase(); 
     857        contact = contact.substring(0, contact.indexOf('@')); 
    789858             
    790                 if( TrophyIM.rosterObj.roster[barejid] ) 
    791                 { 
    792                         if( TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name'] ) 
    793                         { 
    794                                 contact = TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name']; 
    795                         } 
    796                 } 
    797  
    798                 // Message with body are "content message", this means state active 
    799                 if ( elems.length > 0 ) 
    800                 { 
    801                         state = ""; 
    802                          
    803                         // Set notify chat state capability on when sender notify it themself 
    804                         chatStateOnOff = document.getElementById(jid_lower + "__chatStateOnOff"); 
    805                          
    806                         if (active.length > 0 & chatStateOnOff != null ) 
    807                         { 
    808                                 chatStateOnOff.value = 'on'; 
    809                         } 
    810  
    811                         // Get Message 
    812                         var _message    = document.createElement("div"); 
    813                         var _text               = Strophe.getText( elems[0] ); 
    814                          
    815                         // Events Javascript 
    816                         _text = _text.replace(/onblur/gi,"EVENT_DENY"); 
    817                          
    818                         _text = _text.replace(/onchange/gi,"EVENT_DENY"); 
    819                          
    820                         _text = _text.replace(/onclick/gi,"EVENT_DENY"); 
    821                          
    822                         _text = _text.replace(/ondblclick/gi,"EVENT_DENY"); 
    823                          
    824                         _text = _text.replace(/onerror/gi,"EVENT_DENY"); 
    825                          
    826                         _text = _text.replace(/onfocus/gi,"EVENT_DENY"); 
    827                          
    828                         _text = _text.replace(/onkeydown/gi,"EVENT_DENY"); 
    829                          
    830                         _text = _text.replace(/onkeypress/gi,"EVENT_DENY"); 
    831                          
    832                         _text = _text.replace(/onkeyup/gi,"EVENT_DENY"); 
    833                          
    834                         _text = _text.replace(/onmousedown/gi,"EVENT_DENY"); 
    835                          
    836                         _text = _text.replace(/onmousemove/gi,"EVENT_DENY"); 
    837                          
    838                         _text = _text.replace(/onmouseout/gi,"EVENT_DENY"); 
    839                          
    840                         _text = _text.replace(/onmouseover/gi,"EVENT_DENY"); 
    841                          
    842                         _text = _text.replace(/onmouseup/gi,"EVENT_DENY"); 
    843                          
    844                         _text = _text.replace(/onresize/gi,"EVENT_DENY"); 
    845                          
    846                         _text = _text.replace(/onselect/gi,"EVENT_DENY"); 
    847                          
    848                         _text = _text.replace(/onunload/gi,"EVENT_DENY"); 
    849                          
    850                         // Events CSS 
    851                         _text = _text.replace(/style/gi,"EVENT_DENY"); 
    852  
    853                         // Tags HTML 
    854                         _text = _text.replace(/img /gi,"IMG_DENY "); 
    855                          
    856                         _text = _text.replace(/script /gi,"SCRIPT_DENY "); 
    857                          
    858                         _text = _text.replace(/div /gi,"DIV_DENY "); 
    859                          
    860                         _text = _text.replace(/span /gi,"SPAN_DENY "); 
    861                          
    862                         _text = _text.replace(/iframe /gi,"IFRAME_DENY "); 
    863                          
    864                         _message.innerHTML = _text; 
    865                          
    866                         ////////// BEGIN XSS ////////////////////////////////////////////////// 
    867                         // Delete Tags <SCRIPT> 
    868                         var scripts = _message.getElementsByTagName('script_deny'); 
    869                         for (var i = 0; i < scripts.length; i++){ _message.removeChild(scripts[i--]); } 
    870                         //////////////////////////////////////////////////// 
    871                          
    872                         // Delete Tags <IMG> 
    873                         var _imgSrc = _message.getElementsByTagName('img_deny'); 
    874                         for (var i = 0; i < _imgSrc.length; i++){ _imgSrc[i].parentNode.removeChild( _imgSrc[i--] ); } 
    875                         //////////////////////////////////////////////////// 
    876                          
    877                         // Delete Tags <DIV> 
    878                         var _Div = _message.getElementsByTagName('div_deny'); 
    879                         for (var i = 0; i < _Div.length; i++){ _Div[i].parentNode.removeChild( _Div[i--] ); } 
    880                         //////////////////////////////////////////////////// 
    881                          
    882                         // Delete Tags <SPAN> 
    883                         var _Span = _message.getElementsByTagName('span_deny'); 
    884                         for (var i = 0; i < _Span.length; i++){ _Span[i].parentNode.removeChild( _Span[i--] ); } 
    885                         //////////////////////////////////////////////////// 
    886  
    887                         // Delete Tags <IFRAME> 
    888                         var _Iframe = _message.getElementsByTagName('iframe_deny'); 
    889                         for (var i = 0; i < _Iframe.length; i++){ _Iframe[i].parentNode.removeChild( _Iframe[i--] ); } 
    890  
    891                         // Delete Tags <A HREF> 
    892                         var _aHref = _message.getElementsByTagName('a'); 
    893                         for (var i = 0; i < _aHref.length; i++){ _aHref[i].parentNode.removeChild( _aHref[i--] ); } 
    894                          
    895                         _message.innerHTML = _message.innerHTML.replace(/^\s+|\s+$|^\n|\n$/g, ""); 
    896                         ////////// END XSS ////////////////////////////////////////////////// 
    897                          
    898                         // Get Smiles 
    899                         _message.innerHTML = loadscript.getSmiles( _message.innerHTML ); 
    900  
    901                         if (type == 'chat' || type == 'normal') 
    902                         { 
    903                                 if ( _message.hasChildNodes() ) 
    904                                 { 
    905                                         var message =  
    906                                         { 
    907                                 contact : "[" + stamp + "] <font style='font-weight:bold; color:black;'>" + contact + "</font>", 
    908                                 msg             : "</br>" + _message.innerHTML 
    909                         }; 
     859        if( TrophyIM.rosterObj.roster[barejid] ) 
     860        { 
     861            if( TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name'] ) 
     862            { 
     863                contact = TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name']; 
     864            } 
     865        } 
     866 
     867        // Message with body are "content message", this means state active 
     868        if ( elems.length > 0 ) 
     869        { 
     870            state = ""; 
     871                         
     872            // Set notify chat state capability on when sender notify it themself 
     873            chatStateOnOff = document.getElementById(jid_lower + "__chatStateOnOff"); 
     874                         
     875            if (active.length > 0 & chatStateOnOff != null ) 
     876            { 
     877                chatStateOnOff.value = 'on'; 
     878            } 
     879 
     880            // Get Message 
     881            var _message        = document.createElement("div"); 
     882            var _text           = Strophe.getText( elems[0] ); 
     883                         
     884            // Events Javascript 
     885            _text = _text.replace(/onblur/gi,"EVENT_DENY"); 
     886                         
     887            _text = _text.replace(/onchange/gi,"EVENT_DENY"); 
     888                         
     889            _text = _text.replace(/onclick/gi,"EVENT_DENY"); 
     890                         
     891            _text = _text.replace(/ondblclick/gi,"EVENT_DENY"); 
     892                         
     893            _text = _text.replace(/onerror/gi,"EVENT_DENY"); 
     894                         
     895            _text = _text.replace(/onfocus/gi,"EVENT_DENY"); 
     896                         
     897            _text = _text.replace(/onkeydown/gi,"EVENT_DENY"); 
     898                         
     899            _text = _text.replace(/onkeypress/gi,"EVENT_DENY"); 
     900                         
     901            _text = _text.replace(/onkeyup/gi,"EVENT_DENY"); 
     902                         
     903            _text = _text.replace(/onmousedown/gi,"EVENT_DENY"); 
     904                         
     905            _text = _text.replace(/onmousemove/gi,"EVENT_DENY"); 
     906                         
     907            _text = _text.replace(/onmouseout/gi,"EVENT_DENY"); 
     908                         
     909            _text = _text.replace(/onmouseover/gi,"EVENT_DENY"); 
     910                         
     911            _text = _text.replace(/onmouseup/gi,"EVENT_DENY"); 
     912                         
     913            _text = _text.replace(/onresize/gi,"EVENT_DENY"); 
     914                         
     915            _text = _text.replace(/onselect/gi,"EVENT_DENY"); 
     916                         
     917            _text = _text.replace(/onunload/gi,"EVENT_DENY"); 
     918                         
     919            // Events CSS 
     920            _text = _text.replace(/style/gi,"EVENT_DENY"); 
     921 
     922            // Tags HTML 
     923            _text = _text.replace(/img /gi,"IMG_DENY "); 
     924                         
     925            _text = _text.replace(/script /gi,"SCRIPT_DENY "); 
     926                         
     927            _text = _text.replace(/div /gi,"DIV_DENY "); 
     928                         
     929            _text = _text.replace(/span /gi,"SPAN_DENY "); 
     930                         
     931            _text = _text.replace(/iframe /gi,"IFRAME_DENY "); 
     932                         
     933            _message.innerHTML = _text; 
     934                         
     935            ////////// BEGIN XSS ////////////////////////////////////////////////// 
     936            // Delete Tags <SCRIPT> 
     937            var scripts = _message.getElementsByTagName('script_deny'); 
     938            for (var i = 0; i < scripts.length; i++){ 
     939                _message.removeChild(scripts[i--]); 
     940            } 
     941            //////////////////////////////////////////////////// 
     942                         
     943            // Delete Tags <IMG> 
     944            var _imgSrc = _message.getElementsByTagName('img_deny'); 
     945            for (var i = 0; i < _imgSrc.length; i++){ 
     946                _imgSrc[i].parentNode.removeChild( _imgSrc[i--] ); 
     947            } 
     948            //////////////////////////////////////////////////// 
     949                         
     950            // Delete Tags <DIV> 
     951            var _Div = _message.getElementsByTagName('div_deny'); 
     952            for (var i = 0; i < _Div.length; i++){ 
     953                _Div[i].parentNode.removeChild( _Div[i--] ); 
     954            } 
     955            //////////////////////////////////////////////////// 
     956                         
     957            // Delete Tags <SPAN> 
     958            var _Span = _message.getElementsByTagName('span_deny'); 
     959            for (var i = 0; i < _Span.length; i++){ 
     960                _Span[i].parentNode.removeChild( _Span[i--] ); 
     961            } 
     962            //////////////////////////////////////////////////// 
     963 
     964            // Delete Tags <IFRAME> 
     965            var _Iframe = _message.getElementsByTagName('iframe_deny'); 
     966            for (var i = 0; i < _Iframe.length; i++){ 
     967                _Iframe[i].parentNode.removeChild( _Iframe[i--] ); 
     968            } 
     969 
     970            // Delete Tags <A HREF> 
     971            var _aHref = _message.getElementsByTagName('a'); 
     972            for (var i = 0; i < _aHref.length; i++){ 
     973                _aHref[i].parentNode.removeChild( _aHref[i--] ); 
     974            } 
     975                         
     976            _message.innerHTML = _message.innerHTML.replace(/^\s+|\s+$|^\n|\n$/g, ""); 
     977            ////////// END XSS ////////////////////////////////////////////////// 
     978                         
     979            // Get Smiles 
     980            _message.innerHTML = loadscript.getSmiles( _message.innerHTML ); 
     981 
     982            if (type == 'chat' || type == 'normal') 
     983            { 
     984                if ( _message.hasChildNodes() ) 
     985                { 
     986                    var message =  
     987                    { 
     988                        contact : "[" + stamp + "] <font style='font-weight:bold; color:black;'>" + contact + "</font>", 
     989                        msg             : "</br>" + _message.innerHTML 
     990                    }; 
    910991                                         
    911                                         TrophyIM.addMessage( TrophyIM.makeChat( from ), jid_lower, message ); 
    912                                 } 
    913                         } 
    914                         else if( type == 'groupchat') 
    915                         { 
    916                                 if ( _message.hasChildNodes() ) 
    917                                 { 
    918                                         var message =  
    919                                         { 
    920                                 contact : "[" + stamp + "] <font style='font-weight:bold; color:black;'>" + jidChatRoom + "</font>", 
    921                                 msg             : "</br>" + _message.innerHTML 
    922                         }; 
    923  
    924                                         TrophyIM.addMessage( TrophyIM.makeChatRoom( barejid ), jid_lower, message ); 
    925                                 } 
    926                         } 
    927                 } 
    928                 // Message without body are "content message", this mean state is not active 
    929                 else 
    930                 { 
    931                         if( chatBox != null ) 
    932                                 state = TrophyIM.getChatState(msg);                      
    933                 } 
    934                  
    935                 // Clean chat status message some time later             
    936                 var clearChatState = function() 
    937                 { 
    938                         chatBox.innerHTML=''; 
    939                 } 
    940                  
    941                 if (chatBox != null) 
    942                 { 
    943                         var clearChatStateTimer;  
    944                          
    945                         chatBox.innerHTML = "<font style='font-weight:bold; color:grey; float:right;'>" + state + "</font>";  
    946                          
    947                         var _composing =  msg.getElementsByTagName('composing');  
    948                          
    949                         if ( _composing.length == 0 ) 
     992                    TrophyIM.addMessage( TrophyIM.makeChat( from ), jid_lower, message ); 
     993                } 
     994            } 
     995            else if( type == 'groupchat') 
     996            { 
     997                if ( _message.hasChildNodes() ) 
     998                { 
     999                    var message =  
     1000                    { 
     1001                        contact : "[" + stamp + "] <font style='font-weight:bold; color:black;'>" + jidChatRoom + "</font>", 
     1002                        msg     : "</br>" + _message.innerHTML 
     1003                    }; 
     1004 
     1005                    TrophyIM.addMessage( TrophyIM.makeChatRoom( barejid ), jid_lower, message ); 
     1006                } 
     1007            } 
     1008        } 
     1009        // Message without body are "content message", this mean state is not active 
     1010        else 
     1011        { 
     1012            if( chatBox != null ) 
     1013                state = TrophyIM.getChatState(msg);                      
     1014        } 
     1015                 
     1016        // Clean chat status message some time later             
     1017        var clearChatState = function() 
     1018        { 
     1019            chatBox.innerHTML=''; 
     1020        } 
     1021                 
     1022        if (chatBox != null) 
     1023        { 
     1024            var clearChatStateTimer;  
     1025                         
     1026            chatBox.innerHTML = "<font style='font-weight:bold; color:grey; float:right;'>" + state + "</font>";  
     1027                         
     1028            var _composing =  msg.getElementsByTagName('composing');  
     1029                         
     1030            if ( _composing.length == 0 ) 
    9501031                                 
    951                                 clearChatStateTimer = setTimeout(clearChatState, 2000);  
    952                         else  
    953                                 clearTimeout(clearChatStateTimer);                       
    954                 } 
    955  
    956                 return true; 
    957         }, 
    958  
    959         /** Function: getChatState 
     1032                clearChatStateTimer = setTimeout(clearChatState, 2000);  
     1033            else  
     1034                clearTimeout(clearChatStateTimer);                       
     1035        } 
     1036 
     1037        return true; 
     1038    }, 
     1039 
     1040    /** Function: getChatState 
    9601041         * 
    9611042         *  Parameters: 
     
    9631044         *    (string) jid - the jid of chat box to update the chat state to. 
    9641045         */ 
    965         getChatState : function(msg) 
    966         { 
    967                 var     state =  msg.getElementsByTagName('inactive'); 
     1046    getChatState : function(msg) 
     1047    { 
     1048        var     state =  msg.getElementsByTagName('inactive'); 
    9681049                 
    969                 if ( state.length > 0 ) 
    970                 { 
    971                 return i18n.INACTIVE; 
    972                 } 
    973                 else 
    974                 { 
    975                 state = msg.getElementsByTagName('gone'); 
     1050        if ( state.length > 0 ) 
     1051        { 
     1052            return i18n.INACTIVE; 
     1053        } 
     1054        else 
     1055        { 
     1056            state = msg.getElementsByTagName('gone'); 
    9761057            if ( state.length > 0 ) 
    9771058            { 
    978                 return i18n.GONE; 
    979                         } 
     1059                return i18n.GONE; 
     1060            } 
    9801061            else 
    9811062            { 
    982                 state = msg.getElementsByTagName('composing');  
    983                 if ( state.length > 0 ) 
    984                 { 
    985                         return i18n.COMPOSING; 
    986                                 } 
    987                 else 
    988                 { 
    989                         state =  msg.getElementsByTagName('paused'); 
    990                         if ( state.length > 0 ) 
    991                         { 
    992                                 return i18n.PAUSED; 
    993                                         } 
    994                                 } 
    995                         } 
    996                 } 
    997                  
    998                 return ''; 
    999         }, 
    1000  
    1001         /** Function: makeChat 
     1063                state = msg.getElementsByTagName('composing');  
     1064                if ( state.length > 0 ) 
     1065                { 
     1066                    return i18n.COMPOSING; 
     1067                } 
     1068                else 
     1069                { 
     1070                    state =  msg.getElementsByTagName('paused'); 
     1071                    if ( state.length > 0 ) 
     1072                    { 
     1073                        return i18n.PAUSED; 
     1074                    } 
     1075                } 
     1076            } 
     1077        } 
     1078                 
     1079        return ''; 
     1080    }, 
     1081 
     1082    /** Function: makeChat 
    10021083     * 
    10031084     *  Make sure chat window to given fulljid exists, switching chat context to 
     
    10071088    makeChat : function(fulljid) 
    10081089    { 
    1009         var barejid             = Strophe.getBareJidFromJid(fulljid); 
    1010         var titleWindow = ""; 
    1011  
    1012         var paramsChatBox = 
    1013         { 
    1014                         'enabledPopUp'  : ( ( loadscript.getIsIE() ) ? "none" : "block" ), 
    1015                         'idChatBox'     : barejid + "__chatBox", 
    1016                         'jidTo'                 : barejid, 
    1017                                 'path_jabberit' : path_jabberit 
    1018         }; 
    1019  
    1020         titleWindow = barejid.toLowerCase(); 
    1021                 titleWindow = titleWindow.substring(0, titleWindow.indexOf('@')); 
     1090        var barejid             = Strophe.getBareJidFromJid(fulljid); 
     1091        var titleWindow = ""; 
     1092 
     1093        var paramsChatBox = 
     1094        { 
     1095            'enabledPopUp'      : ( ( loadscript.getBrowserCompatible() ) ? "block" : "none" ), 
     1096            'idChatBox'         : barejid + "__chatBox", 
     1097            'jidTo'                     : barejid, 
     1098            'path_jabberit' : path_jabberit 
     1099        }; 
     1100 
     1101        titleWindow = barejid.toLowerCase(); 
     1102        titleWindow = titleWindow.substring(0, titleWindow.indexOf('@')); 
    10221103 
    10231104        if( TrophyIM.rosterObj.roster[barejid] ) 
     
    10251106            if( TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name'] ) 
    10261107            { 
    1027                 titleWindow = TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name']; 
     1108                titleWindow = TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name']; 
    10281109            } 
    10291110        } 
     
    10321113        TrophyIM.posWindow.top  = TrophyIM.posWindow.top + 10;  
    10331114        if( TrophyIM.posWindow.top > 200 ) 
    1034                 TrophyIM.posWindow.top  = 100; 
     1115            TrophyIM.posWindow.top      = 100; 
    10351116         
    10361117        // Position Left 
    10371118        TrophyIM.posWindow.left = TrophyIM.posWindow.left + 5; 
    10381119        if( TrophyIM.posWindow.left > 455 ) 
    1039                 TrophyIM.posWindow.left = 400; 
     1120            TrophyIM.posWindow.left     = 400; 
    10401121         
    10411122        var _content = document.createElement( 'div' ); 
     
    10461127        var _textarea           = _content.getElementsByTagName( 'textarea' ).item( 0 ); 
    10471128        var _send                       = _content.getElementsByTagName( 'input' ).item( 0 ); 
    1048                 var _chatStateOnOff     = _content.getElementsByTagName( 'input' ).item( 1 ); 
     1129        var _chatStateOnOff     = _content.getElementsByTagName( 'input' ).item( 1 ); 
    10491130 
    10501131        var _send_message = function( ) 
    10511132        { 
    1052                 if ( ! TrophyIM.sendMessage( barejid, _textarea.value ) ) 
    1053                         return false; 
    1054  
    1055                 // Add Message in chatBox; 
    1056                 TrophyIM.addMessage( _messages, barejid, { 
    1057                         contact : "<font style='font-weight:bold; color:red;'>" + i18n.ME + "</font>", 
    1058                         msg : "<br/>" + _textarea.value 
    1059                 } ); 
    1060  
    1061                 _textarea.value = ''; 
    1062                 _textarea.focus( ); 
     1133            if ( ! TrophyIM.sendMessage( barejid, _textarea.value ) ) 
     1134                return false; 
     1135 
     1136            // Add Message in chatBox; 
     1137            TrophyIM.addMessage( _messages, barejid, { 
     1138                contact : "<font style='font-weight:bold; color:red;'>" + i18n.ME + "</font>", 
     1139                msg : "<br/>" + _textarea.value 
     1140            } ); 
     1141 
     1142            _textarea.value = ''; 
     1143            _textarea.focus( ); 
    10631144        }; 
    10641145                 
    1065                 var composingTimer_ = 0; 
    1066                 var isComposing_ = 0; 
    1067                 var timeCounter; 
    1068  
    1069                 var setComposing = function( ) 
    1070                 { 
    1071                         var checkComposing = function() 
    1072                         { 
    1073                 if (!isComposing_) { 
    1074                         // User stopped composing 
    1075                         composingTimer_ = 0; 
    1076                         clearInterval(timeCounter); 
    1077                         TrophyIM.sendContentMessage(barejid, 'paused'); 
    1078                 } else { 
    1079                         TrophyIM.sendContentMessage(barejid, 'composing'); 
    1080                 } 
    1081                 isComposing_ = 0; // Reset composing 
    1082                 } 
    1083  
    1084                 if (!composingTimer_) { 
    1085                 /* User (re)starts composing */ 
    1086                 composingTimer_ = 1; 
    1087                 timeCounter = setInterval(checkComposing,4000); 
    1088                 } 
    1089                 isComposing_ = 1; 
    1090         }; 
     1146        var composingTimer_ = 0; 
     1147        var isComposing_ = 0; 
     1148        var timeCounter; 
     1149 
     1150        var setComposing = function( ) 
     1151        { 
     1152            var checkComposing = function() 
     1153            { 
     1154                if (!isComposing_) { 
     1155                    // User stopped composing 
     1156                    composingTimer_ = 0; 
     1157                    clearInterval(timeCounter); 
     1158                    TrophyIM.sendContentMessage(barejid, 'paused'); 
     1159                } else { 
     1160                    TrophyIM.sendContentMessage(barejid, 'composing'); 
     1161                } 
     1162                isComposing_ = 0; // Reset composing 
     1163            } 
     1164 
     1165            if (!composingTimer_) { 
     1166                /* User (re)starts composing */ 
     1167                composingTimer_ = 1; 
     1168                timeCounter = setInterval(checkComposing,4000); 
     1169            } 
     1170            isComposing_ = 1; 
     1171        }; 
    10911172 
    10921173        loadscript.configEvents( _send, 'onclick', _send_message ); 
    1093                 loadscript.configEvents( _textarea, 'onkeyup', function( e ) 
    1094                 { 
    1095                         if ( e.keyCode == 13 ){ 
    1096                                 _send_message( ); 
    1097                                 // User stopped composing 
    1098                 composingTimer_ = 0; 
    1099                 clearInterval(timeCounter); 
    1100                         }else{ 
    1101                                 if (_chatStateOnOff.value == 'on') 
    1102                                         setComposing(); 
    1103                         } 
    1104                 } );         
    1105  
    1106         var winChatBox =  
    1107         { 
    1108                          id_window              : "window_chat_area_" + barejid, 
    1109                          barejid                : barejid, 
    1110                          width                  : 387, 
    1111                          height                 : 375, 
    1112                         top                    : TrophyIM.posWindow.top, 
    1113                          left                   : TrophyIM.posWindow.left, 
    1114                         draggable              : true, 
    1115                         visible                : "display", 
    1116                         resizable              : true, 
    1117                          zindex                 : loadscript.getZIndex(), 
    1118                          title                  : titleWindow, 
    1119                          closeAction    : "hidden", 
    1120                         content                : _content       
    1121         } 
     1174        loadscript.configEvents( _textarea, 'onkeyup', function( e ) 
     1175        { 
     1176            if ( e.keyCode == 13 ){ 
     1177                _send_message( ); 
     1178                // User stopped composing 
     1179                composingTimer_ = 0; 
     1180                clearInterval(timeCounter); 
     1181            }else{ 
     1182                if (_chatStateOnOff.value == 'on') 
     1183                    setComposing(); 
     1184            } 
     1185        } );         
     1186 
     1187        var winChatBox =  
     1188        { 
     1189           id_window           : "window_chat_area_" + barejid, 
     1190           barejid             : barejid, 
     1191            width               : 387, 
     1192            height              : 375, 
     1193            top                 : TrophyIM.posWindow.top, 
     1194            left                : TrophyIM.posWindow.left, 
     1195            draggable           : true, 
     1196            visible             : "display", 
     1197            resizable           : true, 
     1198            zindex              : loadscript.getZIndex(), 
     1199            title               : titleWindow, 
     1200            closeAction         : "hidden", 
     1201            content             : _content       
     1202        } 
    11221203         
    1123                 _win = _winBuild(winChatBox); 
    1124  
    1125         // Notification New Message 
    1126         loadscript.notification(barejid); 
     1204        _win = _winBuild(winChatBox); 
     1205 
     1206        // Notification New Message 
     1207        loadscript.notification(barejid); 
    11271208         
    1128         // Photo User; 
    1129                 loadscript.getPhotoUser(barejid); 
     1209        // Photo User; 
     1210        loadscript.getPhotoUser(barejid); 
    11301211                 
    1131                 _textarea.focus( ); 
    1132                  
    1133                 return ( _messages = _win.content( ).firstChild ); 
    1134     }, 
    1135  
    1136         /** Function: makeChatRoom 
     1212        _textarea.focus( ); 
     1213         
     1214        _messages = _win.content( ).firstChild;  
     1215         
     1216        while ( _messages && _messages.nodeType !== 1 )  
     1217        {  
     1218            _messages = _messages.nextSibling;  
     1219        }  
     1220         
     1221        return ( _messages );          
     1222    }, 
     1223 
     1224    /** Function: makeChatRoom 
    11371225    * 
    11381226    * 
     
    11421230    makeChatRoom : function() 
    11431231    { 
    1144         var jidChatRoom = arguments[0]; 
    1145         var titleWindow = "ChatRoom - " + unescape(arguments[1]); 
     1232        var jidChatRoom = arguments[0]; 
     1233        var titleWindow = "ChatRoom - " + unescape(arguments[1]); 
    11461234         
    1147         var paramsChatRoom = 
    1148         { 
    1149                         'idChatRoom'    : jidChatRoom + "__roomChat", 
    1150                         'jidTo'                 : jidChatRoom, 
    1151                         'lang_Send'             : i18n.SEND, 
    1152                         'lang_Leave_ChatRoom' : i18n.LEAVE_CHATROOM, 
    1153                                 'path_jabberit' : path_jabberit 
    1154         }; 
    1155  
    1156         // Position Top 
     1235        var paramsChatRoom = 
     1236        { 
     1237            'idChatRoom'        : jidChatRoom + "__roomChat", 
     1238            'jidTo'                     : jidChatRoom, 
     1239            'lang_Send'         : i18n.SEND, 
     1240            'lang_Leave_ChatRoom' : i18n.LEAVE_CHATROOM, 
     1241            'path_jabberit' : path_jabberit 
     1242        }; 
     1243 
     1244        // Position Top 
    11571245        TrophyIM.posWindow.top  = TrophyIM.posWindow.top + 10;  
    11581246        if( TrophyIM.posWindow.top > 200 ) 
    1159                 TrophyIM.posWindow.top  = 100; 
     1247            TrophyIM.posWindow.top      = 100; 
    11601248         
    11611249        // Position Left 
    11621250        TrophyIM.posWindow.left = TrophyIM.posWindow.left + 5; 
    11631251        if( TrophyIM.posWindow.left > 455 ) 
    1164                 TrophyIM.posWindow.left = 400; 
     1252            TrophyIM.posWindow.left     = 400; 
    11651253 
    11661254        var _content = document.createElement( 'div' ); 
     
    11751263        var _send_message = function( ) 
    11761264        { 
    1177                 if ( ! TrophyIM.sendMessageChatRoom( jidChatRoom, _textarea.value ) ) 
    1178                         return false; 
     1265            if ( ! TrophyIM.sendMessageChatRoom( jidChatRoom, _textarea.value ) ) 
     1266                return false; 
    11791267                 
    1180                 _textarea.value = ''; 
     1268            _textarea.value = ''; 
    11811269                 
    1182                 _textarea.focus( ); 
     1270            _textarea.focus( ); 
    11831271        }; 
    11841272         
     
    11861274        loadscript.configEvents( _leaveChatRoom, 'onclick', function( ) 
    11871275        { 
    1188                 TrophyIM.leaveChatRoom( jidChatRoom ); 
     1276            TrophyIM.leaveChatRoom( jidChatRoom ); 
    11891277                 
    1190                 if( TrophyIM.activeChatRoom.name.length > 0 ) 
    1191                 { 
    1192                         for( var i = 0;  i < TrophyIM.activeChatRoom.name.length ; i++ ) 
    1193                         { 
    1194                                 if( TrophyIM.activeChatRoom.name[i].indexOf( jidChatRoom ) >= 0 ) 
    1195                                 { 
    1196                                         TrophyIM.activeChatRoom.name[i] = ""; 
    1197                                 } 
    1198                         } 
    1199                 } 
     1278            if( TrophyIM.activeChatRoom.name.length > 0 ) 
     1279            { 
     1280                for( var i = 0;  i < TrophyIM.activeChatRoom.name.length ; i++ ) 
     1281                { 
     1282                    if( TrophyIM.activeChatRoom.name[i].indexOf( jidChatRoom ) >= 0 ) 
     1283                    { 
     1284                        TrophyIM.activeChatRoom.name[i] = ""; 
     1285                    } 
     1286                } 
     1287            } 
    12001288                 
    1201                 setTimeout( function() 
    1202                 { 
    1203                         _winBuild("window_chat_room_" + jidChatRoom, "remove"); 
     1289            setTimeout( function() 
     1290            { 
     1291                _winBuild("window_chat_room_" + jidChatRoom, "remove"); 
    12041292                         
    1205                 }, 650 ); 
     1293            }, 650 ); 
    12061294                 
    12071295        }); 
    12081296         
    1209                 loadscript.configEvents( _textarea, 'onkeyup', function( e ) 
    1210                 { 
    1211                         if ( e.keyCode == 13 ) 
    1212                         { 
    1213                                 _send_message( ); 
    1214                         } 
    1215                 });         
     1297        loadscript.configEvents( _textarea, 'onkeyup', function( e ) 
     1298        { 
     1299            if ( e.keyCode == 13 ) 
     1300            { 
     1301                _send_message( ); 
     1302            } 
     1303        });         
    12161304         
    1217         var winChatRoom =  
    1218         { 
    1219                          id_window              : "window_chat_room_" + arguments[0], 
    1220                          barejid                : jidChatRoom, 
    1221                         width                  : 500, 
    1222                         height                 : 450, 
    1223                         top                    : TrophyIM.posWindow.top, 
    1224                         left                   : TrophyIM.posWindow.left, 
    1225                         draggable              : true, 
    1226                         visible                : "display", 
    1227                         resizable              : true, 
    1228                         zindex                 : loadscript.getZIndex(), 
    1229                         title                  : titleWindow, 
    1230                         closeAction    : "hidden", 
    1231                         content                : _content       
    1232         } 
     1305        var winChatRoom =  
     1306        { 
     1307           id_window           : "window_chat_room_" + arguments[0], 
     1308           barejid             : jidChatRoom, 
     1309            width                       : 500, 
     1310            height                      : 450, 
     1311            top                 : TrophyIM.posWindow.top, 
     1312            left                        : TrophyIM.posWindow.left, 
     1313            draggable           : true, 
     1314            visible             : "display", 
     1315            resizable           : true, 
     1316            zindex                      : loadscript.getZIndex(), 
     1317            title                       : titleWindow, 
     1318            closeAction : "hidden", 
     1319            content             : _content       
     1320        } 
    12331321         
    1234         _win = _winBuild(winChatRoom); 
     1322        _win = _winBuild(winChatRoom); 
    12351323         
    1236         return ( _messages = _win.content( ).firstChild ); 
     1324        _messages = _win.content( ).firstChild;  
     1325         
     1326        while ( _messages && _messages.nodeType !== 1 )  
     1327        {  
     1328            _messages = _messages.nextSibling;  
     1329        }  
     1330         
     1331        return ( _messages );          
     1332 
    12371333         
    12381334    }, 
    12391335     
    1240         /** Function addContacts 
     1336    /** Function addContacts 
    12411337         *  
    12421338         *  Parameters: 
     
    12471343         */ 
    12481344         
    1249         addContact : function( jidTo, name, group ) 
    1250         { 
    1251                 var _flag = true; 
    1252  
    1253                 if( TrophyIM.removeResult.idResult.length > 0 ) 
    1254                 { 
    1255                         for( var i = 0 ; i < TrophyIM.removeResult.idResult.length; i++ ) 
    1256                         { 
    1257                                 if( TrophyIM.removeResult.idResult[i] == jidTo ) 
    1258                                 { 
    1259                                         _flag = false; 
     1345    addContact : function( jidTo, name, group ) 
     1346    { 
     1347        var _flag = true; 
     1348 
     1349        if( TrophyIM.removeResult.idResult.length > 0 ) 
     1350        { 
     1351            for( var i = 0 ; i < TrophyIM.removeResult.idResult.length; i++ ) 
     1352            { 
     1353                if( TrophyIM.removeResult.idResult[i] == jidTo ) 
     1354                { 
     1355                    _flag = false; 
    12601356                                         
    1261                                         TrophyIM.removeResult.idResult.splice(i,1); 
     1357                    TrophyIM.removeResult.idResult.splice(i,1); 
    12621358                                         
    1263                                         i--; 
    1264                                 } 
    1265                         } 
    1266                 } 
    1267                  
    1268                 if( _flag ) 
    1269                 {        
    1270                 // Add Contact 
    1271                 var _id = TrophyIM.connection.getUniqueId('add');  
    1272                         var newContact = $iq({type: 'set', id: _id }); 
    1273                                 newContact = newContact.c('query').attrs({xmlns : 'jabber:iq:roster'}); 
    1274                                 newContact = newContact.c('item').attrs({jid: jidTo, name:name }); 
    1275                                 newContact = newContact.c('group').t(group).tree(); 
    1276          
    1277                         TrophyIM.connection.send(newContact); 
    1278                 } 
    1279         }, 
     1359                    i--; 
     1360                } 
     1361            } 
     1362        } 
     1363                 
     1364        if( _flag ) 
     1365        {        
     1366            // Add Contact 
     1367            var _id = TrophyIM.connection.getUniqueId('add');  
     1368            var newContact = $iq({ 
     1369                type: 'set',  
     1370                id: _id 
     1371            }); 
     1372            newContact = newContact.c('query').attrs({ 
     1373                xmlns : 'jabber:iq:roster' 
     1374            }); 
     1375            newContact = newContact.c('item').attrs({ 
     1376                jid: jidTo,  
     1377                name:name 
     1378            }); 
     1379            newContact = newContact.c('group').t(group).tree(); 
     1380         
     1381            TrophyIM.connection.send(newContact); 
     1382        } 
     1383    }, 
    12801384 
    12811385    /** Function: add 
     
    12881392    addMessage : function( chatBox, jid, msg ) 
    12891393    { 
    1290         // Get Smiles 
    1291         msg.msg = loadscript.getSmiles( msg.msg ); 
     1394        // Get Smiles 
     1395        msg.msg = loadscript.getSmiles( msg.msg ); 
    12921396  
    1293         var messageDiv  = document.createElement("div"); 
    1294                 messageDiv.style.margin = "3px 0px 1em 3px"; 
    1295         messageDiv.innerHTML    = msg.contact + " : " + msg.msg ; 
     1397        var messageDiv  = document.createElement("div"); 
     1398        messageDiv.style.margin = "3px 0px 1em 3px"; 
     1399        messageDiv.innerHTML    = msg.contact + " : " + msg.msg ; 
    12961400                 
    1297         chatBox.appendChild(messageDiv); 
    1298         chatBox.scrollTop = chatBox.scrollHeight; 
     1401        chatBox.appendChild(messageDiv); 
     1402        chatBox.scrollTop = chatBox.scrollHeight; 
    12991403    }, 
    13001404         
     
    13061410    renameContact : function( jid ) 
    13071411    { 
    1308         // Name 
    1309         var name                = TrophyIM.rosterObj.roster[jid].contact.name; 
    1310  
    1311                 if(( name = prompt(i18n.ASK_NEW_NAME_QUESTION + name + "!", name ))) 
    1312                         if(( name = name.replace(/^\s+|\s+$|^\n|\n$/g,"")) == "" ) 
    1313                                 name = ""; 
    1314  
    1315                 if( name == null || name == "") 
    1316                         name = ""; 
    1317                  
    1318         var jidTo = jid 
    1319         var name  = ( name ) ? name : TrophyIM.rosterObj.roster[jid].contact.name; 
    1320         var group = TrophyIM.rosterObj.roster[jid].contact.groups[0]; 
     1412        // Name 
     1413        var name                = TrophyIM.rosterObj.roster[jid].contact.name; 
     1414 
     1415        if(( name = prompt(i18n.ASK_NEW_NAME_QUESTION + name + "!", name ))) 
     1416            if(( name = name.replace(/^\s+|\s+$|^\n|\n$/g,"")) == "" ) 
     1417                name = ""; 
     1418 
     1419        if( name == null || name == "") 
     1420            name = ""; 
     1421                 
     1422        var jidTo = jid 
     1423        var name  = ( name ) ? name : TrophyIM.rosterObj.roster[jid].contact.name; 
     1424        var group = TrophyIM.rosterObj.roster[jid].contact.groups[0]; 
    13211425         
    1322         TrophyIM.addContact( jidTo, name, group ); 
     1426        TrophyIM.addContact( jidTo, name, group ); 
    13231427         
    1324         document.getElementById('itenContact_' + jid ).innerHTML = name; 
     1428        document.getElementById('itenContact_' + jid ).innerHTML = name; 
    13251429    }, 
    13261430     
     
    13321436    renameGroup : function( jid ) 
    13331437    { 
    1334         var group               = TrophyIM.rosterObj.roster[jid].contact.groups[0]; 
    1335         var presence    = TrophyIM.rosterObj.roster[jid].presence; 
     1438        var group               = TrophyIM.rosterObj.roster[jid].contact.groups[0]; 
     1439        var presence    = TrophyIM.rosterObj.roster[jid].presence; 
    13361440         
    1337                 // Group 
    1338                 if(( group = prompt( i18n.ASK_NEW_GROUP_QUESTION, group ))) 
    1339                         if(( group = group.replace(/^\s+|\s+$|^\n|\n$/g,"")) == "" ) 
    1340                                 group = ""; 
    1341  
    1342                 if( group == null || group == "") 
    1343                         group = ""; 
    1344  
    1345         var jidTo = TrophyIM.rosterObj.roster[jid].contact.jid; 
    1346         var name  = TrophyIM.rosterObj.roster[jid].contact.name; 
    1347                 var group = ( group ) ? group : TrophyIM.rosterObj.roster[jid].contact.groups[0]; 
    1348  
    1349                 TrophyIM.rosterObj.removeContact( jid ); 
    1350                  
    1351                 TrophyIM.addContact( jidTo, name, group ); 
     1441        // Group 
     1442        if(( group = prompt( i18n.ASK_NEW_GROUP_QUESTION, group ))) 
     1443            if(( group = group.replace(/^\s+|\s+$|^\n|\n$/g,"")) == "" ) 
     1444                group = ""; 
     1445 
     1446        if( group == null || group == "") 
     1447            group = ""; 
     1448 
     1449        var jidTo = TrophyIM.rosterObj.roster[jid].contact.jid; 
     1450        var name  = TrophyIM.rosterObj.roster[jid].contact.name; 
     1451        var group = ( group ) ? group : TrophyIM.rosterObj.roster[jid].contact.groups[0]; 
     1452 
     1453        TrophyIM.rosterObj.removeContact( jid ); 
     1454                 
     1455        TrophyIM.addContact( jidTo, name, group ); 
    13521456         
    1353                 document.getElementById("JabberIMRoster").innerHTML = ""; 
    1354                  
    1355         TrophyIM.renderRoster(); 
     1457        document.getElementById("JabberIMRoster").innerHTML = ""; 
     1458                 
     1459        TrophyIM.renderRoster(); 
    13561460         
    1357         setTimeout(function() 
    1358         { 
    1359                 for( var i in presence ) 
    1360                 { 
    1361                         if ( presence[ i ].constructor == Function ) 
    1362                                 continue; 
     1461        setTimeout(function() 
     1462        { 
     1463            for( var i in presence ) 
     1464            { 
     1465                if ( presence[ i ].constructor == Function ) 
     1466                    continue; 
    13631467                                 
    1364                         TrophyIM.rosterObj.setPresence( jid, presence[i].priority, presence[i].show, presence[i].status); 
    1365                 } 
    1366         },500); 
     1468                TrophyIM.rosterObj.setPresence( jid, presence[i].priority, presence[i].show, presence[i].status); 
     1469            } 
     1470        },500); 
    13671471    }, 
    13681472 
     
    13741478    createChatRooms : function() 
    13751479    { 
    1376         var nickName     = document.getElementById('nickName_chatRoom_jabberit').value; 
    1377         var nameChatRoom = document.getElementById('name_ChatRoom_jabberit').value;  
     1480        var nickName     = document.getElementById('nickName_chatRoom_jabberit').value; 
     1481        var nameChatRoom = document.getElementById('name_ChatRoom_jabberit').value;  
    13781482         
    1379         var _from               = Base64.decode( loadscript.getUserCurrent().jid ) + TROPHYIM_RESOURCE;  
    1380                 var _to                 = escape( nameChatRoom ) + "@" + TROPHYIM_CHATROOM + "/" + nickName ; 
    1381                 var new_room    = $pres( {from: _from, to: _to } ).c( "x", { xmlns: Strophe.NS.MUC } ); 
    1382  
    1383                 TrophyIM.activeChatRoom.name[ TrophyIM.activeChatRoom.name.length ] = _to;  
    1384                  
    1385                 TrophyIM.connection.send( new_room.tree() ); 
     1483        var _from       = Base64.decode( loadscript.getUserCurrent().jid ) + TROPHYIM_RESOURCE;  
     1484        var _to         = escape( nameChatRoom ) + "@" + TROPHYIM_CHATROOM + "/" + nickName ; 
     1485        var new_room    = $pres( { 
     1486            from: _from,  
     1487            to: _to 
     1488        } ).c( "x", { 
     1489            xmlns: Strophe.NS.MUC 
     1490            } ); 
     1491 
     1492        TrophyIM.activeChatRoom.name[ TrophyIM.activeChatRoom.name.length ] = _to;  
     1493                 
     1494        TrophyIM.connection.send( new_room.tree() ); 
    13861495    }, 
    13871496     
     
    13931502    joinChatRoom : function( roomName ) 
    13941503    { 
    1395         var presence = $pres( {from: TrophyIM.connection.jid, to: roomName} ).c("x",{xmlns: Strophe.NS.MUC}); 
     1504        var presence = $pres( { 
     1505            from: TrophyIM.connection.jid,  
     1506            to: roomName 
     1507        } ).c("x",{ 
     1508            xmlns: Strophe.NS.MUC 
     1509            }); 
    13961510         
    1397                 TrophyIM.connection.send( presence ); 
     1511        TrophyIM.connection.send( presence ); 
    13981512    }, 
    13991513     
     
    14051519    leaveChatRoom : function( roomName ) 
    14061520    { 
    1407         var room_nick   = roomName; 
     1521        var room_nick   = roomName; 
    14081522         
    14091523        var presenceid  = TrophyIM.connection.getUniqueId(); 
    14101524         
    1411         var presence    = $pres( {type: "unavailable", id: presenceid, from: TrophyIM.connection.jid, to: room_nick} ).c("x",{xmlns: Strophe.NS.MUC}); 
     1525        var presence    = $pres( { 
     1526            type: "unavailable",  
     1527            id: presenceid,  
     1528            from: TrophyIM.connection.jid,  
     1529            to: room_nick 
     1530        } ).c("x",{ 
     1531            xmlns: Strophe.NS.MUC 
     1532            }); 
    14121533         
    14131534        TrophyIM.connection.send( presence );         
     
    14211542    getListRooms : function() 
    14221543    { 
    1423         if( TrophyIM.statusConn.connected ) 
    1424         { 
    1425                 var _error_return = function(element) 
    1426                 { 
    1427                         alert("ERRO : Tente novamente !"); 
    1428                 }; 
     1544        if( TrophyIM.statusConn.connected ) 
     1545        { 
     1546            var _error_return = function(element) 
     1547            { 
     1548                alert("ERRO : Tente novamente !"); 
     1549            }; 
    14291550                 
    1430                         var iq = $iq({ to: TROPHYIM_CHATROOM, type: "get" }).c("query",{xmlns: Strophe.NS.DISCO_ITEMS });                
     1551            var iq = $iq({ 
     1552                to: TROPHYIM_CHATROOM,  
     1553                type: "get" 
     1554            }).c("query",{ 
     1555                xmlns: Strophe.NS.DISCO_ITEMS 
     1556                });              
    14311557                         
    1432                 TrophyIM.connection.sendIQ( iq, loadscript.listRooms, _error_return, 500 ); 
    1433         } 
    1434         else 
    1435         { 
    1436                 alert( "ERRO : Sem conexão com o servidor " + TROPHYIM_CHATROOM ); 
    1437         } 
     1558            TrophyIM.connection.sendIQ( iq, loadscript.listRooms, _error_return, 500 ); 
     1559        } 
     1560        else 
     1561        { 
     1562            alert( "ERRO : Sem conexão com o servidor " + TROPHYIM_CHATROOM ); 
     1563        } 
    14381564    }, 
    14391565     
     
    14461572    removeContact : function( jidTo ) 
    14471573    { 
    1448         var divItenContact       = null; 
    1449  
    1450         if( ( divItenContact = document.getElementById('itenContact_' + jidTo ))) 
    1451         {        
    1452                 // Remove Contact 
    1453                 var _id = TrophyIM.connection.getUniqueId();     
     1574        var divItenContact       = null; 
     1575 
     1576        if( ( divItenContact = document.getElementById('itenContact_' + jidTo ))) 
     1577        {        
     1578            // Remove Contact 
     1579            var _id     = TrophyIM.connection.getUniqueId();     
    14541580                 
    1455                 // Controller Result 
    1456                 TrophyIM.removeResult.idResult[ TrophyIM.removeResult.idResult.length ] = jidTo; 
    1457  
    1458                 var delContact  = $iq({type: 'set', id: _id}) 
    1459                         delContact      = delContact.c('query').attrs({xmlns : 'jabber:iq:roster'}); 
    1460                         delContact      = delContact.c('item').attrs({jid: jidTo, subscription:'remove'}).tree(); 
    1461  
    1462                 TrophyIM.connection.send( delContact ); 
     1581            // Controller Result 
     1582            TrophyIM.removeResult.idResult[ TrophyIM.removeResult.idResult.length ] = jidTo; 
     1583 
     1584            var delContact      = $iq({ 
     1585                type: 'set',  
     1586                id: _id 
     1587            }) 
     1588            delContact  = delContact.c('query').attrs({ 
     1589                xmlns : 'jabber:iq:roster' 
     1590            }); 
     1591            delContact  = delContact.c('item').attrs({ 
     1592                jid: jidTo,  
     1593                subscription:'remove' 
     1594            }).tree(); 
     1595 
     1596            TrophyIM.connection.send( delContact ); 
    14631597                 
    1464                         loadscript.removeElement( document.getElementById('itenContactNotification_' + jidTo ) ); 
     1598            loadscript.removeElement( document.getElementById('itenContactNotification_' + jidTo ) ); 
    14651599                 
    1466                 var spanShow = document.getElementById('span_show_itenContact_' + jidTo ) 
    1467                         spanShow.parentNode.removeChild(spanShow); 
     1600            var spanShow = document.getElementById('span_show_itenContact_' + jidTo ) 
     1601            spanShow.parentNode.removeChild(spanShow); 
    14681602                 
    1469                 loadscript.removeGroup( divItenContact.parentNode ); 
     1603            loadscript.removeGroup( divItenContact.parentNode ); 
    14701604                 
    1471                 divItenContact.parentNode.removeChild(divItenContact); 
    1472         } 
     1605            divItenContact.parentNode.removeChild(divItenContact); 
     1606        } 
    14731607    }, 
    14741608     
     
    14791613     */ 
    14801614     
    1481         renderRoster : function() 
    1482         { 
    1483                 var roster_div = document.getElementById('JabberIMRoster'); 
    1484                  
    1485                 if( roster_div ) 
    1486                 { 
    1487                         var users = new Array(); 
    1488                          
    1489                         var loading_gif = document.getElementById("JabberIMRosterLoadingGif"); 
    1490                          
    1491                         if( loading_gif.style.display == "block" ) 
    1492                                 loading_gif.style.display = "none"; 
     1615    renderRoster : function() 
     1616    { 
     1617        var roster_div = document.getElementById('JabberIMRoster'); 
     1618                 
     1619        if( roster_div ) 
     1620        { 
     1621            var users = new Array(); 
     1622                         
     1623            var loading_gif = document.getElementById("JabberIMRosterLoadingGif"); 
     1624                         
     1625            if( loading_gif.style.display == "block" ) 
     1626                loading_gif.style.display = "none"; 
    14931627                                 
    1494                         for( var user in TrophyIM.rosterObj.roster ) 
    1495                         { 
    1496                                 if ( TrophyIM.rosterObj.roster[ user ].constructor == Function ) 
    1497                                         continue; 
    1498  
    1499                                 users[users.length] = TrophyIM.rosterObj.roster[user].contact.jid; 
    1500                         } 
    1501  
    1502                         users.sort(); 
    1503                          
    1504                         var groups              = new Array(); 
    1505                         var flagGeral   = false; 
    1506                          
    1507                         for (var group in TrophyIM.rosterObj.groups) 
    1508                         { 
    1509                                 if ( TrophyIM.rosterObj.groups[ group ].constructor == Function ) 
    1510                                         continue; 
     1628            for( var user in TrophyIM.rosterObj.roster ) 
     1629            { 
     1630                if ( TrophyIM.rosterObj.roster[ user ].constructor == Function ) 
     1631                    continue; 
     1632 
     1633                users[users.length] = TrophyIM.rosterObj.roster[user].contact.jid; 
     1634            } 
     1635 
     1636            users.sort(); 
     1637                         
     1638            var groups          = new Array(); 
     1639            var flagGeral       = false; 
     1640                         
     1641            for (var group in TrophyIM.rosterObj.groups) 
     1642            { 
     1643                if ( TrophyIM.rosterObj.groups[ group ].constructor == Function ) 
     1644                    continue; 
    15111645                                 
    1512                                 if( group ) 
    1513                                         groups[groups.length] = group; 
     1646                if( group ) 
     1647                    groups[groups.length] = group; 
    15141648                                 
    1515                                 if( group == "Geral" ) 
    1516                                         flagGeral = true; 
     1649                if( group == "Geral" ) 
     1650                    flagGeral = true; 
    15171651            } 
    15181652             
    1519                         if( !flagGeral && users.length > 0 ) 
    1520                                 groups[groups.length] = "Geral"; 
     1653            if( !flagGeral && users.length > 0 ) 
     1654                groups[groups.length] = "Geral"; 
    15211655                                 
    1522                         groups.sort(); 
    1523                          
    1524                         for ( var i = 0; i < groups.length; i++ ) 
    1525                         { 
    1526                                 TrophyIM.renderGroups( groups[i] , roster_div );         
    1527                         } 
    1528                          
    1529                         TrophyIM.renderItensGroup( users, roster_div ); 
    1530                 } 
    1531                          
    1532                 TrophyIM._timeOut.renderRoster = setTimeout("TrophyIM.renderRoster()", 1000 );           
    1533         }, 
     1656            groups.sort(); 
     1657                         
     1658            for ( var i = 0; i < groups.length; i++ ) 
     1659            { 
     1660                TrophyIM.renderGroups( groups[i] , roster_div );         
     1661            } 
     1662                         
     1663            TrophyIM.renderItensGroup( users, roster_div ); 
     1664        } 
     1665                         
     1666        TrophyIM._timeOut.renderRoster = setTimeout("TrophyIM.renderRoster()", 1000 );           
     1667    }, 
    15341668         
    15351669    /** Function: renderGroups 
     
    15381672     */ 
    15391673         
    1540         renderGroups: function( nameGroup, element ) 
    1541         { 
    1542                 var _addGroup = function() 
    1543                 { 
    1544                         var _nameGroup  = nameGroup; 
    1545                         var _element    = element; 
    1546  
    1547                         var paramsGroup =  
    1548                         { 
    1549                                 'nameGroup'     : _nameGroup, 
    1550                                 'path_jabberit' : path_jabberit 
    1551                         } 
    1552                          
    1553                         _element.innerHTML += loadscript.parse("group","groups.xsl", paramsGroup); 
    1554                 } 
    1555  
    1556                 if( !element.hasChildNodes() ) 
    1557                 { 
    1558                         _addGroup(); 
    1559                 } 
    1560                 else 
    1561                 { 
    1562                         var _NodeChild  = element.firstChild; 
    1563                         var flagAdd             = false; 
    1564                          
    1565                         while( _NodeChild ) 
    1566                         { 
    1567                                 if( _NodeChild.childNodes[0].nodeName.toLowerCase() === "span" ) 
    1568                                 { 
    1569                                         if( _NodeChild.childNodes[0].childNodes[0].nodeValue === nameGroup ) 
    1570                                         { 
    1571                                                 flagAdd = true; 
    1572                                         } 
    1573                                 } 
     1674    renderGroups: function( nameGroup, element ) 
     1675    { 
     1676        var _addGroup = function() 
     1677        { 
     1678            var _nameGroup      = nameGroup; 
     1679            var _element        = element; 
     1680 
     1681            var paramsGroup =  
     1682            { 
     1683                'nameGroup'     : _nameGroup, 
     1684                'path_jabberit' : path_jabberit 
     1685            } 
     1686                         
     1687            _element.innerHTML += loadscript.parse("group","groups.xsl", paramsGroup); 
     1688        } 
     1689 
     1690        if( !element.hasChildNodes() ) 
     1691        { 
     1692            _addGroup(); 
     1693        } 
     1694        else 
     1695        { 
     1696            var _NodeChild      = element.firstChild; 
     1697            var flagAdd         = false; 
     1698                         
     1699            while( _NodeChild ) 
     1700            { 
     1701                if( _NodeChild.childNodes[0].nodeName.toLowerCase() === "span" ) 
     1702                { 
     1703                    if( _NodeChild.childNodes[0].childNodes[0].nodeValue === nameGroup ) 
     1704                    { 
     1705                        flagAdd = true; 
     1706                    } 
     1707                } 
    15741708                                 
    1575                                 _NodeChild = _NodeChild.nextSibling; 
    1576                         } 
    1577  
    1578                         if( !flagAdd ) 
    1579                         { 
    1580                                 _addGroup(); 
    1581                         } 
    1582                 } 
    1583         }, 
     1709                _NodeChild = _NodeChild.nextSibling; 
     1710            } 
     1711 
     1712            if( !flagAdd ) 
     1713            { 
     1714                _addGroup(); 
     1715            } 
     1716        } 
     1717    }, 
    15841718 
    15851719    /** Function: renderItensGroup 
     
    15881722     */ 
    15891723 
    1590         renderItensGroup : function( users, element ) 
    1591         { 
    1592                 var addItem = function() 
    1593                 { 
    1594                         if( arguments.length > 0 ) 
    1595                         { 
    1596                                 // Get Arguments 
    1597                                 var objContact  = arguments[0]; 
    1598                                 var group               = arguments[1]; 
    1599                                 var element             = arguments[2]; 
    1600                                 var showOffline = loadscript.getShowContactsOffline(); 
     1724    renderItensGroup : function( users, element ) 
     1725    { 
     1726        var addItem = function() 
     1727        { 
     1728            if( arguments.length > 0 ) 
     1729            { 
     1730                // Get Arguments 
     1731                var objContact  = arguments[0]; 
     1732                var group               = arguments[1]; 
     1733                var element             = arguments[2]; 
     1734                var showOffline = loadscript.getShowContactsOffline(); 
    16011735                                 
    1602                                 // Presence e Status 
    1603                                 var presence            = "unavailable"; 
    1604                                 var status                      = ""; 
    1605                                 var statusColor         = "black"; 
    1606                                 var statusDisplay       = "none"; 
     1736                // Presence e Status 
     1737                var presence            = "unavailable"; 
     1738                var status                      = ""; 
     1739                var statusColor         = "black"; 
     1740                var statusDisplay       = "none"; 
    16071741                                 
    1608                                 var _resource   = ""; 
     1742                var _resource   = ""; 
    16091743                                 
    1610                                 // Set Presence  
    1611                                 var _presence = function(objContact) 
    1612                                 { 
    1613                                         if (objContact.presence) 
    1614                                         { 
    1615                                                 for (var resource in objContact.presence) 
    1616                                                 { 
    1617                                                         if ( objContact.presence[resource].constructor == Function ) 
    1618                                                                 continue; 
    1619  
    1620                                                         if( objContact.presence[resource].show != 'invisible' ) 
    1621                                                                 presence = objContact.presence[resource].show; 
    1622  
    1623                                                         if( objContact.contact.subscription != "both")  
    1624                                                                 presence = 'subscription'; 
     1744                // Set Presence  
     1745                var _presence = function(objContact) 
     1746                { 
     1747                    if (objContact.presence) 
     1748                    { 
     1749                        for (var resource in objContact.presence) 
     1750                        { 
     1751                            if ( objContact.presence[resource].constructor == Function ) 
     1752                                continue; 
     1753 
     1754                            if( objContact.presence[resource].show != 'invisible' ) 
     1755                                presence = objContact.presence[resource].show; 
     1756 
     1757                            if( objContact.contact.subscription != "both")  
     1758                                presence = 'subscription'; 
    16251759                                                         
    1626                                                         if( objContact.presence[resource].status ) 
    1627                                                         { 
    1628                                                                 status = " ( " + objContact.presence[resource].status + " ) "; 
    1629                                                                 statusDisplay   = "block"; 
    1630                                                         } 
    1631                                                 } 
    1632                                         } 
    1633                                 }; 
     1760                            if( objContact.presence[resource].status ) 
     1761                            { 
     1762                                status = " ( " + objContact.presence[resource].status + " ) "; 
     1763                                statusDisplay   = "block"; 
     1764                            } 
     1765                        } 
     1766                    } 
     1767                }; 
    16341768                                 
    1635                                 // Set Subscription 
    1636                                 var _subscription = function( objContact ) 
    1637                                 { 
    1638                                         if( objContact.contact.subscription != "both" ) 
    1639                                         { 
    1640                                                 switch( objContact.contact.subscription ) 
    1641                                                 { 
    1642                                                         case "none" : 
     1769                // Set Subscription 
     1770                var _subscription = function( objContact ) 
     1771                { 
     1772                    if( objContact.contact.subscription != "both" ) 
     1773                    { 
     1774                        switch( objContact.contact.subscription ) 
     1775                        { 
     1776                            case "none" : 
    16431777                                                                 
    1644                                                                 status          = " (( " + i18n.ASK_FOR_AUTH  + " )) "; 
    1645                                                                 statusColor     = "red"; 
    1646                                                                 break; 
    1647          
    1648                                                         case "to" : 
     1778                                status          = " (( " + i18n.ASK_FOR_AUTH  + " )) "; 
     1779                                statusColor     = "red"; 
     1780                                break; 
     1781         
     1782                            case "to" : 
    16491783                                                                 
    1650                                                                 status          = " (( " + i18n.CONTACT_ASK_FOR_AUTH  + " )) "; 
    1651                                                                 statusColor     = "orange"; 
    1652                                                                 break; 
    1653          
    1654                                                         case "from" : 
     1784                                status          = " (( " + i18n.CONTACT_ASK_FOR_AUTH  + " )) "; 
     1785                                statusColor     = "orange"; 
     1786                                break; 
     1787         
     1788                            case "from" : 
    16551789                                                                 
    1656                                                                 status          = " (( " + i18n.AUTHORIZED + " )) "; 
    1657                                                                 statusColor = "green"; 
    1658                                                                 break; 
     1790                                status          = " (( " + i18n.AUTHORIZED + " )) "; 
     1791                                statusColor = "green"; 
     1792                                break; 
    16591793                                                                 
    1660                                                         case "subscribe" :  
     1794                            case "subscribe" : 
    16611795                                                                 
    1662                                                                 status          = " (( " + i18n.AUTH_SENT  + " )) "; 
    1663                                                                 statusColor     = "red";         
    1664                                                                 break; 
    1665  
    1666                                                         case "not-in-roster" : 
     1796                                status          = " (( " + i18n.AUTH_SENT  + " )) "; 
     1797                                statusColor     = "red";         
     1798                                break; 
     1799 
     1800                            case "not-in-roster" : 
    16671801                                                                 
    1668                                                                 status          = " (( " + i18n.ASK_FOR_AUTH_QUESTION  + " )) "; 
    1669                                                                 statusColor     = "orange";      
    1670                                                                 break; 
     1802                                status          = " (( " + i18n.ASK_FOR_AUTH_QUESTION  + " )) "; 
     1803                                statusColor     = "orange";      
     1804                                break; 
    16711805                                                                 
    1672                                                         default : 
     1806                            default : 
    16731807                                                                 
    1674                                                                 break; 
    1675                                                 } 
    1676  
    1677                                                 statusDisplay = "block"; 
    1678                                         } 
    1679                                 }; 
    1680  
    1681                                 if( objContact.contact.subscription != "remove") 
    1682                                 { 
    1683                                         var itensJid    = document.getElementById( "itenContact_" + objContact.contact.jid ); 
     1808                                break; 
     1809                        } 
     1810 
     1811                        statusDisplay = "block"; 
     1812                    } 
     1813                }; 
     1814 
     1815                if( objContact.contact.subscription != "remove") 
     1816                { 
     1817                    var itensJid        = document.getElementById( "itenContact_" + objContact.contact.jid ); 
    16841818                                         
    1685                                         if( itensJid == null ) 
    1686                                         { 
    1687                                                 // Name 
    1688                                                 var nameContact = "";                                    
     1819                    if( itensJid == null ) 
     1820                    { 
     1821                        // Name 
     1822                        var nameContact = "";                                    
    16891823                                                 
    1690                                                 if ( objContact.contact.name )  
    1691                                                         nameContact = objContact.contact.name; 
    1692                                                 else 
    1693                                                 { 
    1694                                                         nameContact = objContact.contact.jid; 
    1695                                                         nameContact = nameContact.substring(0, nameContact.indexOf('@')); 
    1696                                                 } 
     1824                        if ( objContact.contact.name )  
     1825                            nameContact = objContact.contact.name; 
     1826                        else 
     1827                        { 
     1828                            nameContact = objContact.contact.jid; 
     1829                            nameContact = nameContact.substring(0, nameContact.indexOf('@')); 
     1830                        } 
    16971831                                                 
    1698                                                 // Get Presence 
    1699                                                 _presence(objContact); 
     1832                        // Get Presence 
     1833                        _presence(objContact); 
    17001834                                                 
    1701                                                 var paramsContact = 
    1702                                                 { 
    1703                                                         divDisplay              : "block",  
    1704                                                         id                              : 'itenContact_' + objContact.contact.jid , 
    1705                                                         jid                             : objContact.contact.jid, 
    1706                                                         nameContact     : nameContact, 
    1707                                                         path_jabberit   : path_jabberit, 
    1708                                                         presence                : presence, 
    1709                                                         spanDisplay             : statusDisplay, 
    1710                                                         status                  : status, 
    1711                                                         statusColor             : "black", 
    1712                                                         subscription    : objContact.contact.subscription, 
    1713                                                         resource                : _resource 
    1714                                                 } 
     1835                        var paramsContact = 
     1836                        { 
     1837                            divDisplay          : "block",  
     1838                            id                          : 'itenContact_' + objContact.contact.jid , 
     1839                            jid                         : objContact.contact.jid, 
     1840                            nameContact         : nameContact, 
     1841                            path_jabberit       : path_jabberit, 
     1842                            presence            : presence, 
     1843                            spanDisplay         : statusDisplay, 
     1844                            status                      : status, 
     1845                            statusColor         : "black", 
     1846                            subscription        : objContact.contact.subscription, 
     1847                            resource            : _resource 
     1848                        } 
    17151849                                                 
    1716                                                 // Get Authorization 
    1717                                                 _subscription( objContact ); 
     1850                        // Get Authorization 
     1851                        _subscription( objContact ); 
    17181852                                                 
    1719                                                 if( group != "") 
    1720                                                 { 
    1721                                                         var _NodeChild          = element.firstChild; 
     1853                        if( group != "") 
     1854                        { 
     1855                            var _NodeChild              = element.firstChild; 
    17221856                                                         
    1723                                                         while( _NodeChild ) 
    1724                                                         { 
    1725                                                                 if( _NodeChild.childNodes[0].nodeName.toLowerCase() === "span" ) 
    1726                                                                 { 
    1727                                                                         if( _NodeChild.childNodes[0].childNodes[0].nodeValue === group ) 
    1728                                                                         { 
    1729                                                                                 _NodeChild.innerHTML += loadscript.parse("itens_group", "itensGroup.xsl", paramsContact); 
    1730                                                                         } 
    1731                                                                 } 
    1732          
    1733                                                                 _NodeChild = _NodeChild.nextSibling; 
    1734                                                         } 
    1735                                                 }        
    1736                                         } 
    1737                                         else 
    1738                                         { 
    1739                                                 // Get Presence 
    1740                                                 _presence(objContact); 
    1741          
    1742                                                 var is_open = itensJid.parentNode.childNodes[0].style.backgroundImage;   
    1743                                                         is_open = is_open.indexOf("arrow_down.gif"); 
    1744          
    1745                                                 // Get Authorization 
    1746                                                 _subscription( objContact ); 
     1857                            while( _NodeChild ) 
     1858                            { 
     1859                                if( _NodeChild.childNodes[0].nodeName.toLowerCase() === "span" ) 
     1860                                { 
     1861                                    if( _NodeChild.childNodes[0].childNodes[0].nodeValue === group ) 
     1862                                    { 
     1863                                        _NodeChild.innerHTML += loadscript.parse("itens_group", "itensGroup.xsl", paramsContact); 
     1864                                    } 
     1865                                } 
     1866         
     1867                                _NodeChild = _NodeChild.nextSibling; 
     1868                            } 
     1869                        }        
     1870                    } 
     1871                    else 
     1872                    { 
     1873                        // Get Presence 
     1874                        _presence(objContact); 
     1875         
     1876                        var is_open = itensJid.parentNode.childNodes[0].style.backgroundImage;   
     1877                        is_open = is_open.indexOf("arrow_down.gif"); 
     1878         
     1879                        // Get Authorization 
     1880                        _subscription( objContact ); 
    17471881                                                 
    1748                                                 // Set subscription 
    1749                                                 itensJid.setAttribute('subscription', objContact.contact.subscription ); 
     1882                        // Set subscription 
     1883                        itensJid.setAttribute('subscription', objContact.contact.subscription ); 
    17501884                                                 
    1751                                                 with ( document.getElementById('span_show_' + 'itenContact_' + objContact.contact.jid ) ) 
    1752                                                 { 
    1753                                                         if( presence == "unavailable" && !showOffline ) 
    1754                                                         { 
    1755                                                                 style.display = "none"; 
    1756                                                         } 
    1757                                                         else 
    1758                                                         { 
    1759                                                                 if( is_open > 0 ) 
    1760                                                                 { 
    1761                                                                         style.display   = statusDisplay; 
    1762                                                                         style.color             = statusColor; 
    1763                                                                         innerHTML               = status; 
    1764                                                                 } 
    1765                                                         } 
    1766                                                 } 
     1885                        with ( document.getElementById('span_show_' + 'itenContact_' + objContact.contact.jid ) ) 
     1886                        { 
     1887                            if( presence == "unavailable" && !showOffline ) 
     1888                            { 
     1889                                style.display = "none"; 
     1890                            } 
     1891                            else 
     1892                            { 
     1893                                if( is_open > 0 ) 
     1894                                { 
     1895                                    style.display       = statusDisplay; 
     1896                                    style.color         = statusColor; 
     1897                                    innerHTML           = status; 
     1898                                } 
     1899                            } 
     1900                            } 
    17671901                                                 
    1768                                                 if( presence == "unavailable" && !showOffline ) 
    1769                                                 { 
    1770                                                         itensJid.style.display = "none"; 
    1771                                                 } 
    1772                                                 else 
    1773                                                 { 
    1774                                                         if( is_open > 0 ) 
    1775                                                         { 
    1776                                                                 itensJid.style.display = "block"; 
    1777                                                         } 
    1778                                                 } 
     1902                        if( presence == "unavailable" && !showOffline ) 
     1903                        { 
     1904                            itensJid.style.display = "none"; 
     1905                        } 
     1906                        else 
     1907                        { 
     1908                            if( is_open > 0 ) 
     1909                            { 
     1910                                itensJid.style.display = "block"; 
     1911                            } 
     1912                        } 
    17791913                                                 
    1780                                                 itensJid.style.background       = "url('"+path_jabberit+"templates/default/images/" + presence + ".gif') no-repeat center left"; 
    1781                                         } 
    1782          
    1783                                         // Contact OffLine 
    1784                                         if( !objContact.presence && !showOffline ) 
    1785                                         { 
    1786                                                 if( objContact.contact.subscription != "remove" ) 
    1787                                                 { 
    1788                                                         with ( document.getElementById('span_show_' + 'itenContact_' + objContact.contact.jid )) 
    1789                                                         { 
    1790                                                                 style.display   = "none"; 
    1791                                                         } 
    1792                  
    1793                                                         with ( document.getElementById('itenContact_' + objContact.contact.jid ) ) 
    1794                                                         { 
    1795                                                                 style.display   = "none"; 
    1796                                                         } 
    1797                                                 } 
    1798                                         } 
    1799                                 } 
    1800                         } 
    1801                 }; 
    1802                  
    1803                 var flag = false; 
    1804                  
    1805                 for( var i = 0 ; i < users.length; i++ ) 
    1806                 { 
    1807                         if( TrophyIM.rosterObj.roster[users[i]].contact.jid != Base64.decode( loadscript.getUserCurrent().jid) ) 
    1808                         { 
    1809                                 var _subscription = TrophyIM.rosterObj.roster[users[i]].contact.subscription; 
     1914                        itensJid.style.background       = "url('"+path_jabberit+"templates/default/images/" + presence + ".gif') no-repeat center left"; 
     1915                    } 
     1916         
     1917                    // Contact OffLine 
     1918                    if( !objContact.presence && !showOffline ) 
     1919                    { 
     1920                        if( objContact.contact.subscription != "remove" ) 
     1921                        { 
     1922                            with ( document.getElementById('span_show_' + 'itenContact_' + objContact.contact.jid )) 
     1923                            { 
     1924                                style.display   = "none"; 
     1925                                } 
     1926                 
     1927                            with ( document.getElementById('itenContact_' + objContact.contact.jid ) ) 
     1928                            { 
     1929                                style.display   = "none"; 
     1930                                } 
     1931                        } 
     1932                    } 
     1933                } 
     1934            } 
     1935        }; 
     1936                 
     1937        var flag = false; 
     1938                 
     1939        for( var i = 0 ; i < users.length; i++ ) 
     1940        { 
     1941            if( TrophyIM.rosterObj.roster[users[i]].contact.jid != Base64.decode( loadscript.getUserCurrent().jid) ) 
     1942            { 
     1943                var _subscription = TrophyIM.rosterObj.roster[users[i]].contact.subscription; 
    18101944                                 
    1811                                 if( _subscription === "to" ) 
    1812                                 { 
    1813                                         flag = true; 
    1814                                 } 
     1945                if( _subscription === "to" ) 
     1946                { 
     1947                    flag = true; 
     1948                } 
    18151949                                 
    1816                                 if(  _subscription === "not-in-roster") 
    1817                                 { 
    1818                                         flag = true; 
    1819                                 } 
     1950                if(  _subscription === "not-in-roster") 
     1951                { 
     1952                    flag = true; 
     1953                } 
    18201954                                 
    1821                                 if( TrophyIM.rosterObj.roster[users[i]].contact.groups ) 
    1822                                 { 
    1823                                         var groups = TrophyIM.rosterObj.roster[users[i]].contact.groups; 
     1955                if( TrophyIM.rosterObj.roster[users[i]].contact.groups ) 
     1956                { 
     1957                    var groups = TrophyIM.rosterObj.roster[users[i]].contact.groups; 
    18241958                                         
    1825                                         if( groups.length > 0 ) 
    1826                                         { 
    1827                                                 for( var j = 0; j < groups.length; j++ ) 
    1828                                                 { 
    1829                                                         addItem( TrophyIM.rosterObj.roster[users[i]], groups[j], element ); 
    1830                                                 } 
    1831                                         } 
    1832                                         else 
    1833                                         { 
    1834                                                 addItem( TrophyIM.rosterObj.roster[users[i]], "Geral", element ); 
    1835                                         } 
    1836                                 } 
    1837                                 else 
    1838                                 { 
    1839                                         addItem( TrophyIM.rosterObj.roster[users[i]], "Geral", element ); 
    1840                                 } 
    1841                         } 
    1842                 } 
    1843                  
    1844                 if( flag ) 
    1845                 { 
    1846                         if ( TrophyIM.controll.notificationNewUsers == 0 ) 
    1847                         { 
    1848                                 loadscript.enabledNotificationNewUsers(); 
    1849                                 TrophyIM.controll.notificationNewUsers++; 
    1850                         } 
    1851                 } 
    1852                 else 
    1853                 { 
    1854                         loadscript.disabledNotificationNewUsers(); 
    1855                         TrophyIM.controll.notificationNewUsers = 0; 
    1856                 } 
    1857         }, 
     1959                    if( groups.length > 0 ) 
     1960                    { 
     1961                        for( var j = 0; j < groups.length; j++ ) 
     1962                        { 
     1963                            addItem( TrophyIM.rosterObj.roster[users[i]], groups[j], element ); 
     1964                        } 
     1965                    } 
     1966                    else 
     1967                    { 
     1968                        addItem( TrophyIM.rosterObj.roster[users[i]], "Geral", element ); 
     1969                    } 
     1970                } 
     1971                else 
     1972                { 
     1973                    addItem( TrophyIM.rosterObj.roster[users[i]], "Geral", element ); 
     1974                } 
     1975            } 
     1976        } 
     1977                 
     1978        if( flag ) 
     1979        { 
     1980            if ( TrophyIM.controll.notificationNewUsers == 0 ) 
     1981            { 
     1982                loadscript.enabledNotificationNewUsers(); 
     1983                TrophyIM.controll.notificationNewUsers++; 
     1984            } 
     1985        } 
     1986        else 
     1987        { 
     1988            loadscript.disabledNotificationNewUsers(); 
     1989            TrophyIM.controll.notificationNewUsers = 0; 
     1990        } 
     1991    }, 
    18581992 
    18591993    /** Function: rosterClick 
     
    18621996     */ 
    18631997     
    1864         rosterClick : function(fulljid) 
    1865         { 
     1998    rosterClick : function(fulljid) 
     1999    { 
    18662000        TrophyIM.makeChat(fulljid); 
    18672001    }, 
    18682002 
    1869         /** Function SetAutorization 
     2003    /** Function SetAutorization 
    18702004         *  
    18712005         */ 
    18722006 
    1873         setAutorization : function( jidTo, jidFrom, _typeSubscription ) 
    1874         { 
    1875         var _id = TrophyIM.connection.getUniqueId(); 
     2007    setAutorization : function( jidTo, jidFrom, _typeSubscription ) 
     2008    { 
     2009        var _id = TrophyIM.connection.getUniqueId(); 
    18762010         
    1877         TrophyIM.connection.send($pres( ).attrs({ from: jidFrom, to: jidTo, type: _typeSubscription, id: _id }).tree()); 
    1878         }, 
    1879  
    1880         /** Function: setPresence 
    1881      * 
    1882      */ 
    1883  
    1884         setPresence : function( _type ) 
    1885         { 
    1886                 var presence_chatRoom = ""; 
    1887                  
    1888                 if( _type != 'status') 
    1889                 { 
    1890                         if( _type == "unavailable" &&  TrophyIM.statusConn.connected ) 
    1891                         { 
    1892                                 var loading_gif = document.getElementById("JabberIMRosterLoadingGif"); 
     2011        TrophyIM.connection.send($pres( ).attrs({ 
     2012            from: jidFrom,  
     2013            to: jidTo,  
     2014            type: _typeSubscription,  
     2015            id: _id 
     2016        }).tree()); 
     2017    }, 
     2018 
     2019    /** Function: setPresence 
     2020     * 
     2021     */ 
     2022 
     2023    setPresence : function( _type ) 
     2024    { 
     2025        var presence_chatRoom = ""; 
     2026                 
     2027        if( _type != 'status') 
     2028        { 
     2029            if( _type == "unavailable" &&  TrophyIM.statusConn.connected ) 
     2030            { 
     2031                var loading_gif = document.getElementById("JabberIMRosterLoadingGif"); 
    18932032                                 
    1894                                 if( TrophyIM._timeOut.renderRoster != null ) 
    1895                                         clearTimeout(TrophyIM._timeOut.renderRoster); 
     2033                if( TrophyIM._timeOut.renderRoster != null ) 
     2034                    clearTimeout(TrophyIM._timeOut.renderRoster); 
    18962035                                 
    1897                                 if( TrophyIM.statusConn.connected ) 
    1898                                         TrophyIM.connection.send($pres({type : _type}).tree()); 
     2036                if( TrophyIM.statusConn.connected ) 
     2037                    TrophyIM.connection.send($pres({ 
     2038                        type : _type 
     2039                    }).tree()); 
    18992040                                 
    1900                                 for( var i = 0; i < TrophyIM.connection._requests.length; i++ ) 
    1901                         { 
    1902                                 if( TrophyIM.connection._requests[i] ) 
    1903                                         TrophyIM.connection._removeRequest(TrophyIM.connection._requests[i]); 
    1904                         } 
     2041                for( var i = 0; i < TrophyIM.connection._requests.length; i++ ) 
     2042                { 
     2043                    if( TrophyIM.connection._requests[i] ) 
     2044                        TrophyIM.connection._removeRequest(TrophyIM.connection._requests[i]); 
     2045                } 
    19052046                                 
    1906                                 TrophyIM.logout(); 
     2047                TrophyIM.logout(); 
    19072048                                 
    1908                         loadscript.clrAllContacts(); 
     2049                loadscript.clrAllContacts(); 
    19092050                         
    1910                         delete TrophyIM.rosterObj.roster; 
    1911                         delete TrophyIM.rosterObj.groups; 
     2051                delete TrophyIM.rosterObj.roster; 
     2052                delete TrophyIM.rosterObj.groups; 
    19122053                         
    1913                         setTimeout(function() 
    1914                         { 
    1915                                         if( loading_gif.style.display == "block" ) 
    1916                                                 loading_gif.style.display = "none"; 
    1917                         }, 1000); 
    1918                         } 
    1919                         else 
    1920                         { 
    1921                                 if( !TrophyIM.autoConnection.connect ) 
    1922                                 { 
    1923                                         TrophyIM.autoConnection.connect = true; 
    1924                                         TrophyIM.load(); 
    1925                                 } 
    1926                                 else 
    1927                                 { 
    1928                                         if( TrophyIM.statusConn.connected ) 
    1929                                         { 
    1930                                                 if( loadscript.getStatusMessage() != "" ) 
    1931                                                 { 
    1932                                                         var _presence = $pres( ); 
    1933                                                         _presence.node.appendChild( Strophe.xmlElement( 'show' ) ).appendChild( Strophe.xmlTextNode( _type ) ); 
    1934                                                         _presence.node.appendChild( Strophe.xmlElement( 'status' ) ).appendChild( Strophe.xmlTextNode( loadscript.getStatusMessage() )); 
     2054                setTimeout(function() 
     2055                { 
     2056                    if( loading_gif.style.display == "block" ) 
     2057                        loading_gif.style.display = "none"; 
     2058                }, 1000); 
     2059            } 
     2060            else 
     2061            { 
     2062                if( !TrophyIM.autoConnection.connect ) 
     2063                { 
     2064                    TrophyIM.autoConnection.connect = true; 
     2065                    TrophyIM.load(); 
     2066                } 
     2067                else 
     2068                { 
     2069                    if( TrophyIM.statusConn.connected ) 
     2070                    { 
     2071                        if( loadscript.getStatusMessage() != "" ) 
     2072                        { 
     2073                            var _presence = $pres( ); 
     2074                            _presence.node.appendChild( Strophe.xmlElement( 'show' ) ).appendChild( Strophe.xmlTextNode( _type ) ); 
     2075                            _presence.node.appendChild( Strophe.xmlElement( 'status' ) ).appendChild( Strophe.xmlTextNode( loadscript.getStatusMessage() )); 
    19352076                                                         
    1936                                                         TrophyIM.connection.send( _presence.tree() ); 
     2077                            TrophyIM.connection.send( _presence.tree() ); 
    19372078                                                         
    1938                                                         presence_chatRoom = _type; 
    1939                                                 } 
    1940                                                 else 
    1941                                                 { 
    1942                                                         TrophyIM.connection.send($pres( ).c('show').t(_type).tree()); 
     2079                            presence_chatRoom = _type; 
     2080                        } 
     2081                        else 
     2082                        { 
     2083                            TrophyIM.connection.send($pres( ).c('show').t(_type).tree()); 
    19432084                                                         
    1944                                                         presence_chatRoom = _type; 
    1945                                                 } 
    1946                                         } 
    1947                                 } 
    1948                         } 
    1949                 } 
    1950                 else 
    1951                 { 
    1952                         var _show       = "available"; 
    1953                         var _status     = ""; 
    1954                          
    1955                         if( arguments.length < 2 ) 
    1956                         { 
    1957                                 if( loadscript.getStatusMessage() != "" ) 
    1958                                         _status = prompt(i18n.TYPE_YOUR_MSG, loadscript.getStatusMessage()); 
    1959                                 else 
    1960                                         _status = prompt(i18n.TYPE_YOUR_MSG); 
     2085                            presence_chatRoom = _type; 
     2086                        } 
     2087                    } 
     2088                } 
     2089            } 
     2090        } 
     2091        else 
     2092        { 
     2093            var _show   = "available"; 
     2094            var _status = ""; 
     2095                         
     2096            if( arguments.length < 2 ) 
     2097            { 
     2098                if( loadscript.getStatusMessage() != "" ) 
     2099                    _status = prompt(i18n.TYPE_YOUR_MSG, loadscript.getStatusMessage()); 
     2100                else 
     2101                    _status = prompt(i18n.TYPE_YOUR_MSG); 
    19612102                                 
    1962                                 var _divStatus = document.getElementById("JabberIMStatusMessage"); 
     2103                var _divStatus = document.getElementById("JabberIMStatusMessage"); 
    19632104                                 
    1964                                 if( ( _status = _status.replace(/^\s+|\s+$|^\n|\n$/g,"") ) != "") 
    1965                                         _divStatus.firstChild.innerHTML = "( " + _status + " )"; 
    1966                         }  
    1967                         else 
    1968                         { 
    1969                                 _status = arguments[1]; 
    1970                         } 
    1971  
    1972                         for( var resource in TrophyIM.rosterObj.roster[Base64.decode(loadscript.getUserCurrent().jid)].presence ) 
    1973                         { 
    1974                         if ( TrophyIM.rosterObj.roster[Base64.decode(loadscript.getUserCurrent().jid)].presence[ resource ].constructor == Function ) 
    1975                                 continue; 
     2105                if( ( _status = _status.replace(/^\s+|\s+$|^\n|\n$/g,"") ) != "") 
     2106                    _divStatus.firstChild.innerHTML     = "( " + _status + " )"; 
     2107            }  
     2108            else 
     2109            { 
     2110                _status = arguments[1]; 
     2111            } 
     2112 
     2113            for( var resource in TrophyIM.rosterObj.roster[Base64.decode(loadscript.getUserCurrent().jid)].presence ) 
     2114            { 
     2115                if ( TrophyIM.rosterObj.roster[Base64.decode(loadscript.getUserCurrent().jid)].presence[ resource ].constructor == Function ) 
     2116                    continue; 
    19762117                         
    1977                                 if ( TROPHYIM_RESOURCE === ("/" + resource) ) 
    1978                                         _show = TrophyIM.rosterObj.roster[Base64.decode(loadscript.getUserCurrent().jid)].presence[resource].show; 
    1979                         } 
    1980  
    1981                         if ( TrophyIM.statusConn.connected ) 
    1982                         { 
    1983                                 var _presence = $pres( ); 
    1984                                 _presence.node.appendChild( Strophe.xmlElement( 'show' ) ).appendChild( Strophe.xmlTextNode( _show ) ); 
    1985                                 _presence.node.appendChild( Strophe.xmlElement( 'status' ) ).appendChild( Strophe.xmlTextNode( _status ) ); 
     2118                if ( TROPHYIM_RESOURCE === ("/" + resource) ) 
     2119                    _show = TrophyIM.rosterObj.roster[Base64.decode(loadscript.getUserCurrent().jid)].presence[resource].show; 
     2120            } 
     2121 
     2122            if ( TrophyIM.statusConn.connected ) 
     2123            { 
     2124                var _presence = $pres( ); 
     2125                _presence.node.appendChild( Strophe.xmlElement( 'show' ) ).appendChild( Strophe.xmlTextNode( _show ) ); 
     2126                _presence.node.appendChild( Strophe.xmlElement( 'status' ) ).appendChild( Strophe.xmlTextNode( _status ) ); 
    19862127                                 
    1987                                 TrophyIM.connection.send( _presence.tree() ); 
     2128                TrophyIM.connection.send( _presence.tree() ); 
    19882129                                 
    1989                                 presence_chatRoom = _show; 
    1990                         } 
    1991                 } 
    1992                  
    1993                 // Send Presence Chat Room 
    1994                 if( TrophyIM.activeChatRoom.name.length > 0 ) 
    1995                 { 
    1996                         for( i = 0; i < TrophyIM.activeChatRoom.name.length; i++ ) 
    1997                         { 
    1998                                 if( TrophyIM.activeChatRoom.name[i] != "" ) 
    1999                                         TrophyIM.connection.send($pres( { to : TrophyIM.activeChatRoom.name[i] } ).c('show').t( presence_chatRoom ) ); 
    2000                         } 
    2001                 } 
    2002  
    2003         }, 
    2004          
    2005         /** Function: sendMessage 
     2130                presence_chatRoom = _show; 
     2131            } 
     2132        } 
     2133                 
     2134        // Send Presence Chat Room 
     2135        if( TrophyIM.activeChatRoom.name.length > 0 ) 
     2136        { 
     2137            for( i = 0; i < TrophyIM.activeChatRoom.name.length; i++ ) 
     2138            { 
     2139                if( TrophyIM.activeChatRoom.name[i] != "" ) 
     2140                    TrophyIM.connection.send($pres( { 
     2141                        to : TrophyIM.activeChatRoom.name[i] 
     2142                        } ).c('show').t( presence_chatRoom ) ); 
     2143            } 
     2144        } 
     2145 
     2146    }, 
     2147         
     2148    /** Function: sendMessage 
    20062149     * 
    20072150     *  Send message from chat input to user 
     
    20102153    sendMessage : function() 
    20112154    { 
    2012                 if (arguments.length > 0) 
    2013                 { 
    2014                         var jidTo = arguments[0]; 
    2015                         var message_input = arguments[1]; 
    2016                          
    2017                          
    2018                         message_input = message_input.replace(/^\s+|\s+$|^\n|\n$/g, ""); 
    2019                          
    2020                         if (message_input != "") { 
    2021                          
    2022                                 // Send Message 
    2023                                 var newMessage = $msg({ 
    2024                                         to: jidTo, 
    2025                                         from: TrophyIM.connection.jid, 
    2026                                         type: 'chat' 
    2027                                 }); 
    2028                                 newMessage = newMessage.c('body').t(message_input); 
    2029                                 newMessage.up(); 
    2030                                 newMessage = newMessage.c('active').attrs({ 
    2031                                         xmlns: 'http://jabber.org/protocol/chatstates' 
    2032                                 }); 
    2033                                 // Send Message 
    2034                                 TrophyIM.connection.send(newMessage.tree()); 
     2155        if (arguments.length > 0) 
     2156        { 
     2157            var jidTo = arguments[0]; 
     2158            var message_input = arguments[1]; 
     2159                         
     2160                         
     2161            message_input = message_input.replace(/^\s+|\s+$|^\n|\n$/g, ""); 
     2162                         
     2163            if (message_input != "") { 
     2164                         
     2165                // Send Message 
     2166                var newMessage = $msg({ 
     2167                    to: jidTo, 
     2168                    from: TrophyIM.connection.jid, 
     2169                    type: 'chat' 
     2170                }); 
     2171                newMessage = newMessage.c('body').t(message_input); 
     2172                newMessage.up(); 
     2173                newMessage = newMessage.c('active').attrs({ 
     2174                    xmlns: 'http://jabber.org/protocol/chatstates' 
     2175                }); 
     2176                // Send Message 
     2177                TrophyIM.connection.send(newMessage.tree()); 
    20352178                                 
    2036                                 return true; 
    2037                         } 
    2038                 } 
    2039                  
    2040                 return false; 
    2041     }, 
    2042  
    2043         /** Function: sendMessage 
     2179                return true; 
     2180            } 
     2181        } 
     2182                 
     2183        return false; 
     2184    }, 
     2185 
     2186    /** Function: sendMessage 
    20442187    * 
    20452188    *  Send message to ChatRoom 
     
    20482191    sendMessageChatRoom : function( ) 
    20492192    { 
    2050         if( arguments.length > 0 )  
    2051         { 
    2052                 var room_nick   = arguments[0]; 
    2053                 var message             = arguments[1]; 
    2054                 var msgid               = TrophyIM.connection.getUniqueId(); 
    2055                 var msg                 = $msg({to: room_nick, type: "groupchat", id: msgid}).c("body",{xmlns: Strophe.NS.CLIENT}).t(message); 
     2193        if( arguments.length > 0 )  
     2194        { 
     2195            var room_nick       = arguments[0]; 
     2196            var message         = arguments[1]; 
     2197            var msgid           = TrophyIM.connection.getUniqueId(); 
     2198            var msg                     = $msg({ 
     2199                to: room_nick,  
     2200                type: "groupchat",  
     2201                id: msgid 
     2202            }).c("body",{ 
     2203                xmlns: Strophe.NS.CLIENT 
     2204                }).t(message); 
    20562205                 
    2057                 msg.up();//.c("x", {xmlns: "jabber:x:event"}).c("composing"); 
     2206            msg.up();//.c("x", {xmlns: "jabber:x:event"}).c("composing"); 
    20582207                 
    2059                 TrophyIM.connection.send(msg); 
     2208            TrophyIM.connection.send(msg); 
    20602209                 
    2061                 return true; 
    2062         } 
    2063     }, 
    2064      
    2065         /** Function: sendContentMessage 
     2210            return true; 
     2211        } 
     2212    }, 
     2213     
     2214    /** Function: sendContentMessage 
    20662215     * 
    20672216     *  Send a content message from chat input to user 
    20682217     */ 
    2069         sendContentMessage : function() 
    2070     { 
    2071       if( arguments.length > 0 ) 
    2072       { 
    2073          var jidTo = arguments[0]; 
    2074          var state = arguments[1]; 
    2075  
    2076          var newMessage = $msg({to: jidTo, from: TrophyIM.connection.jid, type: 'chat'}); 
    2077          newMessage = newMessage.c(state).attrs({xmlns : 'http://jabber.org/protocol/chatstates'}); 
    2078          // Send content message 
    2079          TrophyIM.connection.send(newMessage.tree()); 
    2080       } 
     2218    sendContentMessage : function() 
     2219    { 
     2220        if( arguments.length > 0 ) 
     2221        { 
     2222            var jidTo = arguments[0]; 
     2223            var state = arguments[1]; 
     2224 
     2225            var newMessage = $msg({ 
     2226                to: jidTo,  
     2227                from: TrophyIM.connection.jid,  
     2228                type: 'chat' 
     2229            }); 
     2230            newMessage = newMessage.c(state).attrs({ 
     2231                xmlns : 'http://jabber.org/protocol/chatstates' 
     2232            }); 
     2233            // Send content message 
     2234            TrophyIM.connection.send(newMessage.tree()); 
     2235        } 
    20812236    } 
    20822237}; 
     
    20982253     */ 
    20992254    if (TrophyIM.JSONStore.store_working) 
    2100         { 
     2255    { 
    21012256        var data = TrophyIM.JSONStore.getData(['roster', 'groups']); 
    21022257        this.roster = (data['roster'] != null) ? data['roster'] : {}; 
    21032258        this.groups = (data['groups'] != null) ? data['groups'] : {}; 
    21042259    } 
    2105         else 
    2106         { 
     2260    else 
     2261    { 
    21072262        this.roster = {}; 
    21082263        this.groups = {}; 
     
    21102265    this.changes = new Array(); 
    21112266     
    2112         if (TrophyIM.constants.stale_roster) 
    2113         { 
     2267    if (TrophyIM.constants.stale_roster) 
     2268    { 
    21142269        for (var jid in this.roster) 
    2115                 { 
    2116                         this.changes[this.changes.length] = jid; 
     2270        { 
     2271            this.changes[this.changes.length] = jid; 
    21172272        } 
    21182273    } 
    21192274 
    2120         /** Function: addChange 
     2275    /** Function: addChange 
    21212276         * 
    21222277         *  Adds given jid to this.changes, keeping this.changes sorted and 
     
    21272282         */ 
    21282283          
    2129         this.addChange = function(jid) 
    2130         { 
    2131                 for (var c = 0; c < this.changes.length; c++) 
    2132                 { 
    2133                         if (this.changes[c] == jid) 
    2134                         { 
    2135                                 return; 
    2136                         } 
    2137                 } 
    2138                  
    2139                 this.changes[this.changes.length] = jid; 
    2140                  
    2141                 this.changes.sort(); 
    2142         } 
     2284    this.addChange = function(jid) 
     2285    { 
     2286        for (var c = 0; c < this.changes.length; c++) 
     2287        { 
     2288            if (this.changes[c] == jid) 
     2289            { 
     2290                return; 
     2291            } 
     2292        } 
     2293                 
     2294        this.changes[this.changes.length] = jid; 
     2295                 
     2296        this.changes.sort(); 
     2297    } 
    21432298         
    21442299    /** Function: addContact 
     
    21532308     */ 
    21542309     
    2155         this.addContact = function(jid, subscription, name, groups ) 
    2156         { 
    2157                 if( subscription === "remove" ) 
    2158         { 
    2159                         this.removeContact(jid); 
    2160         } 
    2161         else 
    2162         { 
    2163                         var contact             = { jid:jid, subscription:subscription, name:name, groups:groups } 
    2164                 var jid_lower   = jid.toLowerCase(); 
    2165          
    2166                         if ( this.roster[jid_lower] ) 
    2167                         { 
    2168                     this.roster[jid_lower]['contact'] = contact; 
    2169                 } 
    2170                         else 
    2171                         { 
    2172                     this.roster[jid_lower] = {contact:contact}; 
    2173                 } 
    2174  
    2175                         groups = groups ? groups : ['']; 
     2310    this.addContact = function(jid, subscription, name, groups ) 
     2311    { 
     2312        if( subscription === "remove" ) 
     2313        { 
     2314            this.removeContact(jid); 
     2315        } 
     2316        else 
     2317        { 
     2318            var contact         = { 
     2319                jid:jid,  
     2320                subscription:subscription,  
     2321                name:name,  
     2322                groups:groups 
     2323            } 
     2324            var jid_lower       = jid.toLowerCase(); 
     2325         
     2326            if ( this.roster[jid_lower] ) 
     2327            { 
     2328                this.roster[jid_lower]['contact'] = contact; 
     2329            } 
     2330            else 
     2331            { 
     2332                this.roster[jid_lower] = { 
     2333                    contact:contact 
     2334                }; 
     2335            } 
     2336 
     2337            groups = groups ? groups : ['']; 
    21762338                 
    2177                         for ( var g = 0; g < groups.length; g++ ) 
    2178                         { 
    2179                                 if ( !this.groups[groups[g]] ) 
    2180                                 { 
    2181                         this.groups[groups[g]] = {}; 
    2182                     } 
     2339            for ( var g = 0; g < groups.length; g++ ) 
     2340            { 
     2341                if ( !this.groups[groups[g]] ) 
     2342                { 
     2343                    this.groups[groups[g]] = {}; 
     2344                } 
    21832345                     
    2184                                 this.groups[groups[g]][jid_lower] = jid_lower; 
    2185                 } 
    2186         } 
     2346                this.groups[groups[g]][jid_lower] = jid_lower; 
     2347            } 
     2348        } 
    21872349    } 
    21882350     
     
    21952357      
    21962358    this.getContact = function(jid) 
    2197         { 
     2359    { 
    21982360        if (this.roster[jid.toLowerCase()]) 
    2199                 { 
     2361        { 
    22002362            return this.roster[jid.toLowerCase()]['contact']; 
    22012363        } 
    22022364    } 
    22032365 
    2204    /** Function: getPresence 
     2366    /** Function: getPresence 
    22052367        * 
    22062368        *  Returns best presence for given jid as Array(resource, priority, show, 
     
    22102372        */ 
    22112373          
    2212         this.getPresence = function(fulljid) 
    2213         { 
    2214                 var jid = Strophe.getBareJidFromJid(fulljid); 
    2215                 var current = null; 
     2374    this.getPresence = function(fulljid) 
     2375    { 
     2376        var jid = Strophe.getBareJidFromJid(fulljid); 
     2377        var current = null; 
    22162378                     
    2217                 if (this.roster[jid.toLowerCase()] && this.roster[jid.toLowerCase()]['presence']) 
    2218                 { 
    2219                         for (var resource in this.roster[jid.toLowerCase()]['presence']) 
    2220                         { 
    2221                         if ( this.roster[jid.toLowerCase()]['presence'][ resource ].constructor == Function ) 
    2222                                 continue; 
     2379        if (this.roster[jid.toLowerCase()] && this.roster[jid.toLowerCase()]['presence']) 
     2380        { 
     2381            for (var resource in this.roster[jid.toLowerCase()]['presence']) 
     2382            { 
     2383                if ( this.roster[jid.toLowerCase()]['presence'][ resource ].constructor == Function ) 
     2384                    continue; 
    22232385                         
    2224                                 var presence = this.roster[jid.toLowerCase()]['presence'][resource]; 
    2225                                 if (current == null) 
    2226                                 { 
    2227                                         current = presence 
    2228                                 } 
    2229                                 else 
    2230                                 { 
    2231                                         if(presence['priority'] > current['priority'] && ((presence['show'] == "chat" 
    2232                                         || presence['show'] == "available") || (current['show'] != "chat" || 
    2233                                         current['show'] != "available"))) 
    2234                                         { 
    2235                                                 current = presence 
    2236                                         } 
    2237                                 } 
    2238                         } 
    2239                 } 
    2240                 return current; 
    2241         } 
    2242  
    2243         /** Function: groupHasChanges 
     2386                var presence = this.roster[jid.toLowerCase()]['presence'][resource]; 
     2387                if (current == null) 
     2388                { 
     2389                    current = presence 
     2390                } 
     2391                else 
     2392                { 
     2393                    if(presence['priority'] > current['priority'] && ((presence['show'] == "chat" 
     2394                        || presence['show'] == "available") || (current['show'] != "chat" || 
     2395                        current['show'] != "available"))) 
     2396                        { 
     2397                        current = presence 
     2398                    } 
     2399                } 
     2400            } 
     2401        } 
     2402        return current; 
     2403    } 
     2404 
     2405    /** Function: groupHasChanges 
    22442406         * 
    22452407         *  Returns true if current group has members in this.changes 
     
    22492411         */ 
    22502412          
    2251         this.groupHasChanges = function(group) 
    2252         { 
    2253                 for (var c = 0; c < this.changes.length; c++) 
    2254                 { 
    2255                         if (this.groups[group][this.changes[c]]) 
    2256                         { 
    2257                                 return true; 
    2258                         } 
    2259                 } 
    2260                 return false; 
    2261         } 
    2262          
    2263         /** Function removeContact 
     2413    this.groupHasChanges = function(group) 
     2414    { 
     2415        for (var c = 0; c < this.changes.length; c++) 
     2416        { 
     2417            if (this.groups[group][this.changes[c]]) 
     2418            { 
     2419                return true; 
     2420            } 
     2421        } 
     2422        return false; 
     2423    } 
     2424         
     2425    /** Function removeContact 
    22642426         * 
    22652427         * Parameters 
     
    22672429         */ 
    22682430          
    2269         this.removeContact = function(jid) 
    2270         { 
    2271                 if( this.roster[ jid ] ) 
    2272                 {  
    2273                         var groups = this.roster[ jid ].contact.groups; 
    2274                          
    2275                         if( groups ) 
    2276                         { 
    2277                                 for ( var i = 0; i < groups.length; i++ ) 
    2278                                 { 
    2279                                         delete this.groups[ groups[ i ] ][ jid ]; 
    2280                                 } 
    2281          
    2282                                 for ( var i = 0; i < groups.length; i++ ) 
    2283                                 { 
    2284                                         var contacts = 0; 
    2285                                         for ( var contact in this.groups[ groups[ i ] ] ) 
    2286                                         { 
    2287                                         if ( this.groups[ groups[ i ] ][ contact ].constructor == Function ) 
    2288                                                 continue; 
     2431    this.removeContact = function(jid) 
     2432    { 
     2433        if( this.roster[ jid ] ) 
     2434        {  
     2435            var groups = this.roster[ jid ].contact.groups; 
     2436                         
     2437            if( groups ) 
     2438            { 
     2439                for ( var i = 0; i < groups.length; i++ ) 
     2440                { 
     2441                    delete this.groups[ groups[ i ] ][ jid ]; 
     2442                } 
     2443         
     2444                for ( var i = 0; i < groups.length; i++ ) 
     2445                { 
     2446                    var contacts = 0; 
     2447                    for ( var contact in this.groups[ groups[ i ] ] ) 
     2448                    { 
     2449                        if ( this.groups[ groups[ i ] ][ contact ].constructor == Function ) 
     2450                            continue; 
    22892451                                         
    2290                                                 contacts++; 
    2291                                         } 
    2292                  
    2293                                         if ( ! contacts ) 
    2294                                                 delete this.groups[ groups[ i ] ]; 
    2295                                 } 
    2296                         } 
    2297          
    2298                         // Delete Object roster 
    2299                         if( this.roster[jid] ) 
    2300                                 delete this.roster[jid]; 
    2301                 } 
    2302         } 
     2452                        contacts++; 
     2453                    } 
     2454                 
     2455                    if ( ! contacts ) 
     2456                        delete this.groups[ groups[ i ] ]; 
     2457                } 
     2458            } 
     2459         
     2460            // Delete Object roster 
     2461            if( this.roster[jid] ) 
     2462                delete this.roster[jid]; 
     2463        } 
     2464    } 
    23032465          
    23042466    /** Function: setPresence 
     
    23132475     */ 
    23142476     
    2315         this.setPresence = function(fulljid, priority, show, status) 
    2316         { 
    2317                 var barejid             = Strophe.getBareJidFromJid(fulljid); 
     2477    this.setPresence = function(fulljid, priority, show, status) 
     2478    { 
     2479        var barejid             = Strophe.getBareJidFromJid(fulljid); 
    23182480        var resource    = Strophe.getResourceFromJid(fulljid); 
    23192481        var jid_lower   = barejid.toLowerCase(); 
    23202482         
    23212483        if( show !== 'unavailable' || show !== 'error' ) 
    2322                 { 
    2323                 if (!this.roster[jid_lower]) 
    2324                         { 
     2484        { 
     2485            if (!this.roster[jid_lower]) 
     2486            { 
    23252487                this.addContact( barejid, 'not-in-roster' ); 
    23262488            } 
    23272489             
    23282490            var presence = 
    2329                         { 
     2491            { 
    23302492                resource        : resource, 
    23312493                priority        : priority, 
     
    23342496            } 
    23352497             
    2336                         if (!this.roster[jid_lower]['presence']) 
    2337                         { 
     2498            if (!this.roster[jid_lower]['presence']) 
     2499            { 
    23382500                this.roster[jid_lower]['presence'] = {}; 
    23392501            } 
    23402502             
    23412503            this.roster[jid_lower]['presence'][resource] = presence;     
    2342                 } 
     2504        } 
    23432505    } 
    23442506 
    2345         /** Fuction: save 
     2507    /** Fuction: save 
    23462508         * 
    23472509         *  Saves roster data to JSON store 
    23482510         */ 
    23492511         
    2350         this.save = function() 
    2351         { 
    2352                 if (TrophyIM.JSONStore.store_working) 
    2353                 { 
    2354                         TrophyIM.JSONStore.setData({roster:this.roster, 
    2355                         groups:this.groups, active_chat:TrophyIM.activeChats['current'], 
    2356                         chat_history:TrophyIM.chatHistory}); 
    2357                 } 
    2358         } 
     2512    this.save = function() 
     2513    { 
     2514        if (TrophyIM.JSONStore.store_working) 
     2515        { 
     2516            TrophyIM.JSONStore.setData({ 
     2517                roster:this.roster, 
     2518                groups:this.groups,  
     2519                active_chat:TrophyIM.activeChats['current'], 
     2520                chat_history:TrophyIM.chatHistory 
     2521                }); 
     2522        } 
     2523    } 
    23592524 
    23602525} 
     
    23752540     *    (function) handler = what to set onreadystatechange to 
    23762541     */ 
    2377      this._newXHR = function (handler) { 
     2542    this._newXHR = function (handler) { 
    23782543        var xhr = null; 
    23792544        if (window.XMLHttpRequest) { 
    23802545            xhr = new XMLHttpRequest(); 
    23812546            if (xhr.overrideMimeType) { 
    2382             xhr.overrideMimeType("text/xml"); 
     2547                xhr.overrideMimeType("text/xml"); 
    23832548            } 
    23842549        } else if (window.ActiveXObject) { 
     
    24082573            } 
    24092574            xhr.setRequestHeader('Content-type', 
    2410             'application/x-www-form-urlencoded'); 
     2575                'application/x-www-form-urlencoded'); 
    24112576            xhr.setRequestHeader('Content-length', getdata.length); 
    24122577            xhr.send(getdata); 
     
    24172582                } catch(e) { 
    24182583                    Strophe.error("Could not parse JSONStore response" + 
    2419                     xhr.responseText); 
     2584                        xhr.responseText); 
    24202585                    return false; 
    24212586                } 
     
    24342599        if (typeof(obj) == "object") { 
    24352600            for (var i in obj) { 
    2436                         if ( obj[i].constructor == Function ) 
    2437                                 continue; 
     2601                if ( obj[i].constructor == Function ) 
     2602                    continue; 
    24382603                         
    24392604                if (i == '_empty_') { 
     
    24682633            } 
    24692634            xhr.setRequestHeader('Content-type', 
    2470             'application/x-www-form-urlencoded'); 
     2635                'application/x-www-form-urlencoded'); 
    24712636            xhr.setRequestHeader('Content-length', deldata.length); 
    24722637            xhr.send(deldata); 
     
    24972662    this.setData = function(vars) 
    24982663    { 
    2499         if ( typeof(TROPHYIM_JSON_STORE) != undefined ) 
     2664        if ( typeof(TROPHYIM_JSON_STORE) != undefined ) 
    25002665        { 
    25012666            var senddata = "set=" + JSON.stringify(vars); 
     
    25112676            } 
    25122677            xhr.setRequestHeader('Content-type', 
    2513             'application/x-www-form-urlencoded'); 
     2678                'application/x-www-form-urlencoded'); 
    25142679            xhr.setRequestHeader('Content-length', senddata.length); 
    25152680            xhr.send(senddata); 
    25162681            if (xhr.readyState == 4 && xhr.status == 200 && xhr.responseText == 
    2517             "OK") { 
     2682                "OK") { 
    25182683                return true; 
    25192684            } else { 
     
    25262691    var testData = true; 
    25272692     
    2528     if (this.setData({testData:testData})) { 
     2693    if (this.setData({ 
     2694        testData:testData 
     2695    })) { 
    25292696        var testResult = this.getData(['testData']); 
    25302697        if (testResult && testResult['testData'] == true) { 
     
    25682735                    for(var i = 0; i < node.attributes.length; i++) { 
    25692736                        newNode.setAttribute(node.attributes[i].nodeName, 
    2570                         node.getAttribute(node.attributes[i].nodeName)); 
     2737                            node.getAttribute(node.attributes[i].nodeName)); 
    25712738                    } 
    25722739                } 
    25732740                if (allChildren && node.childNodes && 
    2574                 node.childNodes.length > 0) { 
     2741                    node.childNodes.length > 0) { 
    25752742                    for (var i = 0; i < node.childNodes.length; i++) { 
    25762743                        newNode.appendChild(document.importNode( 
    2577                         node.childNodes[i], allChildren)); 
     2744                            node.childNodes[i], allChildren)); 
    25782745                    } 
    25792746                } 
     
    25982765window.onunload = function() 
    25992766{ 
    2600         if( oldonunload ) 
    2601         { 
     2767    if( oldonunload ) 
     2768    { 
    26022769        oldonunload(); 
    26032770    } 
    26042771         
    2605         TrophyIM.setPresence('unavailable'); 
     2772    TrophyIM.setPresence('unavailable'); 
    26062773} 
Note: See TracChangeset for help on using the changeset viewer.