<commit_before>/*jslint devel:true, node:true, nomen:true */
/*global SVG, svgNodeUI */
// depends: editor.js

(function (editor) {
	"use strict";
	var nui, // node ui
		nodeListTable = {},
		systemNodeListTable = {},
		instance_no = 1,
		edit_view = {},
		popupNodeList = null;
	
	function $(id) {
		return document.getElementById(id);
	}

	function clone(obj) {
		return JSON.parse(JSON.stringify(obj));
	}
	
	function makeItemNode(name, text, top) {
		var itemNode = document.createElement('div'),
			nameNode = document.createElement('div'),
			textNode = document.createElement('div');

		itemNode.classList.add('nodePropertyRow');
		nameNode.innerHTML = name;
		textNode.innerHTML = text;
		nameNode.classList.add('nodePropertyName');
		textNode.classList.add('nodePropertyConst');
		if (top) {
			nameNode.classList.add('nodePropertyTop');
			textNode.classList.add('nodePropertyTop');
		}
		itemNode.appendChild(nameNode);
		itemNode.appendChild(textNode);
		return itemNode;
	}
	
	function makeItemTextNode(name, text, node, type) {
		var itemNode = document.createElement('div'),
			nameNode = document.createElement('div'),
			textNode = document.createElement('input');
		if (type) {
			textNode.setAttribute('type', type);
		} else {
			textNode.setAttribute('type', 'text');
		}
		itemNode.classList.add('nodePropertyRow');
		nameNode.innerHTML = '[' + name + ']';
		textNode.value = text;
		nameNode.classList.add('nodePropertyName');
		textNode.classList.add('nodePropertyText');
		itemNode.appendChild(nameNode);
		itemNode.appendChild(textNode);
		
		textNode.addEventListener('keyup', (function (nodeData, txt) {
			return function (e) {
				nodeData.value = txt.value;
			};
		}(node, textNode)));
		return itemNode;
	}
	
	function makeTargetMachineNode(name, value, node, type) {
		if (!node.target_machine_list) {
			console.log(node);
			return;
		}
		var itemNode = document.createElement('div'),
			itemNode2 = document.createElement('div'),
			nameNode = document.createElement('div'),
			nameNode2 = document.createElement('div'),
			valueNode = document.createElement('div'),
			selectElem = document.createElement('select'),
			textNode = document.createElement('input'),
			optionElem,
			target,
			targets,
			initialIndex = 0,
			i;

		itemNode.classList.add('nodePropertyRow');
		itemNode2.classList.add('nodePropertyRow');
		
		nameNode.innerHTML = name;
		nameNode.classList.add('nodePropertyName');
		itemNode.appendChild(nameNode);
		nameNode2.classList.add('nodePropertyName');
		itemNode2.appendChild(nameNode2);
		
		valueNode.className = "nodePropertyConst";
		itemNode.appendChild(valueNode);
		textNode.className = "nodePropertyText";
		textNode.type = "password";
		itemNode2.appendChild(textNode);
		
		targets = node.target_machine_list.hpcpf.targets;
		selectElem.className = "nodePropertyTargetMachine";
		for (i = 0; i < targets.length; i = i + 1) {
			target = targets[i];
			optionElem = document.createElement('option');
			optionElem.innerHTML = target.name_hr;
			selectElem.appendChild(optionElem);
			
			if (node.value && node.value.hasOwnProperty('name_hr')) {
				if (node.value.name_hr === target.name_hr) {
					initialIndex = i;
				}
			}
		}
		
		selectElem.options[initialIndex].selected = "true";
		node.value = targets[initialIndex];
		console.log(node);
		
		selectElem.onchange = (function (nodeData, targets, textNode) {
			return function (e) {
				nodeData.value = targets[this.selectedIndex];
				
				if (nodeData.value.hasOwnProperty('password')) {
					textNode.value = nodeData.value.password;
				}
				if (nodeData.value.hasOwnProperty('passphrase')) {
					textNode.value = nodeData.value.passphrase;
				}
			};
		}(node, targets, textNode));
		valueNode.appendChild(selectElem);
		
		// password/passphrase box
		textNode.addEventListener('keyup', (function (nodeData, txt) {
			return function (e) {
				if (textNode.mode === 'password') {
					nodeData.value.password = txt.value;
				} else {
					nodeData.value.passphrase = txt.value;
				}
			};
		}(node, textNode)));
		
		if (node.value.hasOwnProperty('password')) {
			nameNode2.innerHTML = "pass";
			textNode.value = node.value.password;
			textNode.mode = 'password';
			console.log("password", node);
			return [itemNode, itemNode2];
		} else {
			nameNode2.innerHTML = "pass";
			if (node.value.hasOwnProperty('passphrase')) {
				textNode.value = node.value.passphrase;
				textNode.mode = 'passphrase';
			}
			console.log("passphrase", node);
			return [itemNode, itemNode2];
		}
	}

	function addNode(nodename, nodename_hr, nx, ny, canErase) {
		var node = nodeListTable[nodename],
			instNode,
			nodeData;
		if (!node) {
			return;<commit_msg>rename vars<commit_after>/*jslint devel:true, node:true, nomen:true */
/*global SVG, svgNodeUI */
// depends: editor.js

(function (editor) {
	"use strict";
	var nui, // node ui
		nodeListTable = {},
		systemNodeListTable = {},
		instance_no = 1,
		edit_view = {},
		popupNodeList = null;
	
	function $(id) {
		return document.getElementById(id);
	}

	function clone(obj) {
		return JSON.parse(JSON.stringify(obj));
	}
	
	function makeItemNode(name, text, top) {
		var itemRow = document.createElement('div'),
			nameProp = document.createElement('div'),
			textProp = document.createElement('div');

		itemRow.classList.add('nodePropertyRow');
		nameProp.innerHTML = name;
		textProp.innerHTML = text;
		nameProp.classList.add('nodePropertyName');
		textProp.classList.add('nodePropertyConst');
		if (top) {
			nameProp.classList.add('nodePropertyTop');
			textProp.classList.add('nodePropertyTop');
		}
		itemRow.appendChild(nameProp);
		itemRow.appendChild(textProp);
		return itemRow;
	}
	
	function makeItemTextNode(name, text, node, type) {
		var itemRow = document.createElement('div'),
			nameProp = document.createElement('div'),
			textProp = document.createElement('input');
		if (type) {
			textProp.setAttribute('type', type);
		} else {
			textProp.setAttribute('type', 'text');
		}
		itemRow.classList.add('nodePropertyRow');
		nameProp.innerHTML = '[' + name + ']';
		textProp.value = text;
		nameProp.classList.add('nodePropertyName');
		textProp.classList.add('nodePropertyText');
		itemRow.appendChild(nameProp);
		itemRow.appendChild(textProp);
		
		textProp.addEventListener('keyup', (function (nodeData, txt) {
			return function (e) {
				nodeData.value = txt.value;
			};
		}(node, textProp)));
		return itemRow;
	}
	
	function makeTargetMachineNode(name, value, node, type) {
		if (!node.target_machine_list) {
			console.log(node);
			return;
		}
		var valueRow = document.createElement('div'),
			passRow = document.createElement('div'),
			sshkeyRow = document.createElement('div'),
			nameProp = document.createElement('div'),
			nameProp2 = document.createElement('div'),
			nameProp3 = document.createElement('div'),
			valueProp = document.createElement('div'),
			selectElem = document.createElement('select'),
			passProp = document.createElement('input'),
			keyProp = document.createElement('input'),
			optionElem,
			target,
			targets,
			initialIndex = 0,
			i;

		valueRow.classList.add('nodePropertyRow');
		passRow.classList.add('nodePropertyRow');
		sshkeyRow.classList.add('nodePropertyRow');
		
		nameProp.innerHTML = name;
		nameProp.classList.add('nodePropertyName');
		valueRow.appendChild(nameProp);
		nameProp2.classList.add('nodePropertyName');
		passRow.appendChild(nameProp2);
		nameProp3.classList.add('nodePropertyName');
		nameProp3.innerHTML = "key";
		sshkeyRow.appendChild(nameProp3);
		
		valueProp.className = "nodePropertyConst";
		valueRow.appendChild(valueProp);
		passProp.className = "nodePropertyText";
		passProp.type = "password";
		passRow.appendChild(passProp);
		keyProp.className = "nodePropertyText";
		sshkeyRow.appendChild(keyProp);
		
		targets = node.target_machine_list.hpcpf.targets;
		selectElem.className = "nodePropertyTargetMachine";
		for (i = 0; i < targets.length; i = i + 1) {
			target = targets[i];
			optionElem = document.createElement('option');
			optionElem.innerHTML = target.name_hr;
			selectElem.appendChild(optionElem);
			
			if (node.value && node.value.hasOwnProperty('name_hr')) {
				if (node.value.name_hr === target.name_hr) {
					initialIndex = i;
				}
			}
		}
		
		selectElem.options[initialIndex].selected = "true";
		node.value = targets[initialIndex];
		console.log(node);
		
		selectElem.onchange = (function (nodeData, targets, passProp, keyProp, keyNode) {
			return function (e) {
				nodeData.value = targets[this.selectedIndex];
				passProp.value = "";
				keyProp.value = "";
				keyNode.style.display = "table-row";
				if (nodeData.value.hasOwnProperty('password')) {
					passProp.value = nodeData.value.password;
					keyNode.style.display = "none";
				}
				if (nodeData.value.hasOwnProperty('passphrase')) {
					passProp.value = nodeData.value.passphrase;
				}
				if (nodeData.value.hasOwnProperty('sshkey')) {
					keyProp.value = nodeData.value.sshkey;
				}
			};
		}(node, targets, passProp, keyProp, sshkeyRow));
		valueProp.appendChild(selectElem);
		
		// password/passphrase box
		passProp.addEventListener('keyup', (function (nodeData, prop) {
			return function (e) {
				if (passProp.mode === 'password') {
					nodeData.value.password = prop.value;
				} else {
					nodeData.value.passphrase = prop.value;
				}
			};
		}(node, passProp)));
		// key box
		keyProp.addEventListener('keyup', (function (nodeData, prop) {
			return function (e) {
				if (passProp.mode === 'passphrase') {
					nodeData.value.sshkey = prop.value;
				}
			};
		}(node, keyProp)));
		
		if (node.value.hasOwnProperty('password')) {
			nameProp2.innerHTML = "pass";
			passProp.value = node.value.password;
			passProp.mode = 'password';
			sshkeyRow.style.display = "none";
			return [valueRow, sshkeyRow, passRow];
		} else {
			nameProp2.innerHTML = "pass";
			if (node.value.hasOwnProperty('passphrase')) {
				passProp.value = node.value.passphrase;
				passProp.mode = 'passphrase';
			}
			if (node.value.hasOwnProperty('sshkey')) {
				keyProp.value = node.value.sshkey;
			}
			sshkeyRow.style.display = "table-row";
			return [valueRow, sshkeyRow, passRow];
		}
	}

	function addNode(nodename, nodename_hr, nx, ny, canErase) {
		var node = nodeListTable[nodename],
			instNode,
			nodeData;
		if (!node) {
			return;
{'fraction_non_alphanumeric': 0.14670919106987532, 'fraction_numerical': 0.0027060983860056056, 'mean_word_length': 4.117705242334322, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1973354', 'n_tokens_mistral': 3835, 'n_tokens_neox': 3275, 'n_words': 568}