<commit_before>$(document).ready(function(){

	var
		TypeAheader = window.Diaphanum.TypeAheader,
		typeAheadConfig = {
			template : $("#person-autocomplete-template").html(),
			name : "names" + _.uniqueId()
		};

	var typeAheadCallbackCreator = function(closestFieldContainerClass, idContainerClass) {
		return function(data) {
			$(this)
				.closest(closestFieldContainerClass)
				.find("input" + idContainerClass)
				.val(data.id);
		};
	};

	var excusedCallback = typeAheadCallbackCreator(".excused-member-field", ".excused-id-container");
	var absentCallback = typeAheadCallbackCreator(".absent-member-field", ".absent-id-container");
	var attendentsCallback = typeAheadCallbackCreator(".attendents-member-field", ".attendents-id-container");
	
	var topicsCount = 1; //TODO: Check if it is posible to have protocol with no topics
	var utils = window.Diaphanum.utils;

	$(".protocol-form")
		.on("click", ".add-excused", function(){
			var newExcusedFieldHtml = $("#new-excused").html();
			// use underscore if any placeholders
			$(newExcusedFieldHtml).insertBefore("#excused-error");

			TypeAheader.feed(
				$("input.autocomplete.excused").not(".tt-query"),
				typeAheadConfig,
				excusedCallback);
		})
		.on("click", ".remove-excused", function(){
			$(this).parent().remove();
		})
		.on("click", ".add-absent", function(){
			var newAbsentFieldHtml = $("#new-absent").html();
			// use underscore if any placeholders
			$(newAbsentFieldHtml).insertBefore("#absent-error");

			TypeAheader.feed(
				$("input.autocomplete.absent").not(".tt-query"),
				typeAheadConfig,
				absentCallback );
		})
		.on("click", ".remove-absent", function(){
			$(this).parent().remove();
		})
		.on("click", ".add-attendents", function(){
			var newAttendentsFieldHtml = $("#new-attendents").html();
			// use underscore if any placeholders
			$(newAttendentsFieldHtml).insertBefore("#attendents-error");

			TypeAheader.feed(
				$("input.autocomplete.attendents").not(".tt-query"),
				typeAheadConfig,
				attendentsCallback);
		})
		.on("click", ".remove-attendents", function(){
			$(this).parent().remove();
		})
		.on("click", ".add-field", function(){
			var newAddMoreFieldHtml = $("#new-field").html();
			// use underscore if any placeholders
			$(newAddMoreFieldHtml).insertBefore($(this));
			$(this).remove();
		})
		.on("click", "#protocol-form-submit", function(){

			//TODO: Refacture that ugliness
			var topicIndex = 0;
			$(".voteTopic").each(function() {
				$(this).attr("name", "topics-" + topicIndex + "-name");
				topicIndex += 1;
			})

			var topicVodedFor = 0;
			$(".topics-voted-for").each(function() {
				$(this).attr("name", "topics-" + topicVodedFor + "-voted_for");
				topicVodedFor += 1;
			})

			var topicVodedAgainst = 0;
			$(".topics-voted-against").each(function() {
				$(this).attr("name", "topics-" + topicVodedAgainst + "-voted_against");
				topicVodedAgainst += 1;
			})

			var topicVodedAbstain = 0;
			$(".topics-voted-abstain").each(function() {
				$(this).attr("name", "topics-" + topicVodedAbstain + "-voted_abstain");
				topicVodedAbstain += 1;
			})

			$("input[name='topics-TOTAL_FORMS']").val(topicsCount);
		})
		.validate({<commit_msg>Set event on submit not on click (no change)<commit_after>$(document).ready(function(){

	var
		TypeAheader = window.Diaphanum.TypeAheader,
		typeAheadConfig = {
			template : $("#person-autocomplete-template").html(),
			name : "names" + _.uniqueId()
		};

	var typeAheadCallbackCreator = function(closestFieldContainerClass, idContainerClass) {
		return function(data) {
			$(this)
				.closest(closestFieldContainerClass)
				.find("input" + idContainerClass)
				.val(data.id);
		};
	};

	var excusedCallback = typeAheadCallbackCreator(".excused-member-field", ".excused-id-container");
	var absentCallback = typeAheadCallbackCreator(".absent-member-field", ".absent-id-container");
	var attendentsCallback = typeAheadCallbackCreator(".attendents-member-field", ".attendents-id-container");
	
	var topicsCount = 1; //TODO: Check if it is posible to have protocol with no topics
	var utils = window.Diaphanum.utils;

	$(".protocol-form")
		.on("click", ".add-excused", function(){
			var newExcusedFieldHtml = $("#new-excused").html();
			// use underscore if any placeholders
			$(newExcusedFieldHtml).insertBefore("#excused-error");

			TypeAheader.feed(
				$("input.autocomplete.excused").not(".tt-query"),
				typeAheadConfig,
				excusedCallback);
		})
		.on("click", ".remove-excused", function(){
			$(this).parent().remove();
		})
		.on("click", ".add-absent", function(){
			var newAbsentFieldHtml = $("#new-absent").html();
			// use underscore if any placeholders
			$(newAbsentFieldHtml).insertBefore("#absent-error");

			TypeAheader.feed(
				$("input.autocomplete.absent").not(".tt-query"),
				typeAheadConfig,
				absentCallback );
		})
		.on("click", ".remove-absent", function(){
			$(this).parent().remove();
		})
		.on("click", ".add-attendents", function(){
			var newAttendentsFieldHtml = $("#new-attendents").html();
			// use underscore if any placeholders
			$(newAttendentsFieldHtml).insertBefore("#attendents-error");

			TypeAheader.feed(
				$("input.autocomplete.attendents").not(".tt-query"),
				typeAheadConfig,
				attendentsCallback);
		})
		.on("click", ".remove-attendents", function(){
			$(this).parent().remove();
		})
		.on("click", ".add-field", function(){
			var newAddMoreFieldHtml = $("#new-field").html();
			// use underscore if any placeholders
			$(newAddMoreFieldHtml).insertBefore($(this));
			$(this).remove();
		})
		.submit(function(){
			alert("Рабитя");
			//TODO: Refacture that ugliness
			var topicIndex = 0;
			$(".voteTopic").each(function() {
				$(this).attr("name", "topics-" + topicIndex + "-name");
				topicIndex += 1;
			})

			var topicVodedFor = 0;
			$(".topics-voted-for").each(function() {
				$(this).attr("name", "topics-" + topicVodedFor + "-voted_for");
				topicVodedFor += 1;
			})

			var topicVodedAgainst = 0;
			$(".topics-voted-against").each(function() {
				$(this).attr("name", "topics-" + topicVodedAgainst + "-voted_against");
				topicVodedAgainst += 1;
			})

			var topicVodedAbstain = 0;
			$(".topics-voted-abstain").each(function() {
				$(this).attr("name", "topics-" + topicVodedAbstain + "-voted_abstain");
				topicVodedAbstain += 1;
			})

			$("input[name='topics-TOTAL_FORMS']").val(topicsCount);
		})
		.validate({
{'fraction_non_alphanumeric': 0.19172113289760348, 'fraction_numerical': 0.0028011204481792717, 'mean_word_length': 4.108903020667727, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '1060874', 'n_tokens_mistral': 2506, 'n_tokens_neox': 2119, 'n_words': 354}