Created
April 23, 2012 03:26
-
-
Save lukekarrys/2468666 to your computer and use it in GitHub Desktop.
Calculate total PF and PA for an NBA team from ESPN schedule page
This file contains 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
var pointsFor = 0, pointsAgainst = 0; | |
jQuery('.mod-content .game-schedule .score').each(function() { | |
var score = jQuery(this), | |
win = score.prev().hasClass('win'), | |
scoreText = score.children('a').text().split('-'), | |
s1 = parseInt(scoreText[0], 0), | |
s2 = parseInt(scoreText[1], 0); | |
pointsFor += (win) ? s1 : s2; | |
pointsAgainst += (win) ? s2 : s1; | |
}); | |
console.log(pointsFor, pointsAgainst); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment