<commit_before>/*
 * If there are non-Latin characters, show transliteration field
 */
function toggleTranslit(id) {
	//Regex for everything outside the standard character set
	var nonroman = /[^\u0000-\u024F\u0263\u02B9\u02BA\u02DD\u0300\u0301\u0302\u0303\u0304\u0306\u0308\u0309\u030A\u030C\u0310\u0313\u0315\u0321\u0322\u0323\u0324\u0325\u0327\u0328\u032E\u0332\u0333\u0351\u0357\u0366\u03B1\u04D4\u04D5\u2020\u2070\u2074\u2075\u2076\u2077\u2078\u2079\u207A\u207B\u207D\u207E\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089\u20AC\u2113\u2117\u266D\u266F\uFE20\uFE21\uFE22\uFE23]/;
	//True if any of the characters in title is from a different alphabet
	var needsTranslit = nonroman.test($("#"+id).val());

	//The given name needed to be detected, but the visual changes are named after the family_name#
	if (id.substring(0,5) === 'given') {
		id = 'family' + id.substring(5);

		//The given field has been removed, but the family field still needs transliteration
		if (!needsTranslit && nonroman.test($("#"+id).val())) {
			return;
		}
	}

	if (needsTranslit) {
		$(".translit-" + id).show();
		$("#translit-" + id + "-block").show();
		$(".translit-" + id + "-block").css("padding","3px");
	}
	else {
		if (id.substring(0,6) === 'family') {
			//If the family field has been removed, but the given field still needs transliteration
			if (nonroman.test($("#given" + id.substring(6)).val())) {
				return;
			}
		}

		$(".translit-" + id).hide();
		$("#translit-" + id + "-block").hide();
		$(".translit-" + id + "-block").css("padding","0px");
	}
}

/*
 * If a listening field has been changed, send the id to the toggler.
 */
$("#marc-maker").on('blur','.translit-listen',function() {
	toggleTranslit($(this).attr("id"));
});

/*
 * If a keyword input being deleted or modified, clear the fastID recorded in case the user is inputing
 * a term not in fast
 */
$("#marc-maker").on('keyup', function(e) {
	if (e.keyCode === 8 || e.keyCode === 46) {
		if ($(':focus')[0].id.indexOf('keyword') == 0) {
			$('#fastID' + $(':focus')[0].id.substring(7)).val('');
		}
	}
});

/*
 * When the insert menu is open ESC will get rid of it
 */
$(document).keyup(function(e) {
	if (e.keyCode === 27) {
		if (document.getElementById("insert-popup")) {
			$("#insert-popup").remove();
		}<commit_msg>Added more detailed documentation for a couple functions in generalInteractions, and modified a listener built for the keywords to explicitly only listen for certain keys being pressed when a keyword is the focus, rather than generally listening for the key, and then checking if a keyword field is the focus.<commit_after>/*
 * If there are non-Latin characters, show transliteration field
 * 	id - The HTML id of the input field that has lost focus (suggesting a change in content)
 *
 *	Most input fields are simply checked for non-roman characters, and their corresponding
 *		transliteration field is shown if non-roman characters are detected and hidden if
 *		no non-roman characters are detected. The exception is name fields, which are a 
 *		little more complicated because two inputs are linked. As long as one of the two 
 *		associated name fields has non-roman characters, both the name transliteration 
 *		fields remain visible.
 */
function toggleTranslit(id) {
	//Regex for everything outside the standard character set
	var nonroman = /[^\u0000-\u024F\u0263\u02B9\u02BA\u02DD\u0300\u0301\u0302\u0303\u0304\u0306\u0308\u0309\u030A\u030C\u0310\u0313\u0315\u0321\u0322\u0323\u0324\u0325\u0327\u0328\u032E\u0332\u0333\u0351\u0357\u0366\u03B1\u04D4\u04D5\u2020\u2070\u2074\u2075\u2076\u2077\u2078\u2079\u207A\u207B\u207D\u207E\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089\u20AC\u2113\u2117\u266D\u266F\uFE20\uFE21\uFE22\uFE23]/;
	//True if any of the characters in title is from a different alphabet
	var needsTranslit = nonroman.test($("#"+id).val());

	//The given name needed to be detected, but the visual changes are named after the family_name#
	if (id.substring(0,5) === 'given') {
		id = 'family' + id.substring(5);

		//The given field has been removed, but the family field still needs transliteration
		if (!needsTranslit && nonroman.test($("#"+id).val())) {
			return;
		}
	}

	if (needsTranslit) {
		$(".translit-" + id).show();
		$("#translit-" + id + "-block").show();
		$(".translit-" + id + "-block").css("padding","3px");
	}
	else {
		if (id.substring(0,6) === 'family') {
			//If the family field has been removed, but the given field still needs transliteration
			if (nonroman.test($("#given" + id.substring(6)).val())) {
				return;
			}
		}

		$(".translit-" + id).hide();
		$("#translit-" + id + "-block").hide();
		$(".translit-" + id + "-block").css("padding","0px");
	}
}

/*
 * If a listening field has been changed, send the id to the toggler.
 */
$("#marc-maker").on('blur','.translit-listen',function() {
	toggleTranslit($(this).attr("id"));
});

/*
 * If a keyword input being deleted or modified, clear the fastID recorded in case the user is inputing
 * a term not in fast
 *
 *	This specifically listens for keyCode 8 (backspace) and keyCode 46 (delete).
 *	'$(':focus')[0].id.substring(7))'' is the number in the id of the keyword, which is always of the form
 *		id = keyword#
 */
$("#marc-maker").on('keyup','.keyword', function(e) {
	if (e.keyCode === 8 || e.keyCode === 46) {
		$('#fastID' + $(':focus')[0].id.substring(7)).val('');
	}
});

/*
 * When the insert menu is open ESC will get rid of it
 */
$(document).keyup(function(e) {
	if (e.keyCode === 27) {
		if (document.getElementById("insert-popup")) {
			$("#insert-popup").remove();
		}
{'fraction_non_alphanumeric': 0.17153544709654436, 'fraction_numerical': 0.0906661916636979, 'mean_word_length': 3.929762949956102, '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': '1349383', 'n_tokens_mistral': 2388, 'n_tokens_neox': 2037, 'n_words': 529}