Advertisement
Guest User

Untitled

a guest
Mar 29th, 2012
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var arr = [], i, _i, tmp, good, bad, out = [];
  2. $('.gamecode').each(function( ){
  3.     var $this = $(this);
  4.    
  5.     arr.push({
  6.         text: $this.find('.innercodetable font:first')[0].textContent,
  7.         good: $this.find('[id^=good_on_count]').html(),
  8.         bad: $this.find('[id^=bad_off_count]').html(),
  9.         goodBtn: $this.find('.cursor_pointer:first')
  10.     });
  11. });
  12.  
  13. //тут мы всё выдрали и радуемся
  14. for( i = arr.length; i; ){
  15.     tmp = arr[ --i ];
  16.     good = tmp.good = parseInt( tmp.good, 10 );
  17.     bad = tmp.bad = parseInt( tmp.bad, 10 );
  18.     if( good < bad ) // если гуда меньше
  19.         arr.splice( i, 1 );// убиваем элемент
  20.    
  21. }
  22.  
  23. arr.sort( function( a, b ){ // посортируем
  24.     return b.good - a.good;
  25. } );
  26.  
  27. // заебенем в массив тексты
  28. for( i = 0, _i = arr.length; i < _i; i++ ){
  29.     tmp = arr[ i ];
  30.     out[ i ] = tmp.text;
  31.     // попутно кликнем
  32.     tmp.goodBtn.click()
  33. }
  34.    
  35. // выведем их через разделитель строки    
  36. console.log( out.join( '\n' ) );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement