source: trunk/instant_messenger/js/im_functions.js @ 33

Revision 33, 23.3 KB checked in by niltonneto, 17 years ago (diff)

* empty log message *

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1// Instant Messenger
2// im_functions.js
3
4   function IM()
5   {
6      this.array_lang_im  = new Array();
7      this.array_users    = new Array();
8      this.vcard_user     = new Array();
9      this.array_prefe    = new Array();
10           this.array_prefe['ch_offline'] = true;       
11      this.load_photo     = false;
12   }
13
14   /*
15    * Load Contatos
16    */
17
18   IM.prototype.load_im = function()
19   {
20          var force = ( arguments.length ) ? true : false;
21      var _this = this;
22      Sincro.count = 0;
23
24      var handler_contacts = function(data)
25      {
26            _this.array_users.splice(0,_this.array_users.length);
27            _this.array_users = data;
28            _this.mount_list(data);
29            _this.conf_VcardUser(data[0]);
30      }
31
32      if ( force || this.getWinContactsState() )
33         cIM.cExecute("$this.Ujabber.list_user",handler_contacts);
34   }
35       
36   /*
37    * Update Contatos
38    */
39
40   IM.prototype.UpdateContacts = function()
41   {
42      var _this = this;
43      _this.load_im();
44   }
45
46   IM.prototype.showContacts = function()
47   {
48      if ( this.getWinContactsState() )
49         im_win.windowClose('contacts_im');
50      else
51      {
52         im_win.windowMaximizeRestore('contacts_im');
53         this.load_im();
54      }
55   }
56
57   IM.prototype.getWinContactsState = function()
58   {
59      try
60      {
61         var win_state = false;
62             win_state = ( windowItems['contacts'].state == WINDOW_STATE_REGULAR ) ? true : false;
63             win_state = ( win_state ) ? win_state : ( windowItems['contacts'].state == WINDOW_STATE_MAXIMIZED ) ? true : false;
64         return win_state;
65      }
66      catch(e)
67      {
68         return false;
69      }
70   }
71   
72  /*
73   * Manutenção
74   */
75
76   IM.prototype.Manutencao = function()
77   {
78                // Manutencao
79        //
80        //   var div_manutencao = document.getElementById('contacts_im_window_body_inner');
81        //       div_manutencao.innerHTML = '<p align="center"><img src='+img_manutencao_im.src+'></p>';
82                //       return false;
83                //
84                //
85        }
86
87   /*
88        * Monta Lista de Contatos
89        */
90       
91        IM.prototype.mount_list = function(pList)
92        {
93                var _this = this;
94                var group = "";
95                var div   = document.getElementById("div_contacts");
96                        div.innerHTML = "";
97
98                        div.innerHTML += '<img id="img_all_groups" src=' + img_group_open.src +
99                                         ' onclick=javascript:IM.visible_group("all_groups")>' +
100                                                 '<b>'+_this.get_lang('list of contacts') + ' - ' + ( pList.length - 1 ) + '</b><br>' +
101                                         '<div id="all_groups"></div>';
102
103                for(var i=1; i < pList.length; i++){
104
105                        var div_agroups = document.getElementById("all_groups");
106                        var div_group = document.createElement('DIV');                 
107                        group = decodeURI(pList[i].group);
108                        group = group.rm_space();
109                        if(document.getElementById("img_" + group) == null ){
110
111                                div_agroups.innerHTML += '<img id="img_' + group + '" src="' + img_group_open.src + '" onclick="javascript:IM.visible_group(\'' + group + '\')" style="margin-left:16px;">';
112                                div_agroups.innerHTML += '<b>' + decodeURI(pList[i].group) + '</b></br>';
113
114                                if(group != 'sem_grupo'){
115                                                div_group.id = group;
116                                                if(pList[i].subscription.rm_space() == "both")
117                                                        div_group.innerHTML += '<div id="' + pList[i].jid + '" nuncontact="'+ i +'" onmouseover="this.className=\'contato_hover\'" onmouseout="this.className=\'\'" onmousedown="javascript:IM.action_button(event, \''+pList[i].online + '\', \'' + pList[i].jid + '\' ,false);" style="cursor:pointer;padding-left:32px;"><img src="' + ((pList[i].online) == parseInt(1) ? img_online.src : img_offline.src) + '">' + decodeURI(pList[i].name) + '</div><span id="_span_' + pList[i].jid + '" class="menu_im"></span>';
118                                                else
119                                                        div_group.innerHTML += '<div id="' + pList[i].jid + '" nuncontact="'+ i +'" onmouseover="this.className=\'contato_hover\'" onmouseout="this.className=\'\'" onmousedown="javascript:IM.action_button(event, \''+parseInt(0)+'\', \'' + pList[i].jid + '\' ,true);" style="cursor:pointer;padding-left:32px;"><img src="' + img_not_authorized.src + '">' + decodeURI(pList[i].name) + '</div><span id="_span_' + pList[i].jid + '" class="menu_im"></span>';
120                                                div_agroups.appendChild(div_group);
121                                }else{
122                                                div_group.id = group;
123                                                div_group.innerHTML += '<div id="'+pList[i].jid+'" onclick=Preferences.updateLoad("'+pList[i].jid+'") style="cursor:pointer;padding-left:32px;">'+
124                                                                                           '<img src="'+img_not_authorized.src+'">'+pList[i].jid+'</div>';
125                                                div_agroups.appendChild(div_group);                                     
126                                }
127                        }else{
128
129                                if(group != 'sem_grupo'){
130                                        var div_group = document.getElementById(group);
131                                        if(pList[i].subscription.rm_space() == "both")
132                                                div_group.innerHTML += '<div id="' + pList[i].jid + '" nuncontact="'+ i +'" onmouseover="this.className=\'contato_hover\'" onmouseout="this.className=\'\'" onmousedown="javascript:IM.action_button(event, \''+pList[i].online + '\', \'' + pList[i].jid + '\',false);" style="cursor:pointer;padding-left:32px;"><img src="' + ((pList[i].online) == parseInt(1) ? img_online.src : img_offline.src) + '">' + decodeURI(pList[i].name) + '</div><span id="_span_' + pList[i].jid + '" class="menu_im"></span>';
133                                        else
134                                                div_group.innerHTML += '<div id="' + pList[i].jid + '" nuncontact="'+ i +'" onmouseover="this.className=\'contato_hover\'" onmouseout="this.className=\'\'" onmousedown="javascript:IM.action_button(event, \''+parseInt(0)+'\', \'' + pList[i].jid + '\',true);" style="cursor:pointer;padding-left:32px;"><img src="' + img_not_authorized.src + '">' + decodeURI(pList[i].name) + '</div><span id="_span_' + pList[i].jid + '" class="menu_im"></span>';                                     
135                                        div_agroups.appendChild(div_group);
136                                }else{
137                                        var div_group = document.getElementById(group);
138                                                div_group.innerHTML += '<div id="'+pList[i].jid+'" onclick=Preferences.updateLoad("'+pList[i].jid+'") style="cursor:pointer;padding-left:32px;">'+
139                                                                                           '<img src="'+img_not_authorized.src+'">'+pList[i].jid+'</div>';
140                                                div_agroups.appendChild(div_group);
141                                }       
142                        }
143                }
144       
145                // Contatos Offline;
146                _this.ContactsOffline();
147               
148                // Usuários Não Autorizados;           
149                setTimeout("Templates.Users_Not_Auth()",2500);
150
151        }
152       
153   /*
154        * Deixar contatos Offline
155        */
156       
157        IM.prototype.ContactsOffline = function()
158        {
159                var _this = this;
160                var display = "block";
161               
162                if(!_this.array_prefe['ch_offline']){
163                        display = "none";
164                }
165
166                for(var i = 1; i < _this.array_users.length; i++){
167                        var div_child = document.getElementById(_this.array_users[i].jid);
168                        var img_src = div_child.firstChild.src
169                        if(img_src === img_offline.src){
170                                div_child.style.display = display;
171                        }
172                }
173        }
174
175   /*   
176        *  Requisitar autorização;
177        */
178
179        IM.prototype.Authorization = function(pJid,pSubscription)
180        {
181                if(confirm("Enviar pedido?")){
182                        var handler_accept_request = function(data){
183                                if(!data)
184                                        alert("Pedido já foi enviado!");
185                        }
186                        cIM.cExecute("$this.Ujabber.AcceptRequest",handler_accept_request,"jid="+pJid+"&subscription="+pSubscription);
187                }
188        }
189
190   /*   
191        *  Grupos dos Contatos;
192        */
193
194        IM.prototype.visible_group = function(el)
195        {
196                var _this = this;
197                el = el.rm_space();
198                var div = document.getElementById(el);
199                div.style.display = "none";
200                var img = document.getElementById("img_" + el);
201                img.onclick = function(){_this.unvisible_group(el)};
202                img.src = img_group_close.src;
203       
204        }
205       
206        IM.prototype.unvisible_group = function(el)
207        {
208                var _this = this;
209                el = el.rm_space();
210                var div = document.getElementById(el);
211                div.style.display = "";
212                var img = document.getElementById("img_" + el);
213                img.onclick = function(){_this.visible_group(el)};
214                img.src = img_group_open.src;
215       
216        }
217
218        /*
219         *  Conf. Vcard
220         */
221       
222        IM.prototype.conf_VcardUser = function(data)
223        {
224                var _this = this;
225
226                // Vcard pessoal;
227                if ( !_this.load_photo ){
228
229                        _this.vcard_user['VCARD_FN'] = decodeURI(data.VCARD_FN);
230                        _this.vcard_user['VCARD_NICKNAME'] = decodeURI(data.VCARD_NICKNAME);
231                        _this.vcard_user['VCARD_ORGNAME']  = decodeURI(data.VCARD_ORGNAME);
232                        _this.vcard_user['VCARD_ORGUNIT']  = decodeURI(data.VCARD_ORGUNIT);
233                        _this.vcard_user['VCARD_ROLE'] = decodeURI(data.VCARD_ROLE);
234                        _this.vcard_user['VCARD_BDAY'] = decodeURI(data.VCARD_BDAY);
235                        _this.vcard_user['VCARD_DESC'] = decodeURI(data.VCARD_DESC);
236                        _this.vcard_user['VCARD_JID']  = decodeURI(data.VCARD_JID);
237                       
238                        im_win.get_photo_ldap(decodeURI(data['VCARD_JID']));
239                        Preferences.GetPreferences();
240                        _this.load_photo = true;
241                }
242       
243                // NickName;
244                if(_this.vcard_user['VCARD_NICKNAME'] != "")
245                        document.getElementById('span_nickname').innerHTML = "<b>&nbsp;" + _this.vcard_user['VCARD_NICKNAME'].substring(0,30) + "</b>";
246                else
247                        document.getElementById('span_nickname').innerHTML = "<b>&nbsp;" + IM.get_lang('your nickname') + "</b>";
248               
249                // Custom Message;
250                if(_this.vcard_user['VCARD_DESC'] != "")
251                        document.getElementById('span_message').innerHTML = "<b>&nbsp;" + _this.vcard_user['VCARD_DESC'].substring(0,30) + "</b>";
252                else
253                        document.getElementById('span_message').innerHTML = "<b>&nbsp;" + IM.get_lang('your message') + "</b>";                 
254       
255        }
256
257   /*   
258        *  Menu
259        */
260
261        IM.prototype.visible_box = function()
262        {
263                var _this = this;
264                document.getElementById('list_users').style.display = "";
265                var img = document.getElementById('box_menu');
266                img.onclick = function(){_this.unvisible_box()};
267                img.src = img_open_box.src;
268        }
269
270        IM.prototype.unvisible_box = function()
271        {
272                var _this = this;
273                document.getElementById('list_users').style.display = "none";
274                var img = document.getElementById('box_menu');
275                img.onclick = function(){_this.visible_box()};
276                img.src = img_close_box.src;
277        }
278
279   /*   
280        *  Traduções
281        */
282
283        // Translate words and phrases using user language from eGroupware.
284        IM.prototype.get_lang = function(_key,_arg1,_arg2,_arg3,_arg4)
285        {
286                var _this = this;
287                if(!_this.array_lang_im[0]){           
288                        return _key+"*";
289                }
290                _value = "";   
291                for(i = 0; i < _this.array_lang_im[0].length;i++){
292                        if(_this.array_lang_im[0][i] == _key.toLowerCase()) {
293                                _value = _this.array_lang_im[1][i];                                     
294                                break;
295                        }
296                }       
297               
298                if(!_value)
299                        return _key+"*";
300                               
301                if(_arg1 || _arg2 ||_arg3 || _arg4) {
302                        for(j = 1; j <= 4; j++){
303                                if(eval("_arg"+j)) {
304                                        var regExp = new RegExp("%"+j+"");             
305                                        _value = _value.replace(regExp,eval("_arg"+j));
306                                }
307                        }
308                }
309               
310                return _value;
311        }
312
313        /*
314         *  Pega Mensagens
315         */
316
317        IM.prototype.getMessage = function()
318        {
319                var _this = this;
320                var handler_message = function(data)
321                {
322                        if( data.length > 0)
323                        {
324                                var TimeStamp           = "";
325                                var jid                     = "";
326                                var nickname            = "";
327                                var body_message        = "";
328                                var window_message  = "";
329
330                                for( var i=0; i < data.length; i++)
331                                {                       
332                                        jid          = data[i].from;
333                                        body_message = data[i].body;
334                                        TimeStamp        = (_this.array_prefe['ch_time']) ? "[" + data[i].timestamp + "] " : " ";
335                                       
336                                        jid = jid.substr(0,jid.indexOf('/'));
337                                        body_message = decodeURI(body_message.replace(/\\\'/g, '\''));
338
339                                        window_message  = document.getElementById(jid + "_chatMessages");
340                                        nickname = jid;
341
342                                        for( var j=1; j < IM.array_users.length; j++ )
343                                        {
344                                                if( jid == IM.array_users[j].jid ){
345                                                        nickname = decodeURI(IM.array_users[j].VCARD_NICKNAME);
346                                                }
347                                        }
348
349                        if ( window_message )
350                        {
351                           window_message.innerHTML += '<strong>' + TimeStamp + nickname + '</strong>&nbsp;' + IM.get_lang('speak') + ':<br/> ' + _this.emotions_icons(body_message) + '<br/><br/>';
352                       if ( windowItems[jid].state != WINDOW_STATE_REGULAR && windowItems[jid].state != WINDOW_STATE_MAXIMIZED )
353                          im_win.showWindowItem(jid);
354                        }
355                        else
356                        {
357                           im_win.open_chat(jid);
358                           window_message = document.getElementById(jid + '_chatMessages');
359                           window_message.innerHTML += '<strong>' + TimeStamp + nickname + '</strong>&nbsp;' + IM.get_lang('speak') + ':<br/> ' + _this.emotions_icons(body_message) + '<br/><br/>';
360                        }
361                                }
362                               
363                                window_message.scrollTop = window_message.scrollHeight;
364                                im_win.newMessageNotification();
365                        }       
366                }
367                cIM.cExecute("$this.Ujabber.getMessages", handler_message);                     
368        }
369
370   /*
371        * Envia Mensagens
372        */
373
374   IM.prototype.sendMessage = function (pJID)
375   {
376      var _this = this;
377      var name_document = document.getElementById(pJID + '_edita');
378      var envio = name_document.contentWindow.document.getElementsByTagName('body').item(0);
379
380      envio.innerHTML = func.trim(envio.innerHTML.replace(/^(&nbsp;|<br>| )*|(&nbsp;|<br>| )*$/g, ''));
381
382      if ( envio.innerHTML != "" )
383      {
384         var message_text  = "<div style='";
385         message_text += (envio.style.fontFamily != "") ? "font-family:"+envio.style.fontFamily+";" : "";
386         message_text += (envio.style.fontSize != "") ? "font-size:"+envio.style.fontSize+";" : "" ;
387         message_text += (envio.style.fontWeight != "") ? "font-weight:"+envio.style.fontWeight+";": "";
388         message_text += (envio.style.fontStyle != "" ) ? "font-style:"+envio.style.fontStyle+";" : "";
389         message_text += (envio.style.color != "") ? "color:"+envio.style.color+";" : "color:black";
390         message_text += "'>";
391         message_text += envio.innerHTML + "</div>";
392
393         envio.innerHTML = '';
394
395         var message_element = document.getElementById(pJID + '_chatMessages');
396         message_element.innerHTML += '<strong>' + ((_this.vcard_user['VCARD_NICKNAME'] != "") ? _this.vcard_user['VCARD_NICKNAME'] : _this.vcard_user['VCARD_JID'] );
397         message_element.innerHTML += ' ' + _this.get_lang('speak') + ':</strong><br/>';
398         message_element.innerHTML += _this.emotions_icons(message_text.replace(/^(&nbsp;|<br>| )*|(&nbsp;|<br>| )*$/g, '')) + '<br/>';
399
400         message_element.scrollTop = message_element.scrollHeight;
401
402         var handler_sendMessage = function(data)
403         {
404            if(!data)
405               alert(data);
406         }
407         cIM.cExecute("$this.Ujabber.SendMessage",handler_sendMessage,"to="+pJID+"&body="+url_encode(encodeURI(message_text)));
408      }
409   }
410       
411        /*
412         *  Smiles
413         */
414
415   IM.prototype.emotions_icons = function(pMessage)
416   {
417      for ( i = 1; i < cod_emotions.length; i++ )
418      {
419         var image = eval('smile_' + i + '.src.substr(smile_' + i + '.src.indexOf(im_path))')
420         pMessage  = pMessage.replace(cod_emotions[i], '<img src="' + image + '">');
421      }
422      return pMessage;
423   }
424
425   IM.prototype.atalho = function()
426   {
427      if ( local = func.byId('user_info') )
428      {
429         var aux  = new Array();
430         var _mix = func.newEl('a', 'a', 'img', 'img', 'dl');
431
432         var fast_menu_link  = _mix[0];
433         var contacts_link   = _mix[1];
434         var fast_menu_image = _mix[2];
435         var contacts_image  = _mix[3];
436         var im_fast_menu    = _mix[4];
437
438         fast_menu_link.onclick = function(){IM.showFastMenu();};
439         contacts_link.onclick  = function(){IM.showContacts();};
440
441         aux['fast_menu_image'] = new Array();
442         aux['fast_menu_image']['element'] = fast_menu_image;
443         aux['fast_menu_image']['style']   = 'width:9px;height:9px';
444         aux['fast_menu_image']['src']     = im_path + 'templates/default/images/menuarwopen.gif';
445
446         aux['im_fast_menu'] = new Array();
447         aux['im_fast_menu']['element'] = im_fast_menu;
448         aux['im_fast_menu']['id']      = 'fast_menu_im';
449         aux['im_fast_menu']['class']   = 'menu_im';
450
451         aux['contacts_image'] = new Array();
452         aux['contacts_image']['element'] = contacts_image;
453         aux['contacts_image']['id']      = 'chat_bubble';
454         aux['contacts_image']['src']     = im_path + 'templates/default/images/navbar.png';
455         aux['contacts_image']['style']   = 'width:15px;height:15px';
456         func.confEl(aux);
457
458         func.insEl(fast_menu_image, fast_menu_link);
459         func.insEl(contacts_image, contacts_link);
460         func.insElB(fast_menu_link, contacts_link, im_fast_menu, document.createTextNode(' '), local.firstChild);
461      }
462      else
463         setTimeout('IM.atalho()', 5000);
464   }
465
466   IM.prototype.showFastMenu = function()
467   {
468      if ( !messages_timeout )
469      {
470         var option       = func.newEl('dt');
471         var option_link  = func.newEl('a');
472         var option_image = func.newEl('img');
473
474         option_link.onclick = function(){IM.login();};
475
476         func.confEl(option_image, 'src', img_online.src);
477         func.confEl(option_image, 'style', 'width:16px;height:16px;');
478
479         func.insEl(option_image, IM.get_lang('login'), option_link);
480         func.insEl(option_link, option);
481
482         im_menu_action.menu('fast_menu_im', option);
483      }
484      else
485      {
486         var _dt = func.newEl('dt', 'dt', 'dt', 'dt', 'dt');
487         var _a  = func.newEl('a', 'a', 'a', 'a', 'a');
488
489         for ( var i in _dt )
490         {
491            if ( typeof _dt[i] == 'function' )
492               continue;
493            eval('var option' + (parseInt(i)+1) + ' = _dt[' + i + '];');
494            eval('var option' + (parseInt(i)+1) + '_link = _a[' + i + '];');
495         }
496
497         var _img = func.newEl('img', 'img', 'img', 'img');
498
499         for ( var i in _img )
500         {
501            if ( typeof _dt[i] == 'function' )
502               continue;
503            eval('var option' + (parseInt(i)+1) + '_image = _img[' + i + '];');
504         }
505
506         option1_link.onclick = function(){IM.setStatus('online');};
507         option2_link.onclick = function(){IM.setStatus('idle');};
508         option3_link.onclick = function(){IM.setStatus('busy');};
509         option4_link.onclick = function(){IM.logout();};
510         option5_link.onclick = function(){IM.setStatus('custom')};
511
512         func.confEl(option1_image, 'src', img_online.src);
513         func.confEl(option1_image, 'style', 'width:16px;height:16px;');
514         func.confEl(option2_image, 'src', img_idle.src);
515         func.confEl(option2_image, 'style', 'width:16px;height:16px;');
516         func.confEl(option3_image, 'src', img_busy.src);
517         func.confEl(option3_image, 'style', 'width:16px;height:16px;');
518         func.confEl(option4_image, 'src', img_offline.src);
519         func.confEl(option4_image, 'style', 'width:16px;height:16px;');
520
521         func.insEl(option1_image, IM.get_lang('online'), option1_link);
522         func.insEl(option1_link, option1);
523         func.insEl(option2_image, IM.get_lang('????'), option2_link);
524         func.insEl(option2_link, option2);
525         func.insEl(option3_image, IM.get_lang('busy'), option3_link);
526         func.insEl(option3_link, option3);
527         func.insEl(option4_image, IM.get_lang('offline'), option4_link);
528         func.insEl(option4_link, option4);
529         func.insEl(IM.get_lang('Custom message...'), option5_link);
530         func.insEl(option5_link, option5);
531
532         im_menu_action.menu('fast_menu_im', option1, option2, option3, option4, option5);
533      }
534   }
535
536   IM.prototype.setStatus = function(pStatus)
537   {
538      im_menu_action.menu('fast_menu_im', null);
539   }
540
541   IM.prototype.getStatus = function()
542   {
543   }
544
545   IM.prototype.login = function()
546   {
547      try
548      {
549         im_menu_action.menu('fast_menu_im', null);
550         Sincro.get_list();
551         Sincro.get_Message();
552         var contacts_image = func.byId('chat_bubble');
553         contacts_image.parentNode.onclick = function(){IM.showContacts()};
554         func.confEl(contacts_image, 'src', im_path + 'templates/default/images/navbar.png');
555      }
556      catch (e)
557      {
558      }
559   }
560
561   IM.prototype.logout = function()
562   {
563      im_menu_action.menu('fast_menu_im', null);
564      clearTimeout(messages_timeout);
565      clearTimeout(contacts_timeout);
566      messages_timeout = false;
567      contacts_timeout = false;
568      var contacts_image = func.byId('chat_bubble');
569      contacts_image.parentNode.onclick = function(){IM.showFastMenu()};
570      func.confEl(contacts_image, 'src', img_chat_bubble.src);
571   }
572
573   IM.prototype.menu_preferences = function(pElement)
574   {
575      if ( document.getElementById(pElement).innerHTML == "" )
576      {
577         var form_pref  = "<dl>";
578            form_pref += "<dt><a href='javascript:void(0)' onclick='javascript:Preferences.Add_userLoad()'>";
579            form_pref += "<img src="+img_menu.src+">&nbsp;"+IM.get_lang('Add Contact')+"</a></dt>";
580            form_pref += "<dt><a href='javascript:void(0)' onclick='javascript:Preferences.Remove_userLoad()'>";
581            form_pref += "<img src="+img_menu.src+">&nbsp;"+IM.get_lang('Remove Contact')+"</a></dt>";
582            form_pref += "<dt><a href='javascript:void(0)' onclick='javascript:Preferences.vCardLoad()'>";
583            form_pref += "<img src="+img_menu.src+">&nbsp;"+IM.get_lang('Information')+"</a></dt>";
584            form_pref += "<dt><a href='javascript:void(0)' onclick='javascript:Preferences.yourPreferences()'>";
585            form_pref += "<img src="+img_menu.src+">&nbsp;"+IM.get_lang('preferences')+"</a></dt>";
586            form_pref += "</dl>";
587         im_menu_action.menu(pElement, form_pref);
588      }
589   }
590
591   IM.prototype.menu_button_right = function(pElement,pReq)
592   {
593      var form_menu_button_right = '<dl>';
594              if(pReq)
595              {
596                    form_menu_button_right += '<dt><a href="javascript:void(0);" onclick="javascript:IM.Authorization(\''+pElement+'\',\'from\');"><img src="'+img_group_close.src+'">' + IM.get_lang('Authorization') + '</a>';                                   
597                  }
598          form_menu_button_right += '<dt><a href="javascript:void(0);" onclick="javascript:Preferences.Update_NickName(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('Nick') + '</a>'+
599                                    '<dt><a href="javascript:void(0);" onclick="javascript:Preferences.SendFile(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('Send File') + '</a>'+
600                                    '<dt><a href="javascript:void(0);" onclick="javascript:Preferences.Update_Group(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('Group') + '</a>'+
601                                    '<dt><a href="javascript:void(0);" onclick="javascript:Preferences.Remove_Contact(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('Delete') + '</a>'+
602                                                                    '<dt><a href="javascript:void(0);" onclick="javascript:Preferences.vCardLoad_Contact(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('See Info') + '</a>'+
603                                    '</dl>';
604      im_menu_action.menu("_span_" + pElement, form_menu_button_right);
605   }
606
607        /*
608         * url_encode
609         */
610       
611        function url_encode(str)
612    {
613            var hex_chars = "0123456789ABCDEF";
614            var noEncode = /^([a-zA-Z0-9\_\-\.])$/;
615            var n, strCode, hex1, hex2, strEncode = "";
616       
617            for( n = 0; n < str.length; n++ )
618       {
619                if ( noEncode.test(str.charAt(n)) )
620           {
621                    strEncode += str.charAt(n);
622                }
623           else
624           {
625                    strCode = str.charCodeAt(n);
626                    hex1 = hex_chars.charAt(Math.floor(strCode / 16));
627                    hex2 = hex_chars.charAt(strCode % 16);
628                    strEncode += "%" + (hex1 + hex2);
629                }
630            }
631            return strEncode;
632        } 
633
634        /*
635         *  Ação do botão onclick da lista de contatos;
636         */
637
638        IM.prototype.action_button = function(pEv,pStatus,pJid,pReq)
639        {
640                var _this = this;
641                if(pEv.button > 1){
642                        _this.menu_button_right(pJid,pReq);
643                        document.oncontextmenu = new Function("return false");
644                }else{
645                        if(pStatus == parseInt(1))
646                                _this.open_chat(pJid);
647                }
648        }
649       
650        /*
651         * Abre Conversa
652         */
653
654        IM.prototype.open_chat = function(pJID)
655        {
656      func.byId(pJID).firstChild.src = img_chat_bubble.src;
657      im_win.open_chat(pJID);
658        }
659
660
661        String.prototype.rm_space = function()
662        {
663        return this.replace(/( *)/g,"");
664        }
665
666// Build Object
667        var IM = new IM();
Note: See TracBrowser for help on using the repository browser.