<commit_before>/*
** Scrum for Trello- https://github.com/Q42/TrelloScrum
** Adds Scrum to your Trello
**
** Original:
** <NAME> <https://github.com/jkaizer>
** <NAME> <https://github.com/marcelduin>
**
** Contribs:
** <NAME> <https://github.com/paullofte>
** <NAME> <https://github.com/nicpottier>
** <NAME> <https://github.com/bastiaanterhorst>
** <NAME> <https://github.com/mgan59>
** <NAME> <https://github.com/frankgeerlings>
** <NAME> <https://github.com/CedricGatay>
** <NAME> <https://github.com/kitglen>
**
*/

//default story point picker sequence
var _pointSeq = ['?', 0, .5, 1, 2, 3, 5, 8, 13, 21];
//attributes representing points values for card
var _pointsAttr = ['cpoints', 'points'];


//internals
var filtered = false, //watch for filtered cards
	reg = /[\(](\x3f|\d*\.?\d+)([\)])\s?/m, //parse regexp- accepts digits, decimals and '?', surrounded by ()
	regC = /[\[](\x3f|\d*\.?\d+)([\]])\s?/m, //parse regexp- accepts digits, decimals and '?', surrounded by []
	iconUrl = chrome.extension.getURL('images/storypoints-icon.png'),
	pointsDoneUrl = chrome.extension.getURL('images/points-done.png');

function round(_val) {return (Math.floor(_val * 100) / 100)};

//what to do when DOM loads
$(function(){
	//watch filtering
	function updateFilters() {
		setTimeout(function(){
			filtered=$('.js-filter-cards').hasClass('is-on');
			calcListPoints()
		})		
	}
	$('.js-toggle-label-filter, .js-select-member, .js-due-filter, .js-clear-all').live('mouseup', updateFilters);
	$('.js-input').live('keyup', updateFilters);

	//for storypoint picker
	$(".card-detail-title .edit-controls").live('DOMNodeInserted',showPointPicker);

	$('.js-share').live('mouseup',function(){
		setTimeout(checkExport,500)
	});

	calcListPoints();

});

document.body.addEventListener('DOMNodeInserted',function(e){
	if(e.target.id=='board') setTimeout(calcListPoints);
});

//calculate board totals
var ctto;
function computeTotal(){
	clearTimeout(ctto);
	ctto = setTimeout(function(){
		var $title = $('#board-header');
		var $total = $title.children('.list-total').empty();
		if ($total.length == 0)
			$total = $('<span class="list-total">').appendTo($title);

		for (var i in _pointsAttr){
			var score = 0,
				attr = _pointsAttr[i];
			$('#board .list-total .'+attr).each(function(){
				score+=parseFloat(this.textContent)||0;
			});
			$total.append('<span class="'+attr+'">'+(round(score)||'')+'</span>');
		}
	});
};

//calculate list totals<commit_msg>board totals don't disappear when changing board name<commit_after>/*
** Scrum for Trello- https://github.com/Q42/TrelloScrum
** Adds Scrum to your Trello
**
** Original:
** <NAME> <https://github.com/jkaizer>
** <NAME> <https://github.com/marcelduin>
**
** Contribs:
** <NAME> <https://github.com/paullofte>
** <NAME> <https://github.com/nicpottier>
** <NAME> <https://github.com/bastiaanterhorst>
** <NAME> <https://github.com/mgan59>
** <NAME> <https://github.com/frankgeerlings>
** <NAME> <https://github.com/CedricGatay>
** <NAME> <https://github.com/kitglen>
**
*/

//default story point picker sequence
var _pointSeq = ['?', 0, .5, 1, 2, 3, 5, 8, 13, 21];
//attributes representing points values for card
var _pointsAttr = ['cpoints', 'points'];


//internals
var filtered = false, //watch for filtered cards
	reg = /[\(](\x3f|\d*\.?\d+)([\)])\s?/m, //parse regexp- accepts digits, decimals and '?', surrounded by ()
	regC = /[\[](\x3f|\d*\.?\d+)([\]])\s?/m, //parse regexp- accepts digits, decimals and '?', surrounded by []
	iconUrl = chrome.extension.getURL('images/storypoints-icon.png'),
	pointsDoneUrl = chrome.extension.getURL('images/points-done.png');

function round(_val) {return (Math.floor(_val * 100) / 100)};

//what to do when DOM loads
$(function(){
	//watch filtering
	function updateFilters() {
		setTimeout(function(){
			filtered=$('.js-filter-cards').hasClass('is-on');
			calcListPoints()
		})		
	}
	$('.js-toggle-label-filter, .js-select-member, .js-due-filter, .js-clear-all').live('mouseup', updateFilters);
	$('.js-input').live('keyup', updateFilters);

	//for storypoint picker
	$(".card-detail-title .edit-controls").live('DOMNodeInserted',showPointPicker);

	$('.js-share').live('mouseup',function(){
		setTimeout(checkExport,500)
	});

	calcListPoints();

});

document.body.addEventListener('DOMNodeInserted',function(e){
	if(e.target.id=='board') setTimeout(calcListPoints);
	else if($(e.target).hasClass('board-name')) computeTotal();
});

//calculate board totals
var ctto;
function computeTotal(){
	clearTimeout(ctto);
	ctto = setTimeout(function(){
		var $title = $('#board-header');
		var $total = $title.children('.list-total').empty();
		if ($total.length == 0)
			$total = $('<span class="list-total">').appendTo($title);

		for (var i in _pointsAttr){
			var score = 0,
				attr = _pointsAttr[i];
			$('#board .list-total .'+attr).each(function(){
				score+=parseFloat(this.textContent)||0;
			});
			$total.append('<span class="'+attr+'">'+(round(score)||'')+'</span>');
		}
	});
};

//calculate list totals
{'fraction_non_alphanumeric': 0.22532402791625125, 'fraction_numerical': 0.01156530408773679, 'mean_word_length': 4.5671476137624865, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 20, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3046325', 'n_tokens_mistral': 1903, 'n_tokens_neox': 1783, 'n_words': 343}