Ignore:
Timestamp:
04/06/10 18:13:32 (14 years ago)
Author:
alexandrecorreia
Message:

Ticket #986 - Adicao de contatos com resultados da busca do ldap e exclusao de contatos da lista.

Location:
sandbox/jabberit_messenger/trophy_expresso/js
Files:
1 added
3 edited

Legend:

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

    r2421 r2437  
    44                var conn        = null;  
    55         
    6                 function addContacts() 
     6                function addContact() 
    77                { 
    88                        var jidFrom             = loadIM.getUserCurrent().jid; 
     
    1111                        var group               = document.getElementById('user_group_jabberIM').value; 
    1212                         
    13                         alert( jidFrom + "\n" + jidTo + "\n" + name + "\n" + group ); 
    14                          
    15                         //TrophyIM.addContacts( jidFrom, jidTo, name, group ); 
    16                          
     13                        TrophyIM.addContact( jidFrom, jidTo, name, group ); 
     14                         
     15                        _winBuild('add_user_info','remove'); 
    1716                } 
    1817                 
     
    7473                        var element             = ( Element.target ) ? Element.target : Element.srcElement; 
    7574                        var infoUser    = null;          
     75                        var img                 = document.createElement('img'); 
    7676                         
    7777                        if( element.getAttribute('value') ) 
     
    8585                                        'group'                         : element.getAttribute('ou'), 
    8686                                        'name'                          : element.getAttribute('name').substring( 0, element.getAttribute('name').indexOf(' ')), 
     87                                        'ou'                            : element.getAttribute('ou'), 
     88                                        'selectBoxOptions'      : "grupo1; grupo2; grupo3", 
    8789                                        'uid'                           : element.getAttribute('value').substring( element.getAttribute('value').indexOf(';') + 1 ) 
    8890                                }; 
     
    9799                                        'lang_name_contact'     : "Contato",                                     
    98100                                        'group'                         : element.parentNode.getAttribute('ou'), 
    99                                         'name'                          : element.parentNode.getAttribute('name').substring( 0, element.parentNode.getAttribute('name').indexOf(' ')),                                   
     101                                        'name'                          : element.parentNode.getAttribute('name').substring( 0, element.parentNode.getAttribute('name').indexOf(' ')), 
     102                                        'ou'                            : element.parentNode.getAttribute('ou'), 
     103                                        'selectBoxOptions'      : "grupo1; grupo2; grupo3", 
    100104                                        'uid'                           : element.parentNode.getAttribute('value').substring( element.parentNode.getAttribute('value').indexOf(';') + 1) 
    101105                                }; 
     
    105109                        {  
    106110                                        id_window        : "add_user_info", 
    107                                         width            : 355, 
     111                                        width            : 370, 
    108112                                        height           : 190, 
    109113                                        top                      : 85, 
     
    126130                                'lang2'                 : 'Fechar', 
    127131                                'onclickClose'  : '_winBuild("' + winAddUser.id_window + '","remove");', 
    128                                 'onclickSubmit' : 'loadIM.addContacts(this);' 
     132                                'onclickSubmit' : 'loadIM.addContact(this);' 
    129133                        };  
    130134 
    131                         document.getElementById('buttons_adduser').innerHTML = Xtools.parse(Xtools.xml('buttons_main'), 'buttons.xsl', _pButtons);  
     135                        // Add Buttons 
     136                        document.getElementById('buttons_adduser').innerHTML = Xtools.parse(Xtools.xml('buttons_main'), 'buttons.xsl', _pButtons); 
     137                         
     138                        // Select Editable 
     139                        loadIM.setSelectEditable(document.getElementById('user_group_jabberIM')); 
     140                         
     141                        if( element.style.backgroundImage ) 
     142                        { 
     143                                var _img = element.cloneNode( false ); 
     144                                _img.style.width        = '60px'; 
     145                                _img.style.height       = '80px'; 
     146                                _img.style.display      = 'block'; 
     147                                _img.style.backgroundRepeat = 'no-repeat'; 
     148                                                         
     149                        } 
     150                        else 
     151                        { 
     152                                var _img = document.createElement("img"); 
     153                                _img.style.width        = '60px'; 
     154                                _img.style.height       = '80px'; 
     155                                _img.style.display      = 'block'; 
     156                                _img.src                        = path_jabberit + "templates/default/images/photo.png"; 
     157                        } 
     158                         
     159                        with ( document.getElementById('photo_user_ldap_jabber') ) 
     160                        { 
     161                                if( hasChildNodes( ) ) 
     162                                        while( hasChildNodes( ) ) 
     163                                        { 
     164                                                removeNode( firstChild ); 
     165                                        } 
     166                                 
     167                                appendChild( _img ); 
     168                        } 
     169                         
    132170                } 
    133171                 
     
    160198                         
    161199                        _winBuild( windAddUser ); 
     200                         
    162201                } 
    163202         
     
    171210                } 
    172211 
    173                 loadAddUser.prototype.add               = addContacts; 
     212                loadAddUser.prototype.add               = addContact; 
    174213                loadAddUser.prototype.search    = search; 
    175214                loadAddUser.prototype.show              = showForm; 
  • sandbox/jabberit_messenger/trophy_expresso/js/loadIM.js

    r2421 r2437  
    44        var path                        = ""; 
    55        var addUser                     = null; 
    6         var conn                        = null 
     6        var conn                        = null; 
     7        var selectEditable      = null; 
    78        var showhidden          = null; 
     9        var userCurrent         = null; 
    810        var Xtools                      = null; 
    9         var userCurrent         = null; 
    1011        var zIndex                      = 9001; 
    1112         
     
    4243        } 
    4344 
    44         function addContacts() 
     45        function addContact() 
    4546        { 
    4647                if( arguments.length > 0 ) 
     
    145146 
    146147                        var _options = [ 
    147                                                 ['Adicionar Contato', 'loadIM.addContacts();' ], 
     148                                                ['Adicionar Contato', 'loadIM.addContact();' ], 
    148149                                                ['Ajuda', 'alert("2")' ], 
    149150                                                ['Preferências', 'alert("3")'], 
     
    309310 
    310311                        var _options = [ 
    311                                                 ['Autorizar', 'TrophyIM.setAutorization(\''+jid+'\')' ], 
    312                                                 ['Remover', 'Remover : ' + jid ], 
     312                                                ['Autorizar', 'TrophyIM.setAutorization(\''+jid+'\')'], 
     313                                                ['Remover', 'loadIM.removeContact(\''+jid+'\')'], 
    313314                                                ['Renomear', 'Renomear : ' + jid], 
    314315                                                ['Trocar grupo', 'Trocar grupo : ' + jid], 
     
    332333                                showhidden.action('onmouseover', 'onmouseout', _optionsItens); 
    333334                                 
     335                        element.parentNode.onclick              = function(){ showhidden.hiddenObject(false); }; 
    334336                        element.parentNode.onmouseout   = function(){ showhidden.hiddenObject(false); }; 
    335337                        element.parentNode.onmouseover  = function(){ showhidden.hiddenObject(true); }; 
     
    346348                if( arguments.length === 3 ) 
    347349                        return Xtools.parse(Xtools.xml(arguments[0]), arguments[1], arguments[2] ); 
     350        } 
     351         
     352        function removeContact(jid) 
     353        { 
     354                TrophyIM.removeContact(jid); 
    348355        } 
    349356         
     
    385392        } 
    386393         
     394        function setSelectEditable(element) 
     395        { 
     396                if( document.getElementById('selectBox0') == null ) 
     397                        selectEditable.create(element); 
     398        } 
     399         
    387400        function setPresence() 
    388401        { 
     
    458471                                                path_jabberit + 'js/trophyim.js', 
    459472                                                path_jabberit + 'js/AddUser.js', 
     473                                                path_jabberit + 'js/SelectEditable.js', 
    460474                                                path_jabberit + 'templates/default/css/button.css', 
    461475                                                path_jabberit + 'templates/default/css/common.css', 
     476                                                path_jabberit + 'templates/default/css/selectEditableStyle.css', 
    462477                                                path_jabberit + 'templates/default/css/' + theme_jabberit 
    463478                                    ]; 
     
    484499                                        addUser = new addUserIM(Xtools, conn); 
    485500 
     501                                 
     502                                // Object SelectEditable 
     503                                if( selectEditable == null ) 
     504                                        selectEditable = new SelectEditable(); 
     505                                         
    486506                                // Add Jabber in StatusBar; 
    487507                                addIcon(); 
     
    492512         
    493513        loadIM.prototype.actionButton           = actionButton; 
    494         loadIM.prototype.addContacts            = addContacts; 
     514        loadIM.prototype.addContact                     = addContact; 
    495515        loadIM.prototype.configEvents           = configEvents; 
    496516        loadIM.prototype.getUserCurrent         = getUserCurrent; 
     
    501521        loadIM.prototype.loginPage                      = loginPage; 
    502522        loadIM.prototype.parse                          = parse; 
     523        loadIM.prototype.searchUser                     = searchUser 
    503524        loadIM.prototype.setPresence            = setPresence; 
    504         loadIM.prototype.searchUser                     = searchUser 
    505525        loadIM.prototype.setStatusJabber        = setStatusJabber; 
     526        loadIM.prototype.setSelectEditable      = setSelectEditable; 
     527        loadIM.prototype.removeContact          = removeContact; 
    506528        loadIM.prototype.rosterDiv                      = rosterDiv; 
    507529         
  • sandbox/jabberit_messenger/trophy_expresso/js/trophyim.js

    r2397 r2437  
    66 */ 
    77 
    8 var TROPHYIM_BOSH_SERVICE       = "/proxy/xmpp-httpbind";  //Change to suit 
     8var TROPHYIM_BOSH_SERVICE       = "/proxy/ejabberd";  //Change to suit 
    99 
    1010var TROPHYIM_LOG_LINES          = 200; 
     
    651651         *  
    652652         *  Parameters: 
    653          *      (string) jid  
     653         *              (string) jidFrom          
     654         *      (string) jidTo  
    654655         *              (string) name 
    655656         *              (string) group    
    656657         */ 
    657658         
    658         addContacts : function( jidFrom, jidTo, name, group ) 
    659         { 
    660                 var newPresence = $pres({from: jidFrom, to: jidTo, type: 'subscribe'}).tree(); 
    661                  
     659        addContact : function( jidFrom, jidTo, name, group ) 
     660        { 
     661                // Set Presence 
     662        var newPresence = $pres({from: jidFrom, to: jidTo, type: 'subscribe'}).tree(); 
     663                         
    662664                TrophyIM.connection.send(newPresence); 
    663  
    664                 var newContact = $iq({type: 'set', id: 'set1'}); 
     665         
     666        // Add Contact 
     667        var newContact = $iq({type: 'set', id: 'setAddContact'}); 
    665668                        newContact = newContact.c('query').attrs({xmlns : 'jabber:iq:roster'}); 
    666                         newContact = newContact.c('item').attrs({jid: jid, name: name, ask:'subscribe', subscription :'none'}); 
     669                        newContact = newContact.c('item').attrs({jid: jidTo, name:name, ask:'subscribe', subscription:'to'}); 
    667670                        newContact = newContact.c('group').t(group).tree(); 
    668671 
     
    689692    }, 
    690693         
     694    /** Function: removeContact 
     695     *  
     696     *  Parameters: 
     697     *          (string) jidTo 
     698     */ 
     699     
     700    removeContact : function(jidTo) 
     701    { 
     702        var divItenContact = null; 
     703         
     704        if( ( divItenContact = document.getElementById('itenContact_' + jidTo))) 
     705        {        
     706                divItenContact.parentNode.removeChild(divItenContact); 
     707                 
     708                // Delete Object groups 
     709                        for( var nameGroup in TrophyIM.rosterObj.groups ) 
     710                                for(var Jid in TrophyIM.rosterObj.groups[nameGroup]) 
     711                                        if(TrophyIM.rosterObj.groups[nameGroup][Jid] == jidTo ) 
     712                                                delete TrophyIM.rosterObj.groups[nameGroup][Jid]; 
     713                         
     714                        // Delete Object roster 
     715                        if( TrophyIM.rosterObj.roster[jidTo] ) 
     716                                delete TrophyIM.rosterObj.roster[jidTo]; 
     717                 
     718                        TrophyIM.rosterObj.save(); 
     719                         
     720                // Remove Contact 
     721                var delContact  = $iq({type: 'set', id: Date.parse( new Date )}) 
     722                        delContact      = delContact.c('query').attrs({xmlns : 'jabber:iq:roster'}); 
     723                        delContact      = delContact.c('item').attrs({jid: jidTo, subscription:'remove'});//.tree(); 
     724                 
     725                TrophyIM.connection.send(delContact); 
     726        } 
     727    }, 
     728     
    691729    /** Function: renderRoster 
    692730     * 
     
    911949        setAutorization : function( jid ) 
    912950        { 
    913            //<presence to='user@example.com' from='contact@example.org' type='subscribed'/> 
    914            //var _autorization = $pres( ).attrs( {to: jid, from: loadIM.getUserCurrent(), type:'subscribed'}).tree(); 
    915                  
    916951           TrophyIM.connection.send($pres( ).attrs( {to: jid, from: loadIM.getUserCurrent().jid, type:'subscribed'}).tree()); 
    917952        }, 
Note: See TracChangeset for help on using the changeset viewer.