jQuery-XMPP-plugin icon indicating copy to clipboard operation
jQuery-XMPP-plugin copied to clipboard

script - Appear only online contacts and disappear when they're off

Open golfixe opened this issue 11 years ago • 0 comments

Only show contacts online, and when they disappear off

In basic file-chat.html change the following lines:

-------------------------------------------------- Old ---------------------------------------------------------

                onPresence: function(presence){

                    var contact = $("<li>");
                    contact.append("<a href='javascript:void(0)'>"+ presence.from +"</a>");
                    contact.find("a").click(function(){
                            var id = MD5.hexdigest(presence.from);
                            var conversation = $("#"+id);
                            if(conversation.length == 0)
                                openChat({to:presence.from});
                    });
                    contactList.append(contact);
                },

-------------------------------------------------- Old ---------------------------------------------------------

replace this: -------------------------------------------------- new ---------------------------------------------------------

                //-----> Add contact on only, remove on offline.
                var onlineoffline = presence.type;
                if( onlineoffline == null ){
                                        var contact = $("<li>");
                    contact.append("<a href='javascript:void(0)'>"+ presence.from +"</a>");
                    contact.find("a").click(function(){
                            var id = MD5.hexdigest(presence.from);
                            var conversation = $("#"+id);
                            if(conversation.length == 0)
                                openChat({to:presence.from});
                    });
                    contactList.append(contact);

                }else{
                                            var contactsx = $("#contacts").html();
                    var overcontactsx = contactsx.replace("<a href='javascript:void(0)'>"+ presence.from +"</a>","");
                    $("#contacts").html("teste");
                }
               //-----> Add contact on only, remove on offline. 

-------------------------------------------------- new ---------------------------------------------------------

on script - jquery.xmpp.js ----------------------------------------------------- old ------------------------------------------------------

        $.each(response.find("presence"),function(i,element){
            try{
                var e = $(element);
                xmpp.onPresence({from: e.attr("from"), to: e.attr("to"), show: e.find("show").html()});
            }catch(e){}
        });
    },

--------------------------------------------------------- old --------------------------------------------------

replace this: --------------------------------------------------------------- new --------------------------------

        $.each(response.find("presence"),function(i,element){
            try{
                var e = $(element);
                xmpp.onPresence({from: e.attr("from"), type: e.attr("type") to: e.attr("to"), show: e.find("show").html()});
            }catch(e){}
        });
    },

---------------------------------------- new ------------------------------------------

golfixe avatar Mar 20 '13 11:03 golfixe