Skip to content

Instantly share code, notes, and snippets.

@shesek
Last active December 15, 2015 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shesek/5185168 to your computer and use it in GitHub Desktop.
Save shesek/5185168 to your computer and use it in GitHub Desktop.
(function(){var e;e=function(e){var t,n;t=+(((n=e.match(/^\s*(?:#\d+)?\s*\(([\d\.]+)\)/))!=null?n[1]:void 0)||0);if(t===t){return t}else{return 0}};$(".list").each(function(){var t,n,r;t=$(this);n=t.find(".list-header h2");r=t.find(".list-card-title:visible").get().reduce(function(t,n){return t+e(n.innerText)},0);return n.find(".total").remove().end().append($("<span>").addClass("total").text(r))});return function(e){return $("<style>").attr({type:"text/css"}).text(e).appendTo("head")}(".list-header .total { float: right }")})()
# Counts the total points for each list
# Points should be added to the beginning of the
# card title, e.g. "(3) Foo bar baz"
do ->
get_points = (t) ->
n = +((t.match /^\s*(?:#\d+)?\s*\(([\d\.]+)\)/)?[1] or 0)
if n is n then n else 0
$('.list').each ->
$t = $ this
$title = $t.find '.list-header h2'
total_points = $t.find('.list-card-title:visible').get().reduce ((a, b) -> a + get_points b.innerText), 0
$title.find('.total').remove().end().append $('<span>').addClass('total').text(total_points)
((style) -> $('<style>').attr(type:'text/css').text(style).appendTo('head')) """
.list-header .total { float: right }
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment