<commit_before>Node.FindNodeType = function(nodeText,returnKey)
{
	if( typeof(returnKey) === "undefined") returnKey = false;
	for (var key in Node.NodeTypes) {
		if (Node.NodeTypes.hasOwnProperty(key)) {
			var element = Node.NodeTypes[key];
			if(element.name === nodeText) 
			{
				if(returnKey)
					return key;
				else
					return Node.NodeTypes[key];
			}
			else continue;
		}
	}
}

Node.onSelectedFunctionChange = function()
{
	var e = document.getElementById("nodeFunctionSelect");
	var selectedFunction = e.options[e.selectedIndex].text;
	selectedFunction = Node.FindNodeType(selectedFunction);
	e = document.getElementById("additionalContent");
	e.innerHTML = "";

	for (var i = 0; i < selectedFunction.params.length; i++) {
		var element = selectedFunction.params[i];
		e.innerHTML += '<label>'+ element.name +'</label><input class="nodeItem" type="'+ element.type +'" id="'+ element.name.hashCode() +'"></input><br>';		
	}
}

onEditNode = function(nodeData, callback)
{
	Node._createNodeModal(function()
	{
		Node._editNodeData(nodeData,callback);
		gl.aceEditor.setValue(nodeData.SCRIPT_TXT);
	},
	function()
	{
		var e = document.getElementById("nodeFunctionSelect");
		var i = 0;
		for (var key in Node.NodeTypes) {
			if (Node.NodeTypes.hasOwnProperty(key)) {
				var element = Node.NodeTypes[key];
				if(element.name === nodeData.nodeType.name)
				{
					e.selectedIndex = i;
					break;
				}
				else i++;
			}
		}
		Node.onSelectedFunctionChange();
	});
}

onEditEdge = function(edgeData, callback)
{
	callback(edgeData);
}

Node._createNodeModal = function(callback,createCallback)
{
	var list = '';
	for (var key in Node.NodeTypes) {
		if (Node.NodeTypes.hasOwnProperty(key)) {
			var element = Node.NodeTypes[key];
			list += '<option value="'+ key +'">'+ element.name +'</option>';
		}
	}
	ModalManager.createModal('<center><select id="nodeFunctionSelect" selectedIndex=0 onchange="Node.onSelectedFunctionChange()">'+ list +'</select><br><div id="additionalContent"></div<</center>',callback,createCallback);
}

Node._editNodeData = function(nodeData,callback)
{
	var e = document.getElementById("nodeFunctionSelect");
	var selectedFunction = Node.FindNodeType(e.options[e.selectedIndex].text);
	var selectedFunctionKey = Node.FindNodeType(e.options[e.selectedIndex].text, true)

	var inputs = document.getElementById('additionalContent').getElementsByTagName('input');
	var labels = document.getElementById('additionalContent').getElementsByTagName('label');
	
	nodeData.m22metadata = {};
	nodeData.SCRIPT_TXT = selectedFunctionKey;
	nodeData.label = selectedFunctionKey;
	for (var i = 0; i < labels.length; i++) {
		nodeData.m22metadata[labels[i].innerHTML] = inputs[i].value;
		nodeData.SCRIPT_TXT += " " + inputs[i].value;
	}

	switch(selectedFunction)<commit_msg>Fix bug with checkbox booleans<commit_after>Node.FindNodeType = function(nodeText,returnKey)
{
	if( typeof(returnKey) === "undefined") returnKey = false;
	for (var key in Node.NodeTypes) {
		if (Node.NodeTypes.hasOwnProperty(key)) {
			var element = Node.NodeTypes[key];
			if(element.name === nodeText) 
			{
				if(returnKey)
					return key;
				else
					return Node.NodeTypes[key];
			}
			else continue;
		}
	}
}

Node.onSelectedFunctionChange = function()
{
	var e = document.getElementById("nodeFunctionSelect");
	var selectedFunction = e.options[e.selectedIndex].text;
	selectedFunction = Node.FindNodeType(selectedFunction);
	e = document.getElementById("additionalContent");
	e.innerHTML = "";

	for (var i = 0; i < selectedFunction.params.length; i++) {
		var element = selectedFunction.params[i];
		e.innerHTML += '<label>'+ element.name +'</label><input class="nodeItem" type="'+ element.type +'" id="'+ element.name.hashCode() +'"></input><br>';		
	}
}

onEditNode = function(nodeData, callback)
{
	Node._createNodeModal(function()
	{
		Node._editNodeData(nodeData,callback);
		gl.aceEditor.setValue(nodeData.SCRIPT_TXT);
	},
	function()
	{
		var e = document.getElementById("nodeFunctionSelect");
		var i = 0;
		for (var key in Node.NodeTypes) {
			if (Node.NodeTypes.hasOwnProperty(key)) {
				var element = Node.NodeTypes[key];
				if(element.name === nodeData.nodeType.name)
				{
					e.selectedIndex = i;
					break;
				}
				else i++;
			}
		}
		Node.onSelectedFunctionChange();
	});
}

onEditEdge = function(edgeData, callback)
{
	callback(edgeData);
}

Node._createNodeModal = function(callback,createCallback)
{
	var list = '';
	for (var key in Node.NodeTypes) {
		if (Node.NodeTypes.hasOwnProperty(key)) {
			var element = Node.NodeTypes[key];
			list += '<option value="'+ key +'">'+ element.name +'</option>';
		}
	}
	ModalManager.createModal('<center><select id="nodeFunctionSelect" selectedIndex=0 onchange="Node.onSelectedFunctionChange()">'+ list +'</select><br><div id="additionalContent"></div<</center>',callback,createCallback);
}

Node._editNodeData = function(nodeData,callback)
{
	var e = document.getElementById("nodeFunctionSelect");
	var selectedFunction = Node.FindNodeType(e.options[e.selectedIndex].text);
	var selectedFunctionKey = Node.FindNodeType(e.options[e.selectedIndex].text, true)

	var inputs = document.getElementById('additionalContent').getElementsByTagName('input');
	var labels = document.getElementById('additionalContent').getElementsByTagName('label');
	
	nodeData.m22metadata = {};
	nodeData.SCRIPT_TXT = selectedFunctionKey;
	nodeData.label = selectedFunctionKey;
	for (var i = 0; i < labels.length; i++) {
		nodeData.m22metadata[labels[i].innerHTML] = inputs[i].value;
		nodeData.SCRIPT_TXT += " " + inputs[i].value;
		switch(inputs[i].type)
		{
			case 'checkbox':
				nodeData.m22metadata[labels[i].innerHTML] = inputs[i].checked;
				nodeData.SCRIPT_TXT += " " + inputs[i].checked;
				break;
			default:
				nodeData.m22metadata[labels[i].innerHTML] = inputs[i].value;
				nodeData.SCRIPT_TXT += " " + inputs[i].value;
				break;
		}
	}

	switch(selectedFunction)
{'fraction_non_alphanumeric': 0.1563237774030354, 'fraction_numerical': 0.003372681281618887, 'mean_word_length': 4.907370517928287, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 29, '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': '2716798', 'n_tokens_mistral': 2109, 'n_tokens_neox': 1907, 'n_words': 331}