Skip to content

Instantly share code, notes, and snippets.

@ivalkeen
Last active August 31, 2015 13:53
Show Gist options
  • Save ivalkeen/06a4ebf10f43c3957810 to your computer and use it in GitHub Desktop.
Save ivalkeen/06a4ebf10f43c3957810 to your computer and use it in GitHub Desktop.
Trello sum
javascript:$('.list').each(function(i, col) {
var ests = $($(col).find('.list-card-title').text().match(/\[([\dF-]+)+\]/ig)).map(function(_, estStr) {
console.log("Found string: ", estStr);
var result = estStr.replace(/[\[\]]/g, '');
if (result.length == 4) {
result = result.split('').reduce(function(sum, current) {
var currentValue = parseInt(current.replace('-', '0').replace(/f/i, '16'));
return currentValue + sum;
}, 0);
} else {
result = parseInt(result);
}
return result;
});
var total = 0;
ests.each(function(i) { total = total + ests[i] });
var cleanTitle = $(col).find('.list-header-name').text().replace(/\[[^\[\]]+\]/g, '');
$(col).find('.list-header-name').text('[' + total + '] ' + cleanTitle);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment