Skip to content

Instantly share code, notes, and snippets.

@timaschew
Last active March 20, 2017 21:39
Show Gist options
  • Save timaschew/ddea277d8f5b1b167877adb90c9dee28 to your computer and use it in GitHub Desktop.
Save timaschew/ddea277d8f5b1b167877adb90c9dee28 to your computer and use it in GitHub Desktop.
Calculates the story points on a trello board and replaces the list title (origin list title MUST NOT have whitespaces)
(function() {
function parsePoints(e) {
const text = $(e).find(".badge-text").text();
const tmp = text.split(' ');
if (tmp[0].trim().toLowerCase() === 'points:') {
return parseInt(tmp[1]);
}
return 0;
}
$(".js-list-content").each((i, board) => {
const cards = $(board).find(".js-plugin-badges");
const points = 0;
cards.each((j, card) => {
points += parsePoints(card);
});
const origin = $(board).find(".list-header-name.mod-list-name.js-list-name-input").text();
const text = origin.split(' ')[0];
$(board).find(".list-header-name.mod-list-name.js-list-name-input").text(text + ' ' + points + 'P');
});
})();
javascript:(function() { function parsePoints(e) { const text = $(e).find(".badge-text").text(); const tmp = text.split(' '); if (tmp[0].trim().toLowerCase() === 'points:') { return parseInt(tmp[1]); } return 0; } $(".js-list-content").each((i, board) => { const cards = $(board).find(".js-plugin-badges"); let points = 0; cards.each((j, card) => { points += parsePoints(card); }); const origin = $(board).find(".list-header-name.mod-list-name.js-list-name-input").text(); const text = origin.split(' ')[0]; $(board).find(".list-header-name.mod-list-name.js-list-name-input").text(text + ' (' + points + 'P)'); });})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment