Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
golfixe opened this issue Mar 20, 2013 · 0 comments
Open

Comments

@golfixe
Copy link

golfixe commented Mar 20, 2013

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 ------------------------------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant