Created
September 23, 2015 17:06
-
-
Save fiskr/5cb8b460ded113ad4b4e to your computer and use it in GitHub Desktop.
Take the coursera lectures' running times and sum them up for each week.
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
[].forEach.call( | |
$('.course-item-list-header'), | |
function(el){ | |
var secSum = 0, | |
minSum = 0, | |
hourSum = 0 | |
originalTitle = ''; | |
originalTitle = $(el).find('h3').text(); | |
//console.log( $(el).find('h3').text() ); | |
[].forEach.call( $(el).next().find('.lecture-link'), | |
function(subEl){ | |
secSum += parseInt($(subEl).text().match(/\:(\d+)\)/)[1], 10); | |
minSum += parseInt($(subEl).text().match(/(\d+)\:/)[1], 10); | |
}); | |
//console.log('hoursum : ' + hourSum + ', minSum: ' + minSum + ', secSum: ' + secSum); | |
minSum += secSum / 60; | |
secSum = secSum % 60; | |
hourSum = minSum / 60; | |
minSum = minSum % 60; | |
$(el).find('h3').append(' (' + parseInt(hourSum, 10) + ':' + parseInt(minSum, 10) + ':' + parseInt(secSum, 10) + ')'); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment