Changeset 2821


Ignore:
Timestamp:
05/19/10 10:42:58 (14 years ago)
Author:
emmanuel.ferro
Message:

Ticket #986 - [SERPRO] Implementacao da XEP-0085 - ok

File:
1 edited

Legend:

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

    r2815 r2821  
    494494                if( status == Strophe.Status.CONNECTED ) 
    495495                { 
    496                         loadscript.setStatusJabber('Disponível','available'); 
     496                        loadscript.setStatusJabber('Disponï¿œvel','available'); 
    497497                        TrophyIM.statusConn.connected = true; 
    498498            TrophyIM.showClient(); 
     
    677677                } 
    678678 
    679                 // Message with body are "content message", this mean state active 
     679                // Message with body are "content message", this means state active 
    680680                if ( elems.length > 0 ) 
    681681                { 
     
    713713                { 
    714714                        if( chatBox != null ) 
    715                                 state = TrophyIM.getChatState(msg);                      
    716                 } 
    717                  
    718                 if( chatBox != null ) 
    719                         chatBox.innerHTML = '<font style="font-weight:bold; color:grey; margin-left: 5px; float:right;">' + state + '</font>';   
     715                                state = contact + TrophyIM.getChatState(msg);                    
     716                } 
     717                 
     718                // Clean chat status message some time later             
     719                var clearChatState = function(){ 
     720                        chatBox.innerHTML=''; 
     721                } 
     722                 
     723                if (chatBox != null) { 
     724                        chatBox.innerHTML = "<font style='font-weight:bold; color:grey; margin-left: 5px; float:left;'>" + state + "</font>"; 
     725                        var clearChatState = setTimeout(clearChatState, 2000); 
     726                } 
    720727                 
    721728                return true; 
     
    734741                if ( state.length > 0 ) 
    735742                { 
    736                 return' está inativo...'; 
     743                return ' está inativo...'; 
    737744                } 
    738745                else 
     
    748755                if ( state.length > 0 ) 
    749756                { 
    750                         return ' está digitando...'; 
     757                        return ' está digitando...'; 
    751758                                } 
    752759                else 
     
    755762                        if ( state.length > 0 ) 
    756763                        { 
    757                                 return ' está parado...'; 
     764                                return ' está parado...'; 
    758765                                        } 
    759766                                } 
     
    831838                loadscript.configEvents( _textarea, 'onkeyup', function( e ) 
    832839                { 
     840                        setComposing(); 
    833841                        if ( e.keyCode == 13 ) 
    834842                                _send_message( ); 
     
    860868                loadscript.getPhotoUser(barejid); 
    861869                 
     870                var composingTimer_ = 0; 
     871                var isComposing_ = 0; 
     872                var timeCounter; 
     873 
     874                function setComposing() 
     875                { 
     876                        var checkComposing = function() 
     877                        { 
     878                if (!isComposing_) { 
     879                        // User stopped composing 
     880                        composingTimer_ = 0; 
     881                        clearInterval(timeCounter); 
     882                        TrophyIM.sendContentMessage(barejid, 'paused'); 
     883                } else { 
     884                        TrophyIM.sendContentMessage(barejid, 'composing'); 
     885                } 
     886                isComposing_ = 0; // Reset composing 
     887                } 
     888 
     889                if (!composingTimer_) { 
     890                /* User (re)starts composing */ 
     891                composingTimer_ = 1; 
     892                timeCounter = setInterval(checkComposing,3000); 
     893                } 
     894                isComposing_ = 1; 
     895        } 
     896 
    862897                _textarea.focus( ); 
    863898                 
     
    12041239                                                        case "none" : 
    12051240                                                                 
    1206                                                                 paramsContact.status            = " (( PEDIR AUTORIZAÇAO ! )) "; 
     1241                                                                paramsContact.status            = " (( PEDIR AUTORIZAÇÃO ! )) "; 
    12071242                                                                paramsContact.statusColor       = "red"; 
    12081243                                                                break; 
     
    12101245                                                        case "to" : 
    12111246                                                                 
    1212                                                                 paramsContact.status            = " (( CONTATO PEDE AUTORIZAÇÃO ! )) "; 
     1247                                                                paramsContact.status            = " (( CONTATO PEDE AUTORIZAÇÃO ! )) "; 
    12131248                                                                paramsContact.statusColor       = "orange"; 
    12141249                                                                break; 
     
    12221257                                                        case "subscribe" :  
    12231258                                                                 
    1224                                                                 paramsContact.status            = " (( AUTORIZAÇÃO ENVIADA ! )) "; 
     1259                                                                paramsContact.status            = " (( AUTORIZAÇÃO ENVIADA ! )) "; 
    12251260                                                                paramsContact.statusColor       = "red";         
    12261261                                                                break; 
     
    12281263                                                        case "not-in-roster" : 
    12291264                                                                 
    1230                                                                 paramsContact.status            = " (( QUERO ADICIONÁ-LO(A) ! POSSO ? )) "; 
     1265                                                                paramsContact.status            = " (( QUERO ADICIONÁ-LO(A) ! POSSO ? )) "; 
    12311266                                                                paramsContact.statusColor       = "orange";      
    12321267                                                                break; 
     
    12951330                                                        case "none" : 
    12961331                                                                 
    1297                                                                 status          = " (( PEDIR AUTORIZAÇAO ! )) "; 
     1332                                                                status          = " (( PEDIR AUTORIZAÇÃO ! )) "; 
    12981333                                                                statusColor     = "red"; 
    12991334                                                                break; 
     
    13011336                                                        case "to" : 
    13021337                                                                 
    1303                                                                 status          = " (( CONTATO PEDE AUTORIZAÇÃO ! )) "; 
     1338                                                                status          = " (( CONTATO PEDE AUTORIZAÇÃO ! )) "; 
    13041339                                                                statusColor     = "orange"; 
    13051340                                                                break; 
     
    13131348                                                        case "subscribe" :  
    13141349                                                                 
    1315                                                                 status          = " (( AUTORIZAÇÃO ENVIADA ! )) "; 
     1350                                                                status          = " (( AUTORIZAÇÃO ENVIADA ! )) "; 
    13161351                                                                statusColor     = "red";         
    13171352                                                                break; 
     
    13191354                                                        case "not-in-roster" : 
    13201355                                                                 
    1321                                                                 status          = " (( QUERO ADICIONÁ-LO(A) ! POSSO ? )) "; 
     1356                                                                status          = " (( QUERO ADICIONÁ-LO(A) ! POSSO ? )) "; 
    13221357                                                                statusColor     = "orange";      
    13231358                                                                break; 
     
    14401475                if( _type != 'status') 
    14411476                { 
    1442                         if( _type == "unavailable" && TrophyIM.statusConn.connected ) 
     1477                        if( _type == "unavailable") 
    14431478                        { 
    14441479                                var loading_gif = document.getElementById("JabberIMRosterLoadingGif"); 
     
    15431578     */ 
    15441579      
    1545     sendMessage : function( _jidTo, _message ) 
     1580    sendMessage : function() 
    15461581    { 
    1547                 _message = _message.replace(/^\s+|\s+$|^\n|\n$/g,""); 
    1548          
    1549                 if( _message != "" ) 
    1550                 { 
    1551                 // Send Message 
    1552                 TrophyIM.connection.send( 
    1553                         $msg( { 
    1554                                 to: _jidTo, from: TrophyIM.connection.jid, 
    1555                                 type: 'chat' 
    1556                         } ).c('body').t( _message ).tree() 
    1557                 ); 
    1558                 return true; 
     1582                if (arguments.length > 0) { 
     1583                        var jidTo = arguments[0]; 
     1584                        var message_input = arguments[1]; 
     1585                         
     1586                         
     1587                        message_input = message_input.replace(/^\s+|\s+$|^\n|\n$/g, ""); 
     1588                         
     1589                        if (message_input != "") { 
     1590                         
     1591                                // Send Message 
     1592                                var newMessage = $msg({ 
     1593                                        to: jidTo, 
     1594                                        from: TrophyIM.connection.jid, 
     1595                                        type: 'chat' 
     1596                                }); 
     1597                                newMessage = newMessage.c('body').t(message_input); 
     1598                                newMessage.up(); 
     1599                                newMessage = newMessage.c('active').attrs({ 
     1600                                        xmlns: 'http://jabber.org/protocol/chatstates' 
     1601                                }); 
     1602                                // Send Message 
     1603                                TrophyIM.connection.send(newMessage.tree()); 
     1604                                 
     1605                                return true; 
     1606                        } 
    15591607                } 
    15601608                 
    15611609                return false; 
     1610    }, 
     1611         
     1612        /** Function: sendContentMessage 
     1613     * 
     1614     *  Send a content message from chat input to user 
     1615     */ 
     1616        sendContentMessage : function() 
     1617    { 
     1618      if( arguments.length > 0 ) 
     1619      { 
     1620         var jidTo = arguments[0]; 
     1621         var state = arguments[1]; 
     1622 
     1623         var newMessage = $msg({to: jidTo, from: TrophyIM.connection.jid, type: 'chat'}); 
     1624         newMessage = newMessage.c(state).attrs({xmlns : 'http://jabber.org/protocol/chatstates'}); 
     1625         // Send content message 
     1626         TrophyIM.connection.send(newMessage.tree()); 
     1627      } 
    15621628    } 
    15631629}; 
Note: See TracChangeset for help on using the changeset viewer.