Skip to content

Instantly share code, notes, and snippets.

@RolandStuder
Last active April 27, 2017 10:49
Show Gist options
  • Save RolandStuder/2c07ce04db8d4bacc76e10bb2a2fc8b7 to your computer and use it in GitHub Desktop.
Save RolandStuder/2c07ce04db8d4bacc76e10bb2a2fc8b7 to your computer and use it in GitHub Desktop.
Enables use of estimates on Github board
// custom javascript for github board
// Strings like '12h' are summed on the top of the columns.
var updateEstimates = window.setInterval(calculateEstimates, 500);
function calculateEstimates(){
var columns = $('.project-column')
for (var i = 0; i < columns.length; i++) {
var sumOfColumn = getSumOfPoints($(columns[i]).find("a.h5").text());
$(columns[i]).find(".Counter").text(sumOfColumn + "h");
}
}
function getSumOfPoints(input) {
var pattern = /(\d+)h/g;
var sumOfPoints = 0
while ((match = pattern.exec(input)) !== null) {
sumOfPoints += parseInt(match[1]);
}
return sumOfPoints
}