<commit_before>/*******************************************************************************
 * Use bag checkbox has been clicked.
 ******************************************************************************/
function clickUseBag(index) {
	var useBag = document.templateForm["useBagConstraint("+index+")"].checked;
	if (document.templateForm["attributeOps("+index+")"] && document.templateForm["attributeOps("+index+")"] != undefined)
	    document.templateForm["attributeOps("+index+")"].disabled=useBag;
	if (document.templateForm["attributeOptions("+index+")"]) {
		document.templateForm["attributeOptions("+index+")"].disabled=useBag;
	}
	// if attributeValues is a radio button
	if (document.templateForm["attributeValues("+index+")"][0]) {
		document.templateForm["attributeValues("+index+")"][0].disabled=useBag;
		document.templateForm["attributeValues("+index+")"][1].disabled=useBag;
	}
	if (document.templateForm["multiValues("+index+")"]) {
		document.templateForm["multiValues("+index+")"].disabled=useBag;
	}
	if (document.templateForm["extraValues("+index+")"]) {
		document.templateForm["extraValues("+index+")"].disabled=useBag;
	}
	document.templateForm["attributeValues("+index+")"].disabled=useBag;
	document.templateForm["bag("+index+")"].disabled=!useBag;
	document.templateForm["bagOp("+index+")"].disabled=!useBag;	
}

function forwardToLinks() {
	// needed validation that bag is not used, validation is performed in the
    // Struts action as well
	if (isBagUsed()) {
		new Insertion.Bottom('error_msg','Link could not be created. This template contains a list constraint, which is currently not supported.  Remove the list constraint and try again.<br/>');
		haserrors=1;
		jQuery('#error_msg').fadeIn();
		return;
	}
	document.getElementById('actionType').value = 'links';
	document.templateForm.submit();
}

function exportTemplate() {
    document.getElementById('actionType').value = 'exportTemplate';
    document.templateForm.submit();
}

function isBagUsed() {
	// checks if bag is used, the presumption is that there aren't more than 10
    // bag constraints
	for (var i = 0; i < 10; i++) {
		if (document.templateForm["useBagConstraint("+i+")"]) {
			if (document.templateForm["useBagConstraint("+i+")"].checked) {
				return true;
			}
		}
	}
	return false;
}

function updateAttributeValues(index) {
	var attributeValues = document.templateForm['attributeValues('+index+')'];
	var selectedString = '';
	var attributeOptions = document.templateForm['attributeOptions('+index+')'];
	if (attributeOptions != "undefined") {
		var i;
		var count = 0;
		for (i = 0; i < attributeOptions.options.length; i++) {
			if (attributeOptions.options[i].selected) {
// var selectedValue = '\'' + attributeOptions.options[i].value + '\'';
				var selectedValue = attributeOptions.options[i].value;
				if (selectedString != '') {
					selectedString += ',';	
				}
				selectedString += selectedValue;
			}	
		}	
		attributeValues.value = selectedString;		
	}
}	

function updateMultiValueAttribute(index) {<commit_msg>undefined instead of "undefined"<commit_after>/*******************************************************************************
 * Use bag checkbox has been clicked.
 ******************************************************************************/
function clickUseBag(index) {
	var useBag = document.templateForm["useBagConstraint("+index+")"].checked;
	if (document.templateForm["attributeOps("+index+")"] && document.templateForm["attributeOps("+index+")"] != undefined)
	    document.templateForm["attributeOps("+index+")"].disabled=useBag;
	if (document.templateForm["attributeOptions("+index+")"]) {
		document.templateForm["attributeOptions("+index+")"].disabled=useBag;
	}
	// if attributeValues is a radio button
	if (document.templateForm["attributeValues("+index+")"][0]) {
		document.templateForm["attributeValues("+index+")"][0].disabled=useBag;
		document.templateForm["attributeValues("+index+")"][1].disabled=useBag;
	}
	if (document.templateForm["multiValues("+index+")"]) {
		document.templateForm["multiValues("+index+")"].disabled=useBag;
	}
	if (document.templateForm["extraValues("+index+")"]) {
		document.templateForm["extraValues("+index+")"].disabled=useBag;
	}
	document.templateForm["attributeValues("+index+")"].disabled=useBag;
	document.templateForm["bag("+index+")"].disabled=!useBag;
	document.templateForm["bagOp("+index+")"].disabled=!useBag;	
}

function forwardToLinks() {
	// needed validation that bag is not used, validation is performed in the
    // Struts action as well
	if (isBagUsed()) {
		new Insertion.Bottom('error_msg','Link could not be created. This template contains a list constraint, which is currently not supported.  Remove the list constraint and try again.<br/>');
		haserrors=1;
		jQuery('#error_msg').fadeIn();
		return;
	}
	document.getElementById('actionType').value = 'links';
	document.templateForm.submit();
}

function exportTemplate() {
    document.getElementById('actionType').value = 'exportTemplate';
    document.templateForm.submit();
}

function isBagUsed() {
	// checks if bag is used, the presumption is that there aren't more than 10
    // bag constraints
	for (var i = 0; i < 10; i++) {
		if (document.templateForm["useBagConstraint("+i+")"]) {
			if (document.templateForm["useBagConstraint("+i+")"].checked) {
				return true;
			}
		}
	}
	return false;
}

function updateAttributeValues(index) {
	var attributeValues = document.templateForm['attributeValues('+index+')'];
	var selectedString = '';
	var attributeOptions = document.templateForm['attributeOptions('+index+')'];
	if (attributeOptions != undefined) {
		var i;
		var count = 0;
		for (i = 0; i < attributeOptions.options.length; i++) {
			if (attributeOptions.options[i].selected) {
// var selectedValue = '\'' + attributeOptions.options[i].value + '\'';
				var selectedValue = attributeOptions.options[i].value;
				if (selectedString != '') {
					selectedString += ',';	
				}
				selectedString += selectedValue;
			}	
		}	
		attributeValues.value = selectedString;		
	}
}	

function updateMultiValueAttribute(index) {
{'fraction_non_alphanumeric': 0.21193785772690107, 'fraction_numerical': 0.0035977105478331973, 'mean_word_length': 5.9029345372460496, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '4666988', 'n_tokens_mistral': 1859, 'n_tokens_neox': 1736, 'n_words': 339}