Last active
March 1, 2017 19:35
-
-
Save adamdicarlo/5366976 to your computer and use it in GitHub Desktop.
Show card counts for each list (column) in Trello. Bonus: If you have a card with the text "PLACEHOLDER," it will show how many cards come before it, and how many come after it.
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
$('.list').each(function() { | |
var $this = $(this); | |
var count = $this.find('.list-card').length; | |
var $title = $this.find('.list-title h2'); | |
var tester = /.*PLACEHOLDER.*/; | |
var placeholderIndex = false; | |
// Determine the index of the PLACEHOLDER card, if there is one. | |
$this.find('.list-card a').each(function(index, el) { | |
if (tester.exec($(el).text()) !== null) { | |
placeholderIndex = index; | |
} | |
}); | |
if (placeholderIndex !== false) { | |
var before = placeholderIndex; | |
var after = count - placeholderIndex - 1; | |
$title.text($title.text() + ' (' + before + ' | ' + after + ')'); | |
} | |
else { | |
$title.text($title.text() + ' (' + count + ')'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, adam, I am trying to create a web page that appears the amount of cards I have in each list, but I'm not so good with that. Could you explain me how can I use your code to do this?