Skip to content

Instantly share code, notes, and snippets.

@chapel
Created October 8, 2010 04:22
Show Gist options
  • Save chapel/616353 to your computer and use it in GitHub Desktop.
Save chapel/616353 to your computer and use it in GitHub Desktop.
exports.jqwindow = function(agent, ratingSel, userSel, callback) {
var window = jsdom.jsdom(agent.body).createWindow();
jsdom.jQueryify(window, './jquery.js', function (window, jquery) {
var ratings = [];
var userRating;
window.jQuery(ratingSel).each(function () {
ratings.push(this.innerHTML.trim());
});
window.jQuery(userSel).each(function () {
console.log(this.innerHTML.trim());
userRating = this.innerHTML.trim();
});
callback (ratings, userRating);
});
}
exports.gamestats = function (agent) {
ratingValue = function (ratings, userRating) {
console.log(ratings);
console.log('user rating: '+userRating);
}
exports.jqwindow(agent, 'td[id$=arenaRating]', '.current_selected_player_row td[id$=arenaRating]', ratingValue);
//ratings.sort(compare);
//exports.jqwindow(agent, '.current_selected_player_row > td[id$=arenaRating]', selected);
//console.log(selected.query, ratings.query);
agent.next();
function compare(a,b){
return b-a;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment