Hi all,
This is a relatively minor suggestion, but one that has always bugged me, so I spent some time fiddling around with jQuery today and made a fix.
My suggestion can be summed up with a couple of images. Currently, when you "sort by tier" on the Pokemon tables, you get this:
BL, BL2, LC, etc. Sort Descending starts you off in UU, then Uber. In both cases we're sorting alphabetically - not too hard to find the tier you want, but we can do better.
Here's how it looks when you sort by tier with the added code (Uber is all that's visible here, but if you scroll down it continues onto OU, BL, UU, BL2, etc.)
(Don't worry that the arrows are missing - that's just because I'm testing my code on a local copy, and I didn't save the images locally.)
The following is the code I used to achieve this effect. (It is a modified version of the existing javascript element that is directly after the table.)
The modification uses builtin tablesorter functionality, and as such does not require any additional JS files or anything. It is fairly straightforward, and the integers are spaced out in case new tiers ever need be added.
To whoever handles the code, you can probably see the changes between the versions.
If not (or if you don't want to run a diff) here they are:
Thanks for your consideration,
~Zedadex
This is a relatively minor suggestion, but one that has always bugged me, so I spent some time fiddling around with jQuery today and made a fix.
My suggestion can be summed up with a couple of images. Currently, when you "sort by tier" on the Pokemon tables, you get this:
BL, BL2, LC, etc. Sort Descending starts you off in UU, then Uber. In both cases we're sorting alphabetically - not too hard to find the tier you want, but we can do better.
Here's how it looks when you sort by tier with the added code (Uber is all that's visible here, but if you scroll down it continues onto OU, BL, UU, BL2, etc.)
(Don't worry that the arrows are missing - that's just because I'm testing my code on a local copy, and I didn't save the images locally.)
The following is the code I used to achieve this effect. (It is a modified version of the existing javascript element that is directly after the table.)
Code:
<script type="text/javascript">
$.tablesorter.addParser({
id: 'tier',
is: function(s) {return false;},
format: function(s) {
return s.toLowerCase().replace(/ /g,'').replace(/\n/g,'')
.replace(/^uber$/, 50)
.replace(/^ou$/, 40)
.replace(/^bl$/, 35)
.replace(/^uu$/, 30)
.replace(/^bl2$/, 25)
.replace(/^ru$/, 20)
.replace(/^nu$/, 10)
.replace(/^lc$/, 5)
.replace(/^limbo$/, 0)
.replace(/^nfe$/, -1);
},
type: 'numeric'
});
$("#pokemon_list4981250").tablesorter({
widgets: ['zebra'],
textExtraction: "complex",
sortList: [[0,0], [1,0], [2,0], [3,0], [4,0], [5,0], [6,0], [7,0], [8,0], [9,0]],
headers: {2: {sorter:'tier'}}
})
</script>
To whoever handles the code, you can probably see the changes between the versions.
If not (or if you don't want to run a diff) here they are:
- Add the first function ($.tablesorter.addParser) before tablesorter is called.
- Add the line "headers: {2: {sorter:'tier'}}" to the tablesorter call, adding a comma at the end of the previous line.
- Change [2,1] to [2,0] in the previous line so that the default order is Ascending (i.e., Ubers shows up at top on first click, NFE on second).
Thanks for your consideration,
~Zedadex