source: sandbox/jabberit_messenger/trophy_expresso/js/AddUser.js @ 2511

Revision 2511, 6.3 KB checked in by alexandrecorreia, 14 years ago (diff)

Ticket #986 - Implementado o status de mensagem e a busca da foto no ldap.

RevLine 
[2397]1(function()
2{
[2411]3                var Xtools      = null;
4                var conn        = null;
[2397]5       
[2437]6                function addContact()
[2397]7                {
[2421]8                        var jidFrom             = loadIM.getUserCurrent().jid;
9                        var jidTo               = document.getElementById('user_jid_jabberIM').value;
10                        var name                = document.getElementById('user_name_jabberIM').value;
11                        var group               = document.getElementById('user_group_jabberIM').value;
[2397]12                       
[2471]13                        if( jidFrom != jidTo )
14                        {
15                                TrophyIM.addContact( jidFrom, jidTo, name, group );
16                               
17                                _winBuild('add_user_info','remove');
18                        }
19                        else
20                                alert("Mesmo Usuário !");
[2397]21                }
22               
[2411]23                function search()
24                {
25                        var _input      = document.getElementById('search_user_jabber');
26                        var _span       = document.getElementById('span_searching_im');
27                        var _div        = document.getElementById('list_users_ldap_im');
28
29                        _span.style.display = "block";
30                       
[2421]31                        if( _input.value.substring((_input.value.length-1),_input.value.length) === "*" )
32                                _input.value = _input.value.substring(0, ( _input.value.length - 1 ));
33
34                        if( _input.value.substring(0 ,1) === "*" )
35                                _input.value = _input.value.substring( 1, _input.value.length );
36                       
[2411]37                        conn.go('p.cc.getListContacts',
38                                        function(data)
39                                        {       
40                                                var _paramsVar =
41                                                {
42                                                        'lang_addContact'       : 'Adicionar Contatos',
43                                                        'lang_empty'            : 'None result was found.',
44                                                        'lang_many_results' : 'Many results. Please, try to refine your search.'
45                                                };     
46                                               
47                                                _div.innerHTML = Xtools.parse( data, 'listLdapContacts.xsl', _paramsVar );
48
[2421]49                                                var _newUser = _div.firstChild;
[2411]50                                               
[2421]51                                                while ( _newUser )
[2411]52                                                {
[2421]53                                                        if( _newUser.getAttribute('photo') === '1' )
[2411]54                                                        {
[2421]55                                                                var jid         = _newUser.getAttribute('jid');
56                                                                var ou          = _newUser.getAttribute('ou');
[2471]57                                                               
58                                                                var _img_path  = path_jabberit + 'inc/WebService.php?' + Date.parse( new Date );
[2511]59                                                                        _img_path += '&photo_session=' + jid + '&ou=' + ou;
[2471]60                                                               
[2421]61                                                                _newUser.style.backgroundImage = 'url(' + _img_path + ')';
[2411]62                                                        }
63                                                       
[2421]64                                                        loadIM.configEvents(_newUser, 'onclick', showContact);
[2411]65                                                       
[2421]66                                                        _newUser = _newUser.nextSibling;
[2411]67                                                }
68
69                                                _input.focus();
70                                                _input.value            = "";
71                                                _span.style.display = "none";
72                                               
[2421]73                                        },'name=' + _input.value );
[2411]74                }
75               
[2421]76                function showContact(Element)
77                {
78                        var element             = ( Element.target ) ? Element.target : Element.srcElement;
79                        var infoUser    = null;         
[2437]80                        var img                 = document.createElement('img');
[2421]81                       
82                        if( element.getAttribute('value') )
83                        {
84                                var infoUser =
85                                {
86                                        'email'                         : element.getAttribute('value').substring( 0, element.getAttribute('value').indexOf(';')),
87                                        'jid'                           : element.getAttribute('jid'),
88                                        'lang_group'            : "Grupo",
89                                        'lang_name_contact'     : "Contato",                                   
90                                        'group'                         : element.getAttribute('ou'),
91                                        'name'                          : element.getAttribute('name').substring( 0, element.getAttribute('name').indexOf(' ')),
[2437]92                                        'ou'                            : element.getAttribute('ou'),
93                                        'selectBoxOptions'      : "grupo1; grupo2; grupo3",
[2421]94                                        'uid'                           : element.getAttribute('value').substring( element.getAttribute('value').indexOf(';') + 1 )
95                                };
96                        }
97                        else if( element.parentNode.getAttribute('value') )
98                        {
99                                var infoUser =
100                                {
101                                        'email'                         : element.parentNode.getAttribute('value').substring( 0, element.parentNode.getAttribute('value').indexOf(';')),
102                                        'jid'                           : element.parentNode.getAttribute('jid'),
103                                        'lang_group'            : "Grupo",
104                                        'lang_name_contact'     : "Contato",                                   
105                                        'group'                         : element.parentNode.getAttribute('ou'),
[2437]106                                        'name'                          : element.parentNode.getAttribute('name').substring( 0, element.parentNode.getAttribute('name').indexOf(' ')),
107                                        'ou'                            : element.parentNode.getAttribute('ou'),
108                                        'selectBoxOptions'      : "grupo1; grupo2; grupo3",
[2421]109                                        'uid'                           : element.parentNode.getAttribute('value').substring( element.parentNode.getAttribute('value').indexOf(';') + 1)
110                                };
111                        }
112                       
113                        var winAddUser =
114                        {
115                                        id_window        : "add_user_info",
[2437]116                                        width            : 370,
[2421]117                                        height           : 190,
118                                        top                      : 85,
119                                        left             : 220,
120                                        draggable        : true,
121                                        visible          : "display",
122                                        resizable        : true,
123                                        zindex           : loadIM.getZIndex(),
124                                        title            : 'Expresso Messenger - Add Contact',
125                                        closeAction  : "remove",
126                                        content          : Xtools.parse( Xtools.xml('adduser'), 'addUser.xsl', infoUser )
127                        };
128
129                        _winBuild( winAddUser );
130                       
131                       
132                        var _pButtons =
133                        {
134                                'lang1'                 : 'Adicionar',
135                                'lang2'                 : 'Fechar',
136                                'onclickClose'  : '_winBuild("' + winAddUser.id_window + '","remove");',
[2437]137                                'onclickSubmit' : 'loadIM.addContact(this);'
[2421]138                        };
139
[2437]140                        // Add Buttons
141                        document.getElementById('buttons_adduser').innerHTML = Xtools.parse(Xtools.xml('buttons_main'), 'buttons.xsl', _pButtons);
142                       
143                        // Select Editable
144                        loadIM.setSelectEditable(document.getElementById('user_group_jabberIM'));
145                       
146                        if( element.style.backgroundImage )
147                        {
148                                var _img = element.cloneNode( false );
149                                _img.style.width        = '60px';
150                                _img.style.height       = '80px';
151                                _img.style.display      = 'block';
152                                _img.style.backgroundRepeat = 'no-repeat';
153                                                       
154                        }
155                        else
156                        {
157                                var _img = document.createElement("img");
158                                _img.style.width        = '60px';
159                                _img.style.height       = '80px';
160                                _img.style.display      = 'block';
161                                _img.src                        = path_jabberit + "templates/default/images/photo.png";
162                        }
163                       
164                        with ( document.getElementById('photo_user_ldap_jabber') )
165                        {
166                                if( hasChildNodes( ) )
167                                        while( hasChildNodes( ) )
168                                        {
169                                                removeNode( firstChild );
170                                        }
171                               
172                                appendChild( _img );
173                        }
174                       
[2421]175                }
176               
[2397]177                function showForm()
178                {
179                        var _paramsWindAddUser =
180                        {
[2411]181                                        'lang_group'            : 'Grupo',
182                                        'lang_load'                     : 'Carregando',
183                                        'lang_name_contact'     : 'Nome do Contato',
184                                        'lang_result'           : 'Resultado da Busca',
185                                        'path'                          : path_jabberit
[2397]186                        };
187
188                        var windAddUser =
189                        {
190                                        id_window        : "add_user_im",
191                                        width            : 440,
192                                        height           : 350,
193                                        top                      : 80,
194                                        left             : 200,
195                                        draggable        : true,
196                                        visible          : "display",
197                                        resizable        : true,
198                                        zindex           : loadIM.getZIndex(),
199                                        title            : 'Expresso Messenger - Search users',
200                                        closeAction  : "remove",
201                                        content          : Xtools.parse( Xtools.xml('userinfo'), 'addUser.xsl', _paramsWindAddUser )
202                        };
203                       
204                        _winBuild( windAddUser );
[2437]205                       
[2397]206                }
207       
208                function loadAddUser()
209                {
210                        if( arguments.length > 0 )
211                        {
[2411]212                                Xtools  = arguments[0];
213                                conn    = arguments[1];                         
[2397]214                        }       
215                }
216
[2437]217                loadAddUser.prototype.add               = addContact;
[2411]218                loadAddUser.prototype.search    = search;
[2397]219                loadAddUser.prototype.show              = showForm;
[2411]220                               
[2397]221                window.addUserIM        = loadAddUser;
222})();
Note: See TracBrowser for help on using the repository browser.