Created
March 7, 2012 09:54
-
-
Save jbochi/1992304 to your computer and use it in GitHub Desktop.
Coursera total minutes / section
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
$('.item_section_list').each(function(i, section) { | |
var saw = 0; | |
var total = 0; | |
for (var i = 0; i < section.childNodes.length; i++) { | |
var row = section.childNodes[i]; | |
console.log(row); | |
var viewed = row.classList.contains('viewed'); | |
var minutes = parseInt(row.firstChild.text.match(/\((\d+) min\)/)[1], 10); | |
if (viewed) { | |
saw += minutes; | |
} | |
total += minutes; | |
} | |
var section_title = section.previousElementSibling.firstElementChild; | |
section_title.textContent += ' (' + saw + ' / ' + total + ' min)'; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment