<commit_before>var PODLOVE = PODLOVE || {};

(function($) {

	$(document).ready(function(){
		if ( $("#add_contributors_submit").length ) {
			$("#add_contributors_submit").on("click", function(e) {
				e.preventDefault();

				var $add_contributors_input = $("#add_contributors_input");
				var new_contributor = $add_contributors_input.val();

				if (!new_contributor.length) return false;

				PODLOVE.add_contributor({
					slug: new_contributor,
					id: 0,
					avatar: null,
					name: new_contributor
				});

				return false;
			});

			$("#contributors").on("click", ".contributor a.ntdelbutton", function(e) {
				e.preventDefault();

				var $contributor = $(this).closest(".contributor");

				// actually remove contributor
				var slug = $contributor.data('termSlug');

				var $data_field = $("#tax-input-podlove-contributors");
				var contributors = $data_field.val().split(",");

				// remove by slug
				contributors.splice(contributors.indexOf(slug),1);
				$data_field.val(contributors.join(","));

				// visurally remove contributor
				$contributor.remove();

				return false;
			});

			$("#add_contributors_input").autocomplete({
				minLength: 0,
				source: PODLOVE.people,
				focus: function(event, ui) {
					$("#add_contributors_input").val(ui.item.label);

					return false;
				},
				select: function(event, ui) {

					PODLOVE.add_contributor({
						slug: ui.item.value,
						id: ui.item.id,
						avatar: ui.item.avatar,
						name: ui.item.label
					});

					return false;
				}
			}).data('autocomplete')._renderItem = function(ul, item) {

				var template = PODLOVE.contributor_template({
					avatar: item.avatar,
					name: item.label,
					display_delete: false,
					display_data: false,
					"class": "contributor autocomplete"
				});

				return $( "<li></li>" )
				    .data( "item.autocomplete", item )
				    .append( "<a>" + template + "</a>" )
				    .appendTo( ul );
			};
		}
	});

	PODLOVE.add_contributor = function(options) {

		if (!options.avatar) {
			options.avatar = 'http://www.gravatar.com/avatar?d=mm';
		}

		// visually add contributor
		$("#add_contributors_input").val('');
		$("#contributors").append(PODLOVE.contributor_template(options));

		// actually add contributor
		var $data_field = $("#tax-input-podlove-contributors");
		var contributors = $data_field.val();

		if (!contributors.length) {
			contributors = options.slug;
		} else {
			contributors = contributors + "," + options.slug;	
		}
		
		$data_field.val(contributors);
	}

	PODLOVE.contributor_template = function(options) {<commit_msg>fix javascript issue<commit_after>var PODLOVE = PODLOVE || {};

(function($) {

	$(document).ready(function(){
		if ( $("#add_contributors_submit").length ) {
			$("#add_contributors_submit").on("click", function(e) {
				e.preventDefault();

				var $add_contributors_input = $("#add_contributors_input");
				var new_contributor = $add_contributors_input.val();

				if (!new_contributor.length) return false;

				PODLOVE.add_contributor({
					slug: new_contributor,
					id: 0,
					avatar: null,
					name: new_contributor
				});

				return false;
			});

			$("#contributors").on("click", ".contributor a.ntdelbutton", function(e) {
				e.preventDefault();

				var $contributor = $(this).closest(".contributor");

				// actually remove contributor
				var slug = $contributor.data('termSlug');

				var $data_field = $("#tax-input-podlove-contributors");
				var contributors = $data_field.val().split(",");

				// remove by slug
				contributors.splice(contributors.indexOf(slug),1);
				$data_field.val(contributors.join(","));

				// visurally remove contributor
				$contributor.remove();

				return false;
			});

			var $input = $("#add_contributors_input").autocomplete({
				minLength: 0,
				source: PODLOVE.people,
				focus: function(event, ui) {
					$("#add_contributors_input").val(ui.item.label);

					return false;
				},
				select: function(event, ui) {

					PODLOVE.add_contributor({
						slug: ui.item.value,
						id: ui.item.id,
						avatar: ui.item.avatar,
						name: ui.item.label
					});

					return false;
				}
			}).data('autocomplete');

			if ($input && $input.length) {
				$input._renderItem = function(ul, item) {

					var template = PODLOVE.contributor_template({
						avatar: item.avatar,
						name: item.label,
						display_delete: false,
						display_data: false,
						"class": "contributor autocomplete"
					});

					return $( "<li></li>" )
					    .data( "item.autocomplete", item )
					    .append( "<a>" + template + "</a>" )
					    .appendTo( ul );
				};
			}
		}
	});

	PODLOVE.add_contributor = function(options) {

		if (!options.avatar) {
			options.avatar = 'http://www.gravatar.com/avatar?d=mm';
		}

		// visually add contributor
		$("#add_contributors_input").val('');
		$("#contributors").append(PODLOVE.contributor_template(options));

		// actually add contributor
		var $data_field = $("#tax-input-podlove-contributors");
		var contributors = $data_field.val();

		if (!contributors.length) {
			contributors = options.slug;
		} else {
			contributors = contributors + "," + options.slug;	
		}
		
		$data_field.val(contributors);
	}

	PODLOVE.contributor_template = function(options) {
{'fraction_non_alphanumeric': 0.16476624857468644, 'fraction_numerical': 0.0011402508551881414, 'mean_word_length': 3.2070343725019983, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7642421', 'n_tokens_mistral': 2254, 'n_tokens_neox': 1704, 'n_words': 300}