Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Pneumatus/2287253 to your computer and use it in GitHub Desktop.
Save Pneumatus/2287253 to your computer and use it in GitHub Desktop.
DynmapCore Alphabetical Player Sort
From c092fae885d0be261f6993f3084d7152c145502b Mon Sep 17 00:00:00 2001
From: Pneumatus <matt@g33k0r.org>
Date: Mon, 2 Apr 2012 22:04:17 +0100
Subject: [PATCH] Inject players alphabetically (ignoring case) into the player list rather than just appending.
---
web/js/map.js | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/web/js/map.js b/web/js/map.js
index 34ad750..8c45223 100644
--- a/web/js/map.js
+++ b/web/js/map.js
@@ -720,8 +720,16 @@ DynMap.prototype = {
me.followPlayer(null);
}
me.panToLocation(player.location);
- })
- .appendTo(me.playerlist);
+ });
+ // Inject into playerlist alphabetically
+ var firstNodeAfter = me.playerlist.children().filter(function() {
+ return ($('a', this).text().toLowerCase() > $('a', menuitem).text().toLowerCase());
+ }).eq(0);
+ if (firstNodeAfter.length > 0) {
+ firstNodeAfter.before(menuitem);
+ } else {
+ menuitem.appendTo(me.playerlist);
+ }
if (me.options.showplayerfacesinmenu) {
getMinecraftHead(player.account, 16, function(head) {
$('img', playerIconContainer).remove();
--
1.7.3.1.msysgit.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment