Ignore:
Timestamp:
02/01/08 10:48:43 (16 years ago)
Author:
niltonneto
Message:
 
Location:
trunk/instant_messenger/js
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/instant_messenger/js/client.js

    r151 r164  
    11var con = new Connector; 
     2var disconnected = false; 
     3 
    24function client() 
    35{ 
     
    57        var buffer = ''; 
    68        var xtools = new XTools; 
    7         var disconnected = false; 
     9 
    810        function request(data) 
    911        { 
     
    2729                        im_window.elementC('_contacts_im_').innerHTML  = xtools.parse(XmlDoc,'disconnected.xsl'); 
    2830                        func.byId('img_status_im').src = im_unavailable.src; 
     31                        im.status = 'type=unavailable'; 
     32                        im.statusFlag = 'unavailable';                                   
     33 
     34                        //im_window.visible('_contacts_im_','block'); 
    2935                } 
    3036                else if ( data.lastIndexOf('>') == data.length - 1) 
     
    5359 
    5460                        var node = xmlDoc.documentElement.firstChild; 
     61 
    5562                        while ( node ) 
     63                        { 
    5664                                with ( node ) 
    5765                                { 
    5866                                        jabber.doIt(nodeName, node); 
    59                                         node = nextSibling; 
     67                                        //node = nextSibling; 
    6068                                } 
     69                                node = node.nextSibling; 
     70                        } 
    6171                } 
    6272                else 
  • trunk/instant_messenger/js/images.js

    r151 r164  
    2424        im_photo.src = path_im + 'templates/default/images/photo.png'; 
    2525         
     26        var im_photo_1 = new Image(); 
     27        im_photo_1.src = path_im + 'templates/default/images/photo_1.png'; 
     28 
    2629        var im_group_open = new Image(); 
    2730        im_group_open.src = path_im + 'templates/default/images/group_open.gif'; 
  • trunk/instant_messenger/js/jabber.js

    r157 r164  
    4444                { 
    4545                        var XmlDoc = "<layer>" + 
    46                                                         "<lang1>" + im.get_lang("Nickname") +"</lang1>" + 
     46                                                        "<lang1>" + im.get_lang("Nickname") + "</lang1>" + 
    4747                                                        "<lang2>" + im.get_lang("Add Contact") + "</lang2>" + 
    4848                                                        "<lang3>" + im.get_lang("Preferences") + "</lang3>" + 
    49                                                         "<nickname>" + im.get_lang("Username") +"</nickname>" + 
    50                                                         "<path>"+path_im+"</path>" + 
     49                                                        "<nickname>" + im.get_lang("Username") + "</nickname>" + 
     50                                                        "<path>" + path_im + "</path>" + 
    5151                                                 "</layer>"; 
     52 
    5253                        im_window.load('_contacts_im_','instant_messenger_content','<title>.::Expresso Messenger::.</title>','window.xsl','',true,true,false); 
    5354                        im_window.elementC('_contacts_im_').innerHTML  = _this.xtools.parse(XmlDoc,'layer.xsl'); 
    5455                        im_window.elementC('_contacts_im_').innerHTML += _this.xtools.parse(pContacts, 'contacts.xsl'); 
    55                          
     56                                                 
    5657                        var element = func.byId('im_contact_list').firstChild; 
    5758 
     
    6768                        } 
    6869                         
    69                         if(im.nickname == null) 
    70                         { 
    71                                 im.request_vcard('this','layer'); 
     70                        if(func.byId('im_avatar').src === im_photo.src) 
     71                        {                        
     72                                im.request_vcard('this',false); 
    7273                                im.ldap_photo('im_avatar'); 
    7374                        } 
    74                         else 
    75                                 func.byId('im_layer_nickname').innerHTML = im.nickname; 
    7675                } 
    7776 
     
    8180                        { 
    8281                                case 'contacts' : readContacts(pIq); break; 
    83                                 case 'vCard' : readVcard(pIq); break; 
     82                                case 'vCard' :  
     83                                case 'vCard_user' :  
     84                                        readVcard(pIq);  
     85                                        break; 
    8486                        } 
    8587                } 
     
    9395                                from = from.substr(0,from.indexOf('/')); 
    9496 
     97                                if(func.byId('iframe_' + from) != null) 
     98                                        func.byId('iframe_' + from).parentNode.removeChild(func.byId('iframe_' + from)); 
     99 
    95100                                var win; 
    96                                 if ( !(win = im_window.elementC(from)) ) 
    97                                 { 
    98                                         im_window.load(from, 'instant_messenger_content', '<title>.:: Expresso Messenger ::.</title>', 'chat.xsl', '310', true, true, true); 
    99                                         func.byId(from + '_avatar').src = path_im + "/templates/default/images/photo.png"; 
    100  
     101 
     102                                function include_iframe() 
     103                                { 
    101104                                        win = im_window.elementC(from); 
    102  
     105                                         
    103106                                        var iframe = document.createElement('iframe'); 
    104107                                        iframe.id = 'iframe_' + from; 
     
    108111                                        iframe.style.margin = '0'; 
    109112                                        iframe.style.padding = '0' 
    110  
     113                                         
    111114                                        var _messages_ = win.firstChild.firstChild.nextSibling.nextSibling; 
    112115                                        _messages_.appendChild(iframe); 
    113  
     116                                         
    114117                                        iframe.contentWindow.document.write('<html><body id="' + from + '" style="margin:0px;padding:0px"></body></html>'); 
    115118                                        iframe.contentWindow.document.close(); 
    116119                                        iframe.contentWindow.document.designMode = "On"; 
    117120                                        iframe.contentWindow.focus(); 
    118  
     121                                 
    119122                                        function keypress_handler(e) 
    120123                                        { 
     
    163166                                                obj.attachEvent('onkeyup', keyup_handler); 
    164167                                        } 
    165                                 }else 
     168                                }                                
     169 
     170                                if ( !(win = im_window.elementC(from)) ) 
     171                                { 
     172                                        im_window.load(from, 'instant_messenger_content', '<title>.:: Expresso Messenger ::.</title>', 'chat.xsl', '310', true, true, true); 
     173                                        //im_window.visible(from,'block'); 
     174                                        func.byId(from + '_avatar').src = path_im + "/templates/default/images/photo.png"; 
     175                                        include_iframe(); 
     176                                } 
     177                                else 
     178                                { 
    166179                                        im_window.load(from, '', '', '', '', true, true, true); 
     180                                        //im_window.visible(from,'block'); 
     181                                        include_iframe(); 
     182                                } 
    167183 
    168184                                if ( win ) 
    169185                                { 
    170186                                        if(!(im.nickname_contacts[from])) 
    171                                                 im.request_vcard(from,'nickname'); 
     187                                                im.request_vcard(from, false); 
    172188 
    173189                                        win = win.firstChild.firstChild; 
     
    183199                function readPresence(pPresence) 
    184200                { 
    185                         var jidFrom = pPresence.getAttribute('from'); 
    186                         jidFrom = jidFrom.substr(0,jidFrom.indexOf('/')); 
    187  
    188                         if(pPresence.getAttribute('type')) 
    189                         { 
    190                                 switch(pPresence.getAttribute('type')) 
    191                                 { 
    192                                         case 'subscribe' : 
    193                                                         if(!func.byId(pPresence.getAttribute('from'))) 
     201                        //@TODO: presenca antes da lista ocasiona erros 
     202                        //verificar e retirar o controle de erros abaixo 
     203                        try 
     204                        { 
     205                                var jidFrom = pPresence.getAttribute('from'); 
     206                                jidFrom = jidFrom.substr(0,jidFrom.indexOf('/')); 
     207         
     208                                if(pPresence.getAttribute('type')) 
     209                                { 
     210                                        switch(pPresence.getAttribute('type')) 
     211                                        { 
     212                                                case 'subscribe' : 
     213                                                                if(func.byId(pPresence.getAttribute('from'))) 
     214                                                                { 
     215                                                                        if(confirm('Autorizar o usuário ' + pPresence.getAttribute('from') + '?')) 
     216                                                                                im.subscription(pPresence.getAttribute('from'),'subscribed'); 
     217                                                                        else 
     218                                                                                im.subscription(pPresence.getAttribute('from'),'unsubscribe'); 
     219                                                                } 
     220                                                                else 
     221                                                                { 
     222                                                                        if(!func.byId(pPresence.getAttribute('from'))) 
     223                                                                        { 
     224                                                                                if(confirm('O usuário ' + pPresence.getAttribute('from') + ' quer adicioná-lo ?')) 
     225                                                                                { 
     226                                                                                        im.addrequest(pPresence.getAttribute('from')); 
     227                                                                                        im.subscription(pPresence.getAttribute('from'),'subscribed'); 
     228                                                                                } 
     229                                                                                else 
     230                                                                                        im.subscription(pPresence.getAttribute('from'),'unsubscribe'); 
     231                                                                        }else 
     232                                                                                im.subscription(pPresence.getAttribute('from'),pPresence.getAttribute('type')); 
     233                                                                } 
     234                                                                break; 
     235                                                case 'subscribed' : 
     236                                                                im.subscription(pPresence.getAttribute('from'),pPresence.getAttribute('type')); 
     237                                                                break; 
     238                                                case 'unsubscribed' :                                            
     239                                                                //alert('O usuário ' + pPresence.getAttribute('from') + ' não quer mais papo !'); 
     240                                                                break; 
     241                                                case 'unsubscribe' :                             
     242                                                                alert('O usuário ' + pPresence.getAttribute('from') + ' negou seu pedido !'); 
     243                                                                break; 
     244                                                case 'unavailable' : 
     245                                                                func.byId('img_' + jidFrom).src = eval('im_' + pPresence.getAttribute('type') + '.src'); 
     246                                                                func.confEl(func.byId(jidFrom),"style","margin-left:15px;cursor:pointer;display:none;");                                                         
     247                                                                break; 
     248                                                case 'available' : 
     249                                                                func.byId('img_' + jidFrom).src = eval('im_' + pPresence.getAttribute('type') + '.src'); 
     250                                                                func.confEl(func.byId(jidFrom),"style","margin-left:15px;cursor:pointer;display:block;");                                                                                                                
     251                                                                break; 
     252                                        } 
     253                                } 
     254                                else 
     255                                { 
     256                                        var node = pPresence.firstChild; 
     257                                        while( node ) 
     258                                        { 
     259                                                if(node.hasChildNodes()) 
     260                                                {                                                
     261                                                        switch(node.nodeName) 
    194262                                                        { 
    195                                                                 if(confirm('O usuario ' + pPresence.getAttribute('from') + ' quer adicioná-lo ?')) 
    196                                                                         im.addrequest(pPresence.getAttribute('from')); 
    197                                                                 else 
    198                                                                         im.subscription(pPresence.getAttribute('from'),'unsubscribe'); 
    199                                                         }else 
    200                                                                 im.subscription(pPresence.getAttribute('from'),pPresence.getAttribute('type')); 
    201                                                         break; 
    202                                         case 'subscribed' : 
    203                                                         im.subscription(pPresence.getAttribute('from'),pPresence.getAttribute('type')); 
    204                                                         break; 
    205                                         case 'unsubscribed' :                                            
    206                                                         //alert('O usuário ' + pPresence.getAttribute('from') + ' não quer mais papo !'); 
    207                                                         break; 
    208                                         case 'unsubscribe' :                             
    209                                                         alert('O usuário ' + pPresence.getAttribute('from') + ' negou seu pedido !'); 
    210                                                         break; 
    211                                         case 'unavailable' : 
    212                                                         func.byId('img_' + jidFrom).src = eval('im_' + pPresence.getAttribute('type') + '.src'); 
    213                                                         func.confEl(func.byId(jidFrom),"style","margin-left:15px;cursor:pointer;display:none;");                                                         
    214                                                         break; 
    215                                         case 'available' : 
    216                                                         func.byId('img_' + jidFrom).src = eval('im_' + pPresence.getAttribute('type') + '.src'); 
    217                                                         break; 
    218                                 } 
    219                         } 
    220                         else 
    221                         { 
    222                                 var node = pPresence.firstChild; 
    223                                 while( node ) 
    224                                 { 
    225                                         if(node.hasChildNodes()) 
    226                                         {                                                
    227                                                 switch(node.nodeName) 
    228                                                 { 
    229                                                         case "show" :                                    
    230                                                                         func.byId('img_' + jidFrom).src = eval('im_' + node.firstChild.nodeValue + '.src'); 
    231                                                                         func.confEl(func.byId(jidFrom),"style","margin-left:15px;cursor:pointer;display:block;");                                                        
    232                                                                         func.byId('status_' + jidFrom).innerHTML = " "; 
    233                                                                         func.confEl(func.byId('status_' + jidFrom), "style", "font-size:8pt; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; display:none;"); 
    234                                                                         break; 
    235                                                         case "status" :  
    236                                                                         func.byId('status_' + jidFrom).innerHTML = ( node.firstChild.nodeValue ) ? node.firstChild.nodeValue : "" ; 
    237                                                                         func.confEl(func.byId('status_' + jidFrom), "style", "font-size:8pt; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; display:block;"); 
    238                                                                         break; 
    239                                                         default : 
    240                                                                         func.byId('img_' + jidFrom).src = im_available.src;                                                                      
    241                                                                         func.confEl(func.byId(jidFrom),"style","margin-left:15px;cursor:pointer;display:block;");                                                        
    242                                                                         func.byId('status_' + jidFrom).innerHTML = " "; 
    243                                                                         func.confEl(func.byId('status_' + jidFrom), "style", "font-size:8pt; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; display:none;"); 
    244                                                                         break; 
     263                                                                case "show" :                                    
     264                                                                                func.byId('img_' + jidFrom).src = eval('im_' + node.firstChild.nodeValue + '.src'); 
     265                                                                                func.confEl(func.byId(jidFrom),"style","margin-left:15px;cursor:pointer;display:block;");                                                        
     266                                                                                func.byId('status_' + jidFrom).innerHTML = " "; 
     267                                                                                func.confEl(func.byId('status_' + jidFrom), "style", "font-size:8pt; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; display:none;"); 
     268                                                                                break; 
     269                                                                case "status" :  
     270                                                                                func.byId('status_' + jidFrom).innerHTML = ( node.firstChild.nodeValue ) ? node.firstChild.nodeValue : "" ; 
     271                                                                                func.confEl(func.byId('status_' + jidFrom), "style", "font-size:8pt; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; display:block;"); 
     272                                                                                break; 
     273                                                                default : 
     274                                                                                func.byId('img_' + jidFrom).src = im_available.src;                                                                      
     275                                                                                func.byId('status_' + jidFrom).innerHTML = " "; 
     276                                                                                func.confEl(func.byId('status_' + jidFrom), "style", "font-size:8pt; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; display:none;"); 
     277                                                                                break; 
     278                                                        } 
    245279                                                } 
    246                                         } 
    247                                         node = node.nextSibling;                                         
    248                                 } 
    249  
    250                                 /*if(!im.contacts_off_line) 
    251                                         setTimeout("im.off_line('none')",2000);*/ 
     280                                                node = node.nextSibling;                                         
     281                                        } 
     282         
     283                                        if(!im.contacts_off_line) 
     284                                                setTimeout("im.off_line()",3000); 
     285                                } 
     286                        } 
     287                        catch(e) 
     288                        { 
    252289                        } 
    253290                } 
     
    255292                function readVcard(pVcard) 
    256293                { 
    257                         switch(im.vcard) 
    258                         { 
    259                                 case "layer" : 
     294                        switch(pVcard.getAttribute('id')) 
     295                        { 
     296                                case "vCard_user" : 
     297 
    260298                                        var vcard = pVcard.firstChild; 
    261299                                        var cc = vcard.firstChild; 
    262                                          
    263300                                        while( cc ) 
    264301                                        { 
    265302                                                if(cc.nodeName == "NICKNAME" || cc.nodeName == "nickname") 
    266303                                                { 
    267                                                         func.byId('im_layer_nickname').innerHTML = cc.firstChild.nodeValue; 
    268                                                         im.nickname = " "; 
    269304                                                        if(cc.firstChild.nodeValue) 
    270                                                                 im.nickname = cc.firstChild.nodeValue; 
     305                                                                func.byId('im_layer_nickname').innerHTML = cc.firstChild.nodeValue;                                                              
    271306                                                } 
    272  
    273307                                                cc = cc.nextSibling; 
    274308                                        } 
    275  
     309                                        if( im.vcard ) 
     310                                                templates.vcard_user(pVcard); 
    276311                                        break; 
    277312 
    278                                 case "user"     : 
    279                                         templates.vcard_user(pVcard); 
    280                                         im.vcard = "layer";                                      
    281                                         break; 
    282  
    283                                 case "contact" : 
    284                                         templates.vcard_contact(pVcard); 
    285                                         im.vcard = "layer";                                      
    286                                         break; 
    287                                          
    288                                 case "nickname" : 
     313                                case "vCard" : 
     314 
    289315                                        var vcard = _this.xtools.parse(pVcard,'nickname.xsl');  
    290                                         im.vcard = "layer";      
    291                                         im.nickname_contacts[vcard.substr(0,vcard.indexOf(','))] = vcard.substr(vcard.indexOf(',')+1); 
     316                                        im.nickname_contacts[vcard.substr(0,vcard.indexOf(','))] = ( vcard.substr(vcard.indexOf(',')+1) ) ? vcard.substr(vcard.indexOf(',')+1) : vcard.substr(0,vcard.indexOf(',')) ; 
     317                                        if( im.vcard ) 
     318                                                templates.vcard_contact(pVcard); 
    292319                                        break; 
    293320                        } 
  • trunk/instant_messenger/js/load.js

    r151 r164  
    1717        }; 
    1818     
     19        function load_im_contacts() 
     20        { 
     21                im_window.load('_contacts_im_','instant_messenger_content', '<title>Expresso Messenger</title>', 'window.xsl','',true,true,true); 
     22                //im_window.visible('_contacts_im_','block'); 
     23        } 
     24         
    1925        function shortcut_im() 
    2026        { 
     
    2228                if((local = func.byId('user_info')) && !(func.byId('instant_messenger_content'))) 
    2329                { 
    24                         local.innerHTML = '<img src="' + im_fast_menu.src + '" onclick="javascript:templates.fast_menu();"/>' + 
    25                                                           '<img id="im_status_src" src="' + im_available.src + '" onclick="javascript:im_window.load(\'_contacts_im_\', \'instant_messenger_content\', \'<title>Expresso Messenger</title>\', \'window.xsl\',\'\',true,true,true);"/>' +  
    26                                                           local.innerHTML + '<div id="instant_messenger_content"><span id="fast_menu_im"/></div>'; 
     30                        var local_old = local.innerHTML ; 
     31                        local.innerHTML  = '<img src="' + im_fast_menu.src + '" onclick="javascript:templates.fast_menu();">'; 
     32                        local.innerHTML += '<img id="im_status_src" src="' + im_available.src + '" onclick="javascript:load_im_contacts();"/>'; 
     33                        local.innerHTML += local_old; 
     34                        local.innerHTML += '<div id="instant_messenger_content"></div><span id="fast_menu_im"/>'; 
    2735                } 
     36 
    2837                // Carregando Preferências do usuário 
    2938                im.get_preferences(); 
  • trunk/instant_messenger/js/templates.js

    r151 r164  
    2626                im_window.elementC('add_user_im').innerHTML  = this.xtools.parse(XmlDoc,'add_user.xsl'); 
    2727                im.ldap(); 
     28                //im_window.visible('add_user_im','block'); 
    2829        }, 
    2930 
     
    9091                im_window.elementC('my_settings_im').innerHTML = this.xtools.parse(XmlDoc,'mysettings.xsl'); 
    9192                im.get_preferences(); 
     93                //im_window.visible('my_settings_im','block'); 
    9294        }, 
    9395         
     
    121123 
    122124                if(!(im.nickname_contacts[pJid])) 
    123                         im.request_vcard(pJid,'nickname'); 
     125                        im.request_vcard(pJid, false); 
    124126 
    125127                if(func.byId('img_' + pJid).src != im_unavailable.src ) 
    126128                { 
    127129                        im_window.load(pJid, 'instant_messenger_content', '<title>.:: Expresso Messenger ::.</title>', 'chat.xsl','310',true,true,true); 
     130                        //im_window.visible(pJid,'block');                       
    128131                        func.byId(pJid + '_avatar').src = path_im + "/templates/default/images/photo.png"; 
     132 
     133                        if(func.byId('iframe_' + pJid) != null) 
     134                                func.byId('iframe_' + pJid).parentNode.removeChild(func.byId('iframe_' + pJid)); 
    129135 
    130136                        var win = im_window.elementC(pJid); 
     
    204210                                                "<lang2>" + im.get_lang("Group") + "</lang2>" + 
    205211                                                "<lang3>" + im.get_lang("Remove") + "</lang3>" + 
    206                                                 "<lang4>(Re)-requisitar Autorização</lang4>" + 
     212                                                "<lang4>" + im.get_lang("It requisition permission")+ "</lang4>" + 
    207213                                                "<lang5>" + im.get_lang("See Info") + "</lang5>" + 
    208214                                                "<jid>" + pJid + "</jid>" + 
    209215                                                "<path>" + path_im + "</path>" +                 
    210216                                         "</options>"; 
    211                 menu_action.menu('sub_' + pJid, this.xtools.parse(XmlDoc,'options.xsl')); 
    212             func.byId('sub_' + pJid).style.zIndex = '99999'; 
    213                 func.byId('sub_' + pJid).style.left = parseInt(func.byId('sub_' + pJid).style.left) - 5;             
    214             func.byId('sub_' + pJid).style.position = 'absolute'; 
    215                  
     217 
     218                var posX = parseInt(func.byId('sub_' + pJid).offsetLeft) - parseInt(func.byId('sub_' + pJid).parentNode.scrollLeft); 
     219                var posY = parseInt(func.byId('sub_' + pJid).offsetTop) - parseInt(func.byId('sub_' + pJid).parentNode.scrollTop); 
     220 
     221                menu_action.menu('im_sub_menu', this.xtools.parse(XmlDoc,'options.xsl')); 
     222            func.byId('im_sub_menu').style.zIndex = '99999'; 
     223                func.byId('im_sub_menu').style.top = posY; 
     224                func.byId('im_sub_menu').style.left = posX + 20;             
     225            func.byId('im_sub_menu').style.position = 'absolute'; 
    216226        }, 
    217227 
     
    224234                                                "<function2>templates.remove_user();</function2>" + 
    225235                                                "<lang3>" + im.get_lang("Vcard") +"</lang3>" + 
    226                                                 "<function3>im.request_vcard('this','user')</function3>" + 
     236                                                "<function3>im.request_vcard('this',true)</function3>" + 
    227237                                                "<lang4>" + im.get_lang("Preferences") + "</lang4>" + 
    228238                                                "<function4>templates.mysettings()</function4>" + 
     
    246256                im_window.elementC('remove_user_im').innerHTML = this.xtools.parse(XmlDoc,'remove_user.xsl'); 
    247257                im.get_contacts(); 
     258                //im_window.visible('remove_user_im','block');           
    248259        }, 
    249260 
     
    264275        "vcard_contact" : function(pXml)         
    265276        { 
     277                im.vcard = false; 
    266278                var title = "Informações do Contato - Expresso"; 
    267279                var XmlDoc = "<vcard_contact>" +  
     
    279291                im_window.load('vcard_contact_im','instant_messenger_content','<title>.:: ' + title +' ::.</title>','window.xsl','390',true,true,true); 
    280292                im_window.elementC('vcard_contact_im').innerHTML = this.xtools.parse(XmlDoc,'vcard_contacts.xsl'); 
     293                //im_window.visible('vcard_contact_im','block');                 
    281294        }, 
    282295 
    283296        "vcard_user" : function(pXml) 
    284297        { 
     298                im.vcard = false; 
    285299                var title = "Informações Pessoais - Expresso"; 
    286300                var XmlDoc = "<vcard_user>" +    
     
    298312                im_window.load('vcard_user_im','instant_messenger_content','<title>.:: ' + title +' ::.</title>','window.xsl','470',true,true,true); 
    299313                im_window.elementC('vcard_user_im').innerHTML = this.xtools.parse(XmlDoc,'vcard_user.xsl'); 
     314                //im_window.visible('vcard_user_im','block');            
    300315        } 
    301316} 
Note: See TracChangeset for help on using the changeset viewer.