Advertisement
Guest User

Expresso Leaderboard Ranking

a guest
Oct 11th, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function(){
  2.   var re = /(\S+) of (\S+)/;
  3.   $("td:contains(' of ')").each(function() {
  4.     var matches = re.exec($(this).text());
  5.     var x = parseInt(matches[1].replace(',',''));
  6.     var y = parseInt(matches[2].replace(',',''));
  7.     var p = Math.round((y-x)/y*100);
  8.     if(x==1){
  9.       $(this).append('<br>(<font color="green">first</font>)');
  10.     } else {
  11.       if(x==y){
  12.         $(this).append('<br>(<font color="red">last</font>)');
  13.       } else if(p<50){
  14.         $(this).append('<br>(<font color="red">bottom ' + p + '%</font>)');
  15.       } else if(p>=50 && p<90){
  16.         p = 100 - p;
  17.         $(this).append('<br>(<font color="orange">top ' + p + '%</font>)');
  18.       } else {
  19.         p = 100 - p;
  20.         $(this).append('<br>(<font color="green">top ' + p + '%</font>)');
  21.       }
  22.     }
  23.   });
  24. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement