Skip to content

Instantly share code, notes, and snippets.

@jaredmcateer
Created February 20, 2013 20:40
Show Gist options
  • Save jaredmcateer/4999410 to your computer and use it in GitHub Desktop.
Save jaredmcateer/4999410 to your computer and use it in GitHub Desktop.
Bookmarklet that keeps your user list sorted when it gets updated instead of putting new users at the bottom of the list like a chump
javascript:(function(){chat.update_roster=function(room_jid){if(room_jid&&room_jid!=app.current_jid){return;}var roster=(room_jid?app.room_rosters[room_jid].sort(function(a,b){if(a.name<b.name){return-1;}else if(a.name>b.name){return 1;}return 0;}):app.roster);if(!roster){return;}$('#roster div.member').remove();for(var i=0;i<roster.length;i++){var status_info=this.get_status_info(roster[i]);var member=roster[i];$('#roster div.list').append('<div class="'+roster[i].role+'"><div jid="'+roster[i].jid+'" class="member '+status_info.show+'">'+member.name+'<span class="idle">'+status_info.idle+'</span><span class="status">'+status_info.status+'</span></div></div>');}$('#roster div.member').dblclick($.proxy(this,'handle_roster_dblclick')).mouseover(function(event){$(this).css('background-color','#F0F0F0');}).mouseout(function(event){$(this).css('background-color','#FFFFFF');}).tooltip({bodyHandler:chat.generate_roster_tooltip});if(config.mobile){$('#roster div.member').click($.proxy(this,'handle_roster_dblclick'));}};})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment