<commit_before>"use strict";

var CSLEDIT = CSLEDIT || {};

CSLEDIT.uiConfig = {};

// if creating an empty node, populate with these attributes
CSLEDIT.uiConfig.defaultAttributes = {
	"text" : {
		"value" : ""
	},
	"if" : {
		"type" : "article",
		"match" : "any"
	},
	"else-if" : {
		"type" : "article",
		"match" : "any"
	},
	"date" : {
		"form" : "text",
		"date-parts" : "year-month-day",
		"variable" : "issued"
	}
}

// for jstree
CSLEDIT.uiConfig.nodeIcons = {
		"default" : "/external/famfamfam-icons/bullet_black.png",
		"text" : "/external/famfamfam-icons/style.png",
		"macro" : "/external/famfamfam-icons/brick.png",
		"info" : "/external/famfamfam-icons/information.png",
		"choose" : "/external/fugue-icons/question-white.png",
		"date" : "/external/famfamfam-icons/date.png",
		"style" : "/external/famfamfam-icons/cog.png",
		"citation" : "/external/famfamfam-icons/page_white_edit.png",
		"bibliography" : "/external/famfamfam-icons/text_list_numbers.png",
		"sort" : "/external/fugue-icons/sort-alphabet.png",
		"number" : "/external/fugue-icons/edit-number.png",
		"layout" : "/external/famfamfam-icons/page_white_stack.png",
		"group" : "/external/famfamfam-icons/page_white_stack.png"
	};

CSLEDIT.uiConfig.capitaliseFirstLetter = function (string)
	{
	    return string.charAt(0).toUpperCase() + string.slice(1);
	};

CSLEDIT.uiConfig.displayNameFromNode = function (node) {
		if (node.name in CSLEDIT.uiConfig.displayNames) {
			return CSLEDIT.uiConfig.displayNames[node.name](node);
		}

		// fall back to using the node name
		return CSLEDIT.uiConfig.capitaliseFirstLetter(node.name);
	};

CSLEDIT.uiConfig.conditionalDisplayName = function (node) {
	var displayName = "",
		elideLimit = 30,
		match = CSLEDIT.schema.attributes("choose/if").match.defaultValue,
		terms = [],
		variable = "",
		join = "";

	$.each(node.attributes, function (i, attribute) {
		if (attribute.enabled) {
		   if (attribute.key === "match") {
				match = attribute.value;
			} else {
				assertEqual(terms.length, 0);
				terms = attribute.value.split(" ");

				// type is so common, don't bother displaying it
				if (attribute.key !== "type") {
					variable = attribute.key;
				}
			}
		}
	});

	if (node.name === "if") {
		displayName = "If ";
	} else {
		displayName = "Else-If ";
	}

	if (match === "any") {
		displayName += terms.join(" OR ");
	} else if (match === "all") {
		displayName += terms.join(" AND ");
	} else if (match === "none") {
		displayName += "NOT (" + terms.join(" OR ") + ")";
	} else {
		assert(false);
	}

	if (displayName.length > elideLimit) {
		displayName = displayName.substr(0, elideLimit-3) + "...";
	}

	return displayName;
};

CSLEDIT.uiConfig.displayNames = {
		"macro" : function (node) {
			return "Macro: " + new CSLEDIT.CslNode(node).getAttr("name");<commit_msg>Fix tree view name for conditional nodes with > 1 type<commit_after>"use strict";

var CSLEDIT = CSLEDIT || {};

CSLEDIT.uiConfig = {};

// if creating an empty node, populate with these attributes
CSLEDIT.uiConfig.defaultAttributes = {
	"text" : {
		"value" : ""
	},
	"if" : {
		"type" : "article",
		"match" : "any"
	},
	"else-if" : {
		"type" : "article",
		"match" : "any"
	},
	"date" : {
		"form" : "text",
		"date-parts" : "year-month-day",
		"variable" : "issued"
	}
}

// for jstree
CSLEDIT.uiConfig.nodeIcons = {
		"default" : "/external/famfamfam-icons/bullet_black.png",
		"text" : "/external/famfamfam-icons/style.png",
		"macro" : "/external/famfamfam-icons/brick.png",
		"info" : "/external/famfamfam-icons/information.png",
		"choose" : "/external/fugue-icons/question-white.png",
		"date" : "/external/famfamfam-icons/date.png",
		"style" : "/external/famfamfam-icons/cog.png",
		"citation" : "/external/famfamfam-icons/page_white_edit.png",
		"bibliography" : "/external/famfamfam-icons/text_list_numbers.png",
		"sort" : "/external/fugue-icons/sort-alphabet.png",
		"number" : "/external/fugue-icons/edit-number.png",
		"layout" : "/external/famfamfam-icons/page_white_stack.png",
		"group" : "/external/famfamfam-icons/page_white_stack.png"
	};

CSLEDIT.uiConfig.capitaliseFirstLetter = function (string)
	{
	    return string.charAt(0).toUpperCase() + string.slice(1);
	};

CSLEDIT.uiConfig.displayNameFromNode = function (node) {
		if (node.name in CSLEDIT.uiConfig.displayNames) {
			return CSLEDIT.uiConfig.displayNames[node.name](node);
		}

		// fall back to using the node name
		return CSLEDIT.uiConfig.capitaliseFirstLetter(node.name);
	};

CSLEDIT.uiConfig.conditionalDisplayName = function (node) {
	var displayName = "",
		elideLimit = 30,
		match = CSLEDIT.schema.attributes("choose/if").match.defaultValue,
		terms = [],
		join = "";

	$.each(node.attributes, function (i, attribute) {
		if (attribute.enabled) {
		   if (attribute.key === "match") {
				match = attribute.value;
			} else {
				$.each(attribute.value.split(" "), function (i, val) {
					terms.push(val);
				});
			}
		}
	});

	if (node.name === "if") {
		displayName = "If ";
	} else {
		displayName = "Else-If ";
	}

	if (match === "any") {
		displayName += terms.join(" OR ");
	} else if (match === "all") {
		displayName += terms.join(" AND ");
	} else if (match === "none") {
		displayName += "NOT (" + terms.join(" OR ") + ")";
	} else {
		assert(false);
	}

	if (displayName.length > elideLimit) {
		displayName = displayName.substr(0, elideLimit-3) + "...";
	}

	return displayName;
};

CSLEDIT.uiConfig.displayNames = {
		"macro" : function (node) {
			return "Macro: " + new CSLEDIT.CslNode(node).getAttr("name");
{'fraction_non_alphanumeric': 0.18779342723004694, 'fraction_numerical': 0.002527988443481401, 'mean_word_length': 3.646812080536913, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '604978', 'n_tokens_mistral': 2273, 'n_tokens_neox': 2077, 'n_words': 347}