Ignore:
Timestamp:
04/30/10 09:52:49 (14 years ago)
Author:
alexandrecorreia
Message:

Ticket #986 - Correcao para compatibilizar o carregamento do script para o trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/jabberit_messenger/trophy_expresso/js/trophyim.js

    r2647 r2670  
    6464                    return htmlObj; 
    6565                } catch(e) { 
    66                     alert( 
    67                     "TrophyIM Error: Cannot add html to page" + e.message); 
     66                    alert("TrophyIM Error: Cannot add html to page " + e.message); 
    6867                } 
    6968            } 
     
    243242        load : function() 
    244243        { 
    245                 loadIM.setUserCurrent(); 
     244                loadscript.setUserCurrent(); 
    246245         
    247246        if (!TrophyIM.statusConn.connected) 
     
    258257                else 
    259258                { 
    260                         loadIM.rosterDiv(); 
     259                        loadscript.rosterDiv(); 
    261260                } 
    262261   }, 
     
    309308            { 
    310309                // List Contact 
    311                                 loadIM.rosterDiv(); 
     310                                loadscript.rosterDiv(); 
    312311                                 
    313                                 if ( loadIM.getUserCurrent() != null ) 
     312                                if ( loadscript.getUserCurrent() != null ) 
    314313                                { 
    315                                         TrophyIM.login( Base64.decode(loadIM.getUserCurrent().jid), Base64.decode(loadIM.getUserCurrent().password)); 
     314                                        TrophyIM.login( Base64.decode(loadscript.getUserCurrent().jid), Base64.decode(loadscript.getUserCurrent().password)); 
    316315                                } 
    317316                                else 
    318317                                { 
    319                                         loadIM.loginPage(); 
     318                                        loadscript.loginPage(); 
    320319                                } 
    321320            } 
     
    401400                        var button              = document.getElementById('trophyimconnect'); 
    402401                         
    403                         loadIM.setUserCurrent( barejid, password); 
     402                        loadscript.setUserCurrent( barejid, password); 
    404403                         
    405404                        if ( button.value == 'connect' ) 
     
    475474                                },10000); 
    476475                                 
    477                     loadIM.clrAllContacts();     
     476                    loadscript.clrAllContacts();         
    478477                     
    479                     loadIM.setStatusJabber("Desconectado","unavailable"); 
     478                    loadscript.setStatusJabber("Desconectado","unavailable"); 
    480479                     
    481480                    delete TrophyIM.rosterObj.roster; 
     
    486485                if( status == Strophe.Status.CONNECTED ) 
    487486                { 
    488                         loadIM.setStatusJabber('Disponível','available'); 
     487                        loadscript.setStatusJabber('Disponível','available'); 
    489488                        TrophyIM.statusConn.connected = true; 
    490489            TrophyIM.showClient(); 
     
    511510        TrophyIM.connection.send($iq({type: 'get', xmlns: Strophe.NS.CLIENT}).c('query', {xmlns: Strophe.NS.ROSTER}).tree()); 
    512511        TrophyIM.connection.send($pres().tree()); 
    513                 setTimeout("TrophyIM.renderRoster()", 1000); 
     512                setTimeout( TrophyIM.renderRoster, 1000); 
    514513    }, 
    515514         
     
    640639            } 
    641640 
    642             var message =  
    643             {  
    644                 contact : "<font style='font-weight:bold; color:black;'>" + contact + "</font>", 
    645                 msg             : Strophe.getText(elems[0])      
    646             }; 
    647  
    648             TrophyIM.makeChat(from); //Make sure we have a chat window 
    649             TrophyIM.addMessage(message, jid_lower); 
     641                var _message = document.createElement("div"); 
     642                _message.innerHTML = Strophe.getText(elems[0]); 
     643 
     644                var scripts = _message.getElementsByTagName( 'script' ); 
     645 
     646                for ( var i = 0; i < scripts.length; i++ ) 
     647                        _message.removeChild( scripts[ i-- ] ); 
     648                 
     649                _message.innerHTML = _message.innerHTML.trim( ); 
     650 
     651                if ( _message.hasChildNodes( ) ) 
     652                { 
     653                    var message =  
     654                    {  
     655                        contact : "<font style='font-weight:bold; color:black;'>" + contact + "</font>", 
     656                        msg             : _message.innerHTML 
     657                    }; 
     658         
     659                    TrophyIM.makeChat(from); //Make sure we have a chat window 
     660                    TrophyIM.addMessage(message, jid_lower); 
     661                } 
    650662        } 
    651663         
     
    702714                         visible                : "display", 
    703715                         resizable              : true, 
    704                          zindex                 : loadIM.getZIndex(), 
     716                         zindex                 : loadscript.getZIndex(), 
    705717                         title                  : titleWindow, 
    706718                         closeAction    : "hidden", 
    707                          content                : loadIM.parse("chat_box","chatBox.xsl", paramsChatBox)  
     719                         content                : loadscript.parse("chat_box","chatBox.xsl", paramsChatBox)      
    708720        } 
    709721         
     
    711723 
    712724        // Notification New Message 
    713         loadIM.notification(); 
     725        loadscript.notification(); 
    714726         
    715727        // Photo User; 
    716                 loadIM.getPhotoUser(barejid); 
     728                loadscript.getPhotoUser(barejid); 
    717729                 
    718                 loadIM.configEvents( document.getElementById( barejid + '__sendBox'), 
     730                loadscript.configEvents( document.getElementById( barejid + '__sendBox'), 
    719731                        'onkeyup', function(e) 
    720732                        { 
     
    828840        { 
    829841                for( var i in presence ) 
     842                { 
     843                        if ( presence[ i ].constructor == Function ) 
     844                                continue; 
     845                                 
    830846                        TrophyIM.rosterObj.setPresence( jid, presence[i].priority, presence[i].show, presence[i].status); 
     847                } 
    831848        },500); 
    832849    }, 
     
    849866                spanShow.parentNode.removeChild(spanShow); 
    850867                 
    851                 loadIM.removeGroup( divItenContact.parentNode ); 
     868                loadscript.removeGroup( divItenContact.parentNode ); 
    852869                 
    853870                divItenContact.parentNode.removeChild(divItenContact); 
     
    892909                        for( var user in TrophyIM.rosterObj.roster ) 
    893910                        { 
     911                                if ( TrophyIM.rosterObj.roster[ user ].constructor == Function ) 
     912                                        continue; 
     913 
    894914                                users[users.length] = TrophyIM.rosterObj.roster[user].contact.jid; 
    895915                        } 
     
    902922                        for (var group in TrophyIM.rosterObj.groups) 
    903923                        { 
     924                                if ( TrophyIM.rosterObj.groups[ group ].constructor == Function ) 
     925                                        continue; 
     926                                 
    904927                                if( group ) 
    905928                                        groups[groups.length] = group; 
     
    943966                        } 
    944967                         
    945                         _element.innerHTML += loadIM.parse("group","groups.xsl", paramsGroup); 
     968                        _element.innerHTML += loadscript.parse("group","groups.xsl", paramsGroup); 
    946969                } 
    947970 
     
    9921015 
    9931016                                var itensJid    = document.getElementById( 'itenContact_' + objContact.contact.jid + '_' + index ); 
    994                                  
     1017 
    9951018                                if( itensJid == null ) 
    9961019                                { 
     
    10151038                                                for (var resource in objContact.presence) 
    10161039                                                { 
     1040                                                        if ( objContact.presence[resource].constructor == Function ) 
     1041                                                                continue; 
     1042 
    10171043                                                        if( objContact.presence[resource].show != 'invisible' ) 
    10181044                                                                presence = objContact.presence[resource].show; 
     
    10341060                                                jid                             : objContact.contact.jid,        
    10351061                                                id                              : 'itenContact_' + objContact.contact.jid + '_' + index , 
    1036                                                 index                   : index, 
     1062                                                index                   : ((index == 0 ) ? "0" : index), 
    10371063                                                path_jabberit   : path_jabberit, 
    10381064                                                presence                : presence, 
     
    10421068                                                subscription    : objContact.contact.subscription 
    10431069                                        } 
    1044                                          
    1045  
    10461070                                         
    10471071                                        // Authorization         
     
    10961120                                                                if( _NodeChild.childNodes[0].childNodes[0].nodeValue === group ) 
    10971121                                                                { 
    1098                                                                         _NodeChild.innerHTML += loadIM.parse("itens_group", "itensGroup.xsl", paramsContact); 
     1122                                                                        _NodeChild.innerHTML += loadscript.parse("itens_group", "itensGroup.xsl", paramsContact); 
    10991123                                                                } 
    11001124                                                        } 
     
    11171141                                                for ( var resource in objContact.presence ) 
    11181142                                                { 
     1143                                                        if ( objContact.presence[resource].constructor == Function ) 
     1144                                                                continue; 
     1145 
    11191146                                                        if( objContact.presence[resource].show != 'invisible' ) 
    11201147                                                                presence = objContact.presence[resource].show; 
     
    11931220                for( var i = 0 ; i < users.length; i++ ) 
    11941221                { 
    1195                         if( TrophyIM.rosterObj.roster[users[i]].contact.jid != Base64.decode(loadIM.getUserCurrent().jid) ) 
     1222                        if( TrophyIM.rosterObj.roster[users[i]].contact.jid != Base64.decode(loadscript.getUserCurrent().jid) ) 
    11961223                        { 
    11971224                                if( TrophyIM.rosterObj.roster[users[i]].contact.groups ) 
     
    12021229                                        { 
    12031230                                                for( var j = 0; j < groups.length; j++ ) 
     1231                                                { 
    12041232                                                        addItem( TrophyIM.rosterObj.roster[users[i]], groups[j], element, j ); 
     1233                                                } 
    12051234                                        } 
    12061235                                        else 
     
    12641293                                TrophyIM.logout(); 
    12651294                                 
    1266                         loadIM.clrAllContacts(); 
     1295                        loadscript.clrAllContacts(); 
    12671296                         
    12681297                        delete TrophyIM.rosterObj.roster; 
     
    12931322                        if (( _status = prompt("Digite sua mensagem !") )) 
    12941323                        { 
    1295                                 for(var resource in TrophyIM.rosterObj.roster[Base64.decode(loadIM.getUserCurrent().jid)].presence ) 
    1296                                 {        
     1324                                for(var resource in TrophyIM.rosterObj.roster[Base64.decode(loadscript.getUserCurrent().jid)].presence ) 
     1325                                { 
     1326                                if ( TrophyIM.rosterObj.roster[Base64.decode(loadscript.getUserCurrent().jid)].presence[ resource ].constructor == Function ) 
     1327                                        continue; 
     1328                                 
    12971329                                        if ( TROPHYIM_RESOURCE === ("/" + resource) ) 
    1298                                                 _show = TrophyIM.rosterObj.roster[Base64.decode(loadIM.getUserCurrent().jid)].presence[resource].show; 
     1330                                                _show = TrophyIM.rosterObj.roster[Base64.decode(loadscript.getUserCurrent().jid)].presence[resource].show; 
    12991331                                } 
    13001332 
     
    14781510                        for (var resource in this.roster[jid.toLowerCase()]['presence']) 
    14791511                        { 
     1512                        if ( this.roster[jid.toLowerCase()]['presence'][ resource ].constructor == Function ) 
     1513                                continue; 
     1514                         
    14801515                                var presence = this.roster[jid.toLowerCase()]['presence'][resource]; 
    14811516                                if (current == null) 
     
    15401575                                        var contacts = 0; 
    15411576                                        for ( var contact in this.groups[ groups[ i ] ] ) 
     1577                                        { 
     1578                                        if ( this.groups[ groups[ i ] ][ contact ].constructor == Function ) 
     1579                                                continue; 
     1580                                         
    15421581                                                contacts++; 
     1582                                        } 
    15431583                 
    15441584                                        if ( ! contacts ) 
     
    16861726        if (typeof(obj) == "object") { 
    16871727            for (var i in obj) { 
     1728                        if ( obj[i].constructor == Function ) 
     1729                                continue; 
     1730                         
    16881731                if (i == '_empty_') { 
    16891732                    obj[""] = this.emptyFix(obj['_empty_']); 
Note: See TracChangeset for help on using the changeset viewer.