Changeset 2312


Ignore:
Timestamp:
03/19/10 17:28:03 (14 years ago)
Author:
alexandrecorreia
Message:

Ticket #986 - Implementado troca de status e template da lista de contatos ( xsl ).

Location:
sandbox/jabberit_messenger/trophy
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • sandbox/jabberit_messenger/trophy/js/loadIM.js

    r2293 r2312  
    55        var zIndex      = 9001; 
    66         
     7        function configEvents(pObj, pEvent, pHandler) 
     8        { 
     9                if ( typeof pObj == 'object' ) 
     10                { 
     11                        if ( pEvent.substring(0, 2) == 'on' ) 
     12                                pEvent = pEvent.substring(2, pEvent.length); 
     13 
     14                        if ( pObj.addEventListener ) 
     15                                pObj.addEventListener(pEvent, pHandler, false); 
     16                        else if ( pObj.attachEvent ) 
     17                                pObj.attachEvent('on' + pEvent, pHandler); 
     18                } 
     19        } 
     20         
    721        function TrophyIMChatArea() 
    822        { 
     23                /* 
    924                var winImChatArea =  
    1025                { 
     
    2338                }; 
    2439                 
    25                 //_winBuild( winImChatArea ); 
    26                  
    27                 //return '<div id="trophyimchat"><div id="trophyimchattabs"/></div>'; 
     40                _winBuild( winImChatArea ); 
     41                 
     42                return '<div id="trophyimchat"><div id="trophyimchattabs"/></div>'; 
     43                */ 
    2844        } 
    2945         
     
    8399        { 
    84100                setXTools();                     
    85                  
     101 
    86102                var winRosterDiv =  
    87103                { 
     
    97113                         title                  : "Contatos - Expresso Messenger", 
    98114                         closeAction    : "hidden", 
    99                          content                : '<div id="trophyimroster" />' + TrophyIMStatusDiv()    
     115                         content                : _xtools.parse(_xtools.xml("contacts_list"),"contactsList.xsl")         
    100116                }; 
    101117                 
    102118                _winBuild( winRosterDiv ); 
    103                  
    104                 //return '<div id="trophyimroster" />';  
    105119        } 
    106120         
     
    123137        { 
    124138        var statusDiv = '<div id="trophyimstatus">' + 
    125                                                 '<span>Status:</span>' + 
     139                                                '<span>Status::::</span>' + 
    126140                                                '<span id="trophyimstatuslist">Select box</span>' + 
    127141                                                '<br/>' +  
     
    129143                                                        '<input type="button" value="disconnect" onclick="TrophyIM.logout()"/>' + 
    130144                                                '</form>' + 
     145                                                        '<input type="button" value="DND" onclick="TrophyIM.setTest(\'dnd\')">'+ 
     146                                                        '<input type="button" value="AWAY" onclick="TrophyIM.setTest(\'away\')">'+ 
     147                                                        '<input type="button" value="XA" onclick="TrophyIM.setTest(\'xa\')">'+ 
     148                                                        '<input type="button" value="INVISIBLE" onclick="TrophyIM.setTest(\'invisible\')">'+ 
     149                                                        '<input type="button" value="UNAVAILABLE" onclick="TrophyIM.setTest(\'unavailable\')">'+ 
     150                                                        '<input type="button" value="AVAILABLE" onclick="TrophyIM.setTest(\'available\')">'+ 
    131151                                        '</div>'; 
    132152                 
     
    216236        function loadIM() 
    217237        { 
    218  
    219238                var files =     [ 
    220239                                 'js/xtools.js', 
     
    222241                                 'js/makeW.js', 
    223242                                 'css/trophyim.css', 
    224                                  'css/window_azul.css' 
     243                                 //'css/window_azul.css' 
    225244                                 //'css/window_cataratas.css' 
    226245                                 //'css/window_celepar.css' 
     
    229248                                 //'css/window_escritorio.css' 
    230249                                 //'css/window_metropole.css' 
    231                                  //'css/window_rochas.css' 
     250                                 'css/window_rochas.css' 
    232251                            ]; 
    233252                 
    234253                loadScripts(files); 
    235                  
    236254        } 
    237255         
     
    239257        loadIM.prototype.getZIndex                      = getZindex; 
    240258        loadIM.prototype.parse                          = parse; 
     259        loadIM.prototype.configEvents           = configEvents; 
    241260         
    242261        loadIM.prototype.HTMLSnippets           = new HTMLSnippets; 
  • sandbox/jabberit_messenger/trophy/js/trophyim.js

    r2298 r2312  
    499499        } 
    500500        TrophyIM.rosterObj = new TrophyIMRoster(); 
    501         TrophyIM.connection.addHandler(TrophyIM.onVersion, Strophe.NS.VERSION, 
    502         'iq', null, null, null); 
    503         TrophyIM.connection.addHandler(TrophyIM.onRoster, Strophe.NS.ROSTER, 
    504         'iq', null, null, null); 
    505         TrophyIM.connection.addHandler(TrophyIM.onPresence, null, 'presence', 
    506         null, null, null); 
    507         TrophyIM.connection.addHandler(TrophyIM.onMessage, null, 'message', 
    508         null, null,  null); 
     501        TrophyIM.connection.addHandler(TrophyIM.onVersion, Strophe.NS.VERSION, 'iq', null, null, null); 
     502        TrophyIM.connection.addHandler(TrophyIM.onRoster, Strophe.NS.ROSTER, 'iq', null, null, null); 
     503        TrophyIM.connection.addHandler(TrophyIM.onPresence, null, 'presence', null, null, null); 
     504        TrophyIM.connection.addHandler(TrophyIM.onMessage, null, 'message', null, null,  null); 
    509505        //Get roster then announce presence. 
    510         TrophyIM.connection.send($iq({type: 'get', xmlns: Strophe.NS.CLIENT}).c( 
    511         'query', {xmlns: Strophe.NS.ROSTER}).tree()); 
     506        TrophyIM.connection.send($iq({type: 'get', xmlns: Strophe.NS.CLIENT}).c('query', {xmlns: Strophe.NS.ROSTER}).tree()); 
    512507        TrophyIM.connection.send($pres().tree()); 
    513508        TrophyIM.renderChats(); 
     
    577572     *  Presence handler 
    578573     */ 
    579     onPresence : function(msg) { 
    580         Strophe.debug("Presence handler"); 
    581         var type = msg.getAttribute('type') ? msg.getAttribute('type') : 
    582         'available'; 
    583         var show = msg.getElementsByTagName('show').length ? Strophe.getText( 
    584         msg.getElementsByTagName('show')[0]) : type; 
    585         var status = msg.getElementsByTagName('status').length ? Strophe.getText( 
    586         msg.getElementsByTagName('status')[0]) : ''; 
    587         var priority = msg.getElementsByTagName('priority').length ? parseInt( 
    588         Strophe.getText(msg.getElementsByTagName('priority')[0])) : 0; 
    589         TrophyIM.rosterObj.setPresence(msg.getAttribute('from'), priority, 
    590         show, status); 
     574    onPresence : function(msg) 
     575        { 
     576                //alert('Function onPresence'); 
     577                 
     578                Strophe.debug("Presence handler"); 
     579        var type = msg.getAttribute('type') ? msg.getAttribute('type') : 'available'; 
     580        var show = msg.getElementsByTagName('show').length ? Strophe.getText(msg.getElementsByTagName('show')[0]) : type; 
     581        var status = msg.getElementsByTagName('status').length ? Strophe.getText(msg.getElementsByTagName('status')[0]) : ''; 
     582        var priority = msg.getElementsByTagName('priority').length ? parseInt(Strophe.getText(msg.getElementsByTagName('priority')[0])) : 0; 
     583                TrophyIM.rosterObj.setPresence(msg.getAttribute('from'), priority, show, status); 
     584                 
    591585        return true; 
    592586    }, 
     
    678672                         id_window              : "window_chat_area_" + barjid, 
    679673                         width                  : 387, 
    680                          height                 : 355, 
     674                         height                 : 365, 
    681675                         top                    : 100, 
    682676                         left                   : 400, 
     
    691685         
    692686        _winBuild(winChatBox) 
     687                 
     688                loadIM.configEvents( 
     689                        document.getElementById( barjid + '__sendBox'), 
     690                        'onkeyup', function(e) 
     691                        { 
     692                                if( e.keyCode == 13 ) 
     693                                { 
     694                                        TrophyIM.sendMessage( barjid ); 
     695                                        document.getElementById( barjid + '__sendBox').value = ''; 
     696                                        return false; 
     697                                } 
     698                        } 
     699                ); 
    693700                 
    694701        /* 
     
    762769     *    (String) tab_div - tab div element to alter class on 
    763770     */ 
    764     setTabPresence : function(jid, tab_div) { 
    765         var presence = TrophyIM.rosterObj.getPresence(jid); 
     771    setTabPresence : function(jid, tab_div) 
     772        { 
     773        alert('function setTabPresence'); 
     774                 
     775                var presence = TrophyIM.rosterObj.getPresence(jid); 
    766776        tab_div.className = tab_div.className.replace(" trophyimchattab_av", ""); 
    767777        tab_div.className = tab_div.className.replace(" trophyimchattab_aw", ""); 
     
    10601070        tab_item.parentNode.parentNode.removeChild(tab_item.parentNode); 
    10611071    }, 
    1062     /** Function: sendMessage 
     1072     
     1073        setPresence : function() 
     1074        { 
     1075                if( arguments.length > 0 ) 
     1076                { 
     1077                        //alert('Args 0 : ' + arguments[0]); 
     1078                        TrophyIM.connection.send($pres( ).c('show').t(arguments[0])); 
     1079                } 
     1080        }, 
     1081         
     1082        /** Function: sendMessage 
    10631083     * 
    10641084     *  Send message from chat input to user 
     
    10711091        { 
    10721092                var jidTo = arguments[0]; 
    1073                 var message_input = document.getElementById(jidTo + "__sendBox"); 
     1093                var message_input = document.getElementById(jidTo + "__sendBox").value; 
    10741094             
    1075                 if( message_input.value.replace(/^\s+|\s+$/g,"") != "" ) 
     1095                if( ( message_input = message_input.replace(/^\s+|\s+$|^\n|\n$/g,"") ) != "" ) 
    10761096                { 
    10771097                        // Send Message 
    1078                         TrophyIM.connection.send($msg({to: jidTo, from: TrophyIM.connection.jid, type: 'chat'}).c('body').t(message_input.value).tree()); 
     1098                        TrophyIM.connection.send($msg({to: jidTo, from: TrophyIM.connection.jid, type: 'chat'}).c('body').t(message_input).tree()); 
    10791099                         
    10801100                        var message =  
    10811101                        { 
    10821102                                        contact : "<font style='font-weight:bold; color:red;'>" + "Eu" + "</font>", 
    1083                                         msg : message_input.value 
     1103                                        msg : message_input 
    10841104                        } 
    1085                          
    1086                         message_input.value = ''; 
    10871105                         
    10881106                        // Add Message in chatBox; 
     
    11941212     *    (String) status: status attribute from presence 
    11951213     */ 
    1196     this.setPresence = function(fulljid, priority, show, status) { 
    1197         var barejid = Strophe.getBareJidFromJid(fulljid); 
     1214    this.setPresence = function(fulljid, priority, show, status) 
     1215        { 
     1216                var barejid = Strophe.getBareJidFromJid(fulljid); 
    11981217        var resource = Strophe.getResourceFromJid(fulljid); 
    11991218        var jid_lower = barejid.toLowerCase(); 
    1200         if(show != 'unavailable') { 
    1201             if (!this.roster[jid_lower]) { 
     1219         
     1220                if( show != 'unavailable') 
     1221                { 
     1222            if (!this.roster[jid_lower]) 
     1223                        { 
    12021224                this.addContact(barejid, 'not-in-roster'); 
    12031225            } 
    1204             var presence = { 
     1226            var presence = 
     1227                        { 
    12051228                resource:resource, priority:priority, show:show, status:status 
    12061229            } 
    1207             if (!this.roster[jid_lower]['presence']) { 
     1230             
     1231                        if (!this.roster[jid_lower]['presence']) 
     1232                        { 
    12081233                this.roster[jid_lower]['presence'] = {} 
    12091234            } 
    12101235            this.roster[jid_lower]['presence'][resource] = presence 
    1211         } else if (this.roster[jid_lower] && this.roster[jid_lower]['presence'] 
    1212         && this.roster[jid_lower]['presence'][resource]) { 
     1236        } 
     1237                else if (this.roster[jid_lower] && this.roster[jid_lower]['presence'] && this.roster[jid_lower]['presence'][resource]) 
     1238                { 
    12131239            delete this.roster[jid_lower]['presence'][resource]; 
    12141240        } 
    1215         this.addChange(jid_lower); 
    1216         if (TrophyIM.activeChats['divs'][jid_lower]) { 
    1217             TrophyIM.setTabPresence(jid_lower,  
    1218             TrophyIM.activeChats['divs'][jid_lower]['tab']); 
     1241         
     1242                this.addChange(jid_lower); 
     1243         
     1244                if (TrophyIM.activeChats['divs'][jid_lower]) 
     1245                { 
     1246            TrophyIM.setTabPresence(jid_lower, TrophyIM.activeChats['divs'][jid_lower]['tab']); 
    12191247        } 
    12201248    } 
  • sandbox/jabberit_messenger/trophy/xsl/chatBox.xsl

    r2298 r2312  
    99                 
    1010                        <div> 
    11                                 <div id="{$idChatBox}" style="height:190px; width:370px; overflow-y:scroll"></div> 
     11                                <div id="{$idChatBox}" style="height:190px; width:370px; overflow-y:scroll;"></div> 
    1212                                <div style="margin:2px;"> 
    13                                         <div style="margin-top:0px; width:70px; height:93px; position:relative; float:right; background-image:url('images/photo.png');"></div> 
    14                                         <textarea id="{$jidTo}__sendBox" class="trophyimchatinput" rows="5" cols="38"></textarea> 
    15                                         <div style="margin-left:2px;"> 
     13                                        <textarea id="{$jidTo}__sendBox" class="trophyimchatinput" style="padding-left: 78px; height:130px; width:285px;"></textarea> 
     14                                        <div style="position:relative;margin:-126px 0 0 3px; border:0px solid red;width:70px; height:93px; background-image:url('images/photo.png');"></div> 
     15                                         
     16                                        <div style="margin: 3px 0 0 4px;"> 
    1617                                                <input type="button" value="Send" onclick="TrophyIM.sendMessage('{$jidTo}')"/> 
    1718                                        </div> 
Note: See TracChangeset for help on using the changeset viewer.