Skip to content

Instantly share code, notes, and snippets.

@raik
Last active January 16, 2018 21:33
Show Gist options
  • Select an option

  • Save raik/76c9e7a2899a7cf916986987d18e48e6 to your computer and use it in GitHub Desktop.

Select an option

Save raik/76c9e7a2899a7cf916986987d18e48e6 to your computer and use it in GitHub Desktop.
(function(){
let lists = document.querySelectorAll('.js-list')
Array.from(lists).forEach(function(el, index, array) {
let spans = el.querySelectorAll('span.badge-text')
let sum = 0
Array.from(spans).forEach(function(el, index, array) {
let str = el.innerText
let re = /estimate\:\s+([+-]?([0-9]*[.])?[0-9]+)$/i;
let nr = str.match(re)
if (nr) {
sum += Number(nr[1])
}
})
let title = el.querySelector('.js-list-name-assist')
title.insertAdjacentHTML('afterend', '<strong>Total: ' + sum + '</strong>')
})
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment