Last active
August 5, 2016 16:37
-
-
Save mattroyer/1298d87822ab78cb641416a3b0be7fe1 to your computer and use it in GitHub Desktop.
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 times = $(".lecture__item").not('.completed').find('.lecture__item__link__time').map(function() { return $(this).text() }); | |
var reduced_time = times.map(function() { return this.split(":").map(function(str) { return parseInt(str) }).reduce(function(a, b) { return a * 60 + b}) }); | |
var seconds = Array.from(reduced_time).reduce(function(a, b) { return a + b }, 0); | |
Number.prototype.toHHMMSS = function () { | |
var sec_num = parseInt(this, 10); // don't forget the second param | |
var hours = Math.floor(sec_num / 3600); | |
var minutes = Math.floor((sec_num - (hours * 3600)) / 60); | |
var seconds = sec_num - (hours * 3600) - (minutes * 60); | |
if (hours < 10) {hours = "0"+hours;} | |
if (minutes < 10) {minutes = "0"+minutes;} | |
if (seconds < 10) {seconds = "0"+seconds;} | |
var time = hours+':'+minutes+':'+seconds; | |
return time; | |
} | |
var one_point_five_time = seconds / 1.5 | |
alert("Normal Time: " + seconds.toHHMMSS() + "\n 1.5x Time: " + one_point_five_time.toHHMMSS()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment