Created
September 18, 2012 04:08
-
-
Save ttrefren/3741200 to your computer and use it in GitHub Desktop.
sort cardpool gift cards by discount amount
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
// http://www.cardpool.com/buy-gift-cards | |
var table = $($("table.merchants_grid")[0]); | |
var boxes = table.find("td.merchant_cell"); | |
boxes.sort(function(a, b) { | |
var val1 = parseInt($(a).find('.merchant_discount').text()), | |
val2 = parseInt($(b).find('.merchant_discount').text()); | |
return val2 - val1; | |
}); | |
for (var i = 0; i < boxes.length; i++) { | |
var tr = $(table.find("tr")[Math.floor(i / 5)]); | |
tr.append(boxes[i]); | |
} | |
// make out-of-stock obvious | |
$($("table.merchants_grid")[1]).css("opacity", 0.25); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment