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

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