Sign Up! Login: Password: New User? Forgot? Support
Top Mods!
Wowhead Search
by sonofsamedi
Digital Clock
by Wolfar15
Admin Forums
Welcome to the GuildPortal Help Community! These forums are for admin-to-admin help.
Available Forums
Forums : Pimp My Site! > Sorting the Raid Point Standing Table
Mottie (MVP) 10/5/2008 10:42 AM EST : Sorting the Raid Point Standing Table
GuildPortal MVP
Mottie
Posts: 3884
Zomgawsh Poster

Raid Point Sorting

This code will allow you to sort your raid point standings table as well as hide all members with less than one raid point. The initial sort will display the member with the highest points at the top as well as sorting the member's names that have the same amount of points. Check it out in action at the bottom of the "Roster" tab of my test-site.


  • Double arrows () show that the column is sortable.
  • A down arrow () shows that the column has a descending sort applied.
  • An up arrow () shows that the column has a ascending sort applied.
  • The (+/-) link under the "Curr. Points" will hide or show the members with zero points or less.
  • To sort by multiple columns, hold down the shift key while clicking on the header.

The Code

Add this to the header, footer or to a "free form text/HTML" box on your raid points page.
<style type="text/css">
th.header {
 background: #222222 url(http://i201.photobucket.com/albums/aa236/Mottie1/testsite/icons/sort-white.gif) left center no-repeat;
 cursor: pointer;
 font-weight: bold;
 text-align:center;
 padding-left: 10px;
 border-right: 1px solid #00000;
}
th.headerSortUp { background: #400000 url(http://i201.photobucket.com/albums/aa236/Mottie1/testsite/icons/asc-white.gif) left center no-repeat; }
th.headerSortDown { background: #804000 url(http://i201.photobucket.com/albums/aa236/Mottie1/testsite/icons/desc-white.gif) left center no-repeat; }
#hideZeros { font-weight:normal; text-align:right; font-size:8pt;}
.hide {display:none;}
</style>
<script src="http://www.guildportal.com/Cms/jquery.tablesorter.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
 try {
// Add Table Sort
 $("span").each(function () {
  if ($(this).attr('id').match('lblRaidPointTitle')) {
   $(this).parent().find("table:eq(0)").attr("id","RaidTable");
  }
 });
 $("#RaidTable").find("tbody").attr("id","RaidData");
 $("#RaidTable").find("tr:eq(0)").remove();
 var hdr = "<tr><th class=\"{sorter: 'text'}\">Member</th><th class=\"{sorter: 'numeric'}\" width=80";
 hdr += "align=center>Att. Raids</th><th class=\"{sorter: 'numeric'}\" width=80 align=center>M/SU</th>";
 hdr += "<th class=\"{sorter: 'numeric'}\" width=80 align=center>A/P</th><th class=\"{sorter: 'numeric'}\"";
 hdr += "width=80 align=center>Curr. Points</th></tr>";
 $("#RaidData").before("<thead id='RaidHeader'></thead>");
 $("#RaidHeader").html(hdr);
// Add button
 var hideImage = '(+/-)';
 var CurrentPoints = "Curr. Points";
 var filter = "eq(" + columnNum(CurrentPoints) + ")";
 var temp = $("#RaidHeader").find("th:" + filter).html();
 temp += " <a href='#' id='hideZeros'>" + hideImage + "</a>"
 $("#RaidHeader").find("th:" + filter).html(temp);
 $("#hideZeros").click(function() {
  $("#RaidData").find("tr").each(function() {
   if ($(this).find("td:" + filter).html() < 1) {
    $(this).toggleClass("hide");
   }
  })
 })
 $("#RaidTable").tablesorter({
  textExtraction: function(node) {
   var xx = node.innerHTML.toLowerCase();
   if (xx.match("history")) {
    var temp = xx.substring(0,xx.indexOf("<br>"));
    return temp.replace(/~/g,"").replace(/-/g,"").replace(/\./g,"").replace(/\*/g,"");
   }
   if (xx.match("viewindividual")) {
       temp = node.childNodes[0].innerHTML;
       return temp.substr(temp.indexOf("/")+1,temp.length);
   }
   return xx;
  }
  ,sortList: [[4,1],[0,0]]
 });
} catch (e) {}
})
function columnNum(x) {
 var counter = 0;
 var temp = false;
 $("#RaidHeader").find("th").each(function() {
  if ($(this).text().match(x)) {temp = counter;}
  counter++;
 });
 return temp;
}
</script>

Customizing

CSS
Script
  • If you want to replace the "(+/-)" to hide or show the zero points, then look in the script for the green text

    var hideImage = '(+/-)';

    this can be replaced with text or even an image:

    var hideImage = '<img src="URL TO IMAGE">';

  • The default sort order with this script is set as follows:
    1. Descending sort on "Curr. Points" column (4th column, if you start to count with a zero from left to right)
    2. Ascending sort on "Members" column (column zero - the furthest left column is always numbered zero)

    To change this, look for:

    sortList: [[4,1],[0,0]]

    The "4" tells the script to sort the 4th column, the "1" tells the script that it is descending. Then the first "0" tells the script to sort column zero, and the second "0" tells it to sort it ascending.

    For more details on how to change this sort list or anything else with the script, refer to this web site: Tablesorter.

  • If in the future this table is reformated and this script stops working, look for the text in purple. Otherwise don't mess with it!!
    • "history" is the text that script looks for in the member's column... from the link "(point history)"
    • "Curr. Points" is the title of the Current Points header that the script searches for to add the hide zero toggle.
Edit (10/6/08): Added some code to prevent making an error when it's not on the raid point page
Edit (10/31/08): Fixed the problem with this script not working with IE.
Edit (12/24/08): Fixed one line to prevent this script from replacing the "Recent Forum" header... highlighted with a blue background.
TopBottom

RedRydur (Guild Admin) 10/23/2008 10:55 AM EST : RE: Sorting the Raid Point Standing Table
RedRydur
Posts: 1065
Zomgawsh Poster

Mottie said:
Check it out in action at the bottom of the "Roster" tab of my test-site.



Didn't Work for me. I put it in my footer without modifications.
I went to the test site also, and it looks like the generic Raid Point Page.

http://www.guildportal.com/Guild.aspx?GuildID=66776&TabID=578876
---------------------------------------------
-
RedRydur the Pure
TopBottom

Mottie (MVP) 10/23/2008 12:48 PM EST : RE: Sorting the Raid Point Standing Table
GuildPortal MVP
Mottie
Posts: 3884
Zomgawsh Poster

Your link doesn't work for the public, but try adding the script somewhere else on the page... I've been having trouble with code working in the footer recently.
TopBottom

RedRydur (Guild Admin) 10/24/2008 2:47 AM EST : RE: Sorting the Raid Point Standing Table
RedRydur
Posts: 1065
Zomgawsh Poster

Mottie said:
Your link doesn't work for the public, but try adding the script somewhere else on the page... I've been having trouble with code working in the footer recently.

Most sorry, I set the access rights to public now. Its not working for me. I followed the link to your site, and I see the generic raid points there too. There is nothing on the client side that needs to be loaded?
---------------------------------------------
-
RedRydur the Pure
TopBottom

Mottie (MVP) 10/24/2008 5:18 AM EST : RE: Sorting the Raid Point Standing Table
GuildPortal MVP
Mottie
Posts: 3884
Zomgawsh Poster

Ugh, yet another thing that works perfectly with Firefox & Chrome but not with IE... Hmmm I swear I tested it before I posted.... ugh, ok let me look into it again
TopBottom

RedRydur (Guild Admin) 10/30/2008 10:46 AM EST : RE: Sorting the Raid Point Standing Table
RedRydur
Posts: 1065
Zomgawsh Poster

I downloaded firefox and it looks great Mottie! You haven't figured out a IE friendly version have you?
---------------------------------------------
-
RedRydur the Pure
TopBottom

Mottie (MVP) 10/30/2008 10:53 AM EST : RE: Sorting the Raid Point Standing Table
GuildPortal MVP
Mottie
Posts: 3884
Zomgawsh Poster

It's still on my "To Do" list... need more time!!!
TopBottom

Mottie (MVP) 10/31/2008 8:01 AM EST : RE: Sorting the Raid Point Standing Table
GuildPortal MVP
Mottie
Posts: 3884
Zomgawsh Poster

Ok, it's been fixed and tested on Firefox, IE and Chrome.
TopBottom

Mottie (MVP) 12/24/2008 1:46 AM EST : RE: Sorting the Raid Point Standing Table
GuildPortal MVP
Mottie
Posts: 3884
Zomgawsh Poster

I had to fix this script because it was replacing the "Most Recent Activity" header in the forums.
TopBottom

Admins Online
There are   members online.
So-and-so has logged on!
%title%
%message%