Last active
February 25, 2016 10:11
-
-
Save logarytm/89e9d3640d150d442241 to your computer and use it in GitHub Desktop.
A bookmarklet for Trello to show completness of entire lists
This file contains hidden or 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
| javascript:Array.prototype.forEach.call(document.querySelectorAll(".list"),function(e){var t=0,r=0;var l=/(\d+?)\/(\d+?)/;var a=e.querySelector(".list-header");Array.prototype.forEach.call(e.querySelectorAll('.badge[title="Checklist items"] .badge-text'),function(e){var a=l.exec(e.textContent);if(a){t+=parseInt(a[2]);r+=parseInt(a[1])}});var o=a.querySelector(".completness")||document.createElement("span");if(t>0){o.textContent=r+"/"+t+" ("+Math.round(r*100/t)+"%)"}o.className="completness";o.style.opacity=.75;o.style.float="right";a.insertBefore(o,a.querySelector(".list-header-menu-icon"))}); |
This file contains hidden or 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
| Array.prototype.forEach.call(document.querySelectorAll('.list'), function(list) { | |
| var all = 0, completed = 0; | |
| var re = /(\d+?)\/(\d+?)/; | |
| var header = list.querySelector('.list-header'); | |
| Array.prototype.forEach.call(list.querySelectorAll('.badge[title="Checklist items"] .badge-text'), function(badge) { | |
| var match = re.exec(badge.textContent); | |
| if (match) { | |
| all += parseInt(match[2]); | |
| completed += parseInt(match[1]); | |
| } | |
| }); | |
| var info = header.querySelector('.completness') || document.createElement('span'); | |
| if (all > 0) { | |
| info.textContent = completed + '/' + all + ' (' + (Math.round(completed * 100 / all)) + '%)'; | |
| } | |
| info.className = 'completness'; | |
| info.style.opacity = 0.75; | |
| info.style.float = 'right'; | |
| header.insertBefore(info, header.querySelector('.list-header-menu-icon')); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment