<commit_before>(function() {
	var $ = function(id) {return document.getElementById(id)},
		enableHostsElm,
		validateHostsElm,
		validateHost;

	function loadOptions() {
		var validateHosts,
			hostOpt,
			validator = $('validator'),
			collapsed = $('collapse');
	
		//	Load options
		window.addEventListener('load', function() {
			var enableHosts = [],
				validateHosts = [];

			//	TODO: abstract select box population into function
			if (localStorage['enableHosts']) {
				enableHosts = localStorage['enableHosts'].split(' ');
				for (var i = 0; i < enableHosts.length; i++) {
					hostOpt = document.createElement('option');
					hostOpt.textContent = enableHosts[i];
					enableHostsElm.appendChild(hostOpt);
				}
			}

			if (localStorage['validateHosts'] !== undefined) {
				validateHosts = localStorage['validateHosts'].split(' ');
				//	Loop through hosts to populate select box
				for (var j = 0; j < validateHosts.length; j++) {
					hostOpt = document.createElement('option');
					hostOpt.textContent = validateHosts[j];
					validateHostsElm.appendChild(hostOpt);
				}
			}

			if (localStorage['validator'] !== undefined) {
				validator.value = localStorage['validator'];
			}

			if (localStorage['collapseResults'] !== undefined) {
				collapsed.checked = localStorage['collapseResults'];
			}
			else {
				//	Defaults to true
				collapsed.checked = true;
			}
		});
	}

	//	Edit hosts
	function addOptionToSelect(optionText, select) {
		var option = document.createElement('option');

		option.textContent = optionText;
		select.appendChild(option);

		return option;
	}

	function removeOptionsFromSelect(select) {
		var option;

		for (var i = 0; i < select.childNodes.length; i++) {
			option = select.childNodes[i];
			if (option.selected === true) {
				select.removeChild(option);
			}
		}
	}

	//	Save options
	function saveOptions() {
		var enableHosts = [],
			validateHosts = [];

		for (var i = 0; i < enableHostsElm.childNodes.length; i++) {
			enableHosts.push(enableHostsElm.childNodes[i].textContent);
		}

		for (var j = 0; j < validateHostsElm.childNodes.length; j++) {
			validateHosts.push(validateHostsElm.childNodes[j].textContent);
		}

		//	Sort hosts alphabetically
		enableHosts.sort();
		validateHosts.sort();

		localStorage['enableHosts'] = enableHosts.join(' ');
		localStorage['validateHosts'] = validateHosts.join(' ');
		localStorage['validator'] = validator.value;
		localStorage['collapseResults'] = collapse.checked;
	}

	//	DOM Ready
	document.addEventListener('DOMContentLoaded', function() {
		enableHostsElm = $('enableHosts')
		validateHostsElm = $('validateHosts');
		//validateHost = $('validateHost');

		//	Load option values into UI
		loadOptions();

		//	Attach add and remove events for select boxes
		$('enableAdd').addEventListener('click', function() {
			var textArea = $('enableHost');
			addOptionToSelect(textArea.value, enableHostsElm);
			textArea.value = '';
		});

		$('enableRemove').addEventListener('click', function() {
			removeOptionsFromSelect(enableHostsElm);
		});

		$('validateAdd').addEventListener('click', function() {
			var textArea = $('validateHost');
			addOptionToSelect(textArea.value, validateHostsElm);
			textArea.value = '';
		});

		$('validateRemove').addEventListener('click', function() {
			removeOptionsFromSelect(validateHostsElm);
		});

		//	Attach save and apply events
		$('apply').addEventListener('click', function() {
			saveOptions();
		});

		$('optionsForm').addEventListener('submit', function() {
			saveOptions();
			window.close();
			return false;
		});
	});
})();<commit_msg>Host options are now added on enter keypress.<commit_after>(function() {
	var $ = function(id) {return document.getElementById(id)},
		enableHostsElm,
		validateHostsElm,
		validateHost;

	function loadOptions() {
		var validateHosts,
			hostOpt,
			validator = $('validator'),
			collapsed = $('collapse');
	
		//	Load options
		window.addEventListener('load', function() {
			var enableHosts = [],
				validateHosts = [];

			//	TODO: abstract select box population into function
			if (localStorage['enableHosts']) {
				enableHosts = localStorage['enableHosts'].split(' ');
				for (var i = 0; i < enableHosts.length; i++) {
					hostOpt = document.createElement('option');
					hostOpt.textContent = enableHosts[i];
					enableHostsElm.appendChild(hostOpt);
				}
			}

			if (localStorage['validateHosts'] !== undefined) {
				validateHosts = localStorage['validateHosts'].split(' ');
				//	Loop through hosts to populate select box
				for (var j = 0; j < validateHosts.length; j++) {
					hostOpt = document.createElement('option');
					hostOpt.textContent = validateHosts[j];
					validateHostsElm.appendChild(hostOpt);
				}
			}

			if (localStorage['validator'] !== undefined) {
				validator.value = localStorage['validator'];
			}

			if (localStorage['collapseResults'] !== undefined) {
				collapsed.checked = localStorage['collapseResults'];
			}
			else {
				//	Defaults to true
				collapsed.checked = true;
			}
		});
	}

	//	Edit hosts
	function addOptionToSelect(optionText, select) {
		var option = document.createElement('option');

		option.textContent = optionText;
		select.appendChild(option);

		return option;
	}

	function removeOptionsFromSelect(select) {
		var option;

		for (var i = 0; i < select.childNodes.length; i++) {
			option = select.childNodes[i];
			if (option.selected === true) {
				select.removeChild(option);
			}
		}
	}

	//	Save options
	function saveOptions() {
		var enableHosts = [],
			validateHosts = [];

		for (var i = 0; i < enableHostsElm.childNodes.length; i++) {
			enableHosts.push(enableHostsElm.childNodes[i].textContent);
		}

		for (var j = 0; j < validateHostsElm.childNodes.length; j++) {
			validateHosts.push(validateHostsElm.childNodes[j].textContent);
		}

		//	Sort hosts alphabetically
		enableHosts.sort();
		validateHosts.sort();

		localStorage['enableHosts'] = enableHosts.join(' ');
		localStorage['validateHosts'] = validateHosts.join(' ');
		localStorage['validator'] = validator.value;
		localStorage['collapseResults'] = collapse.checked;
	}

	//	DOM Ready
	document.addEventListener('DOMContentLoaded', function() {
		enableHostsElm = $('enableHosts')
		validateHostsElm = $('validateHosts');
		//validateHost = $('validateHost');

		//	Load option values into UI
		loadOptions();

		//	Attach add and remove events for select boxes
		$('enableAdd').addEventListener('click', function() {
			var textArea = $('enableHost');
			if (textArea.value !== '') {
				addOptionToSelect(textArea.value, enableHostsElm);
			}
			textArea.value = '';
		});

		$('enableRemove').addEventListener('click', function() {
			removeOptionsFromSelect(enableHostsElm);
		});

		//	Add host on enter keypress
		$('enableHost').addEventListener('keypress', function(e) {
			if (e.which === 13) {
				//	Cancel submit
				e.preventDefault();
				$('enableAdd').click();
			}
		});

		$('validateAdd').addEventListener('click', function() {
			var textArea = $('validateHost');
			if (textArea.value !== '') {
				addOptionToSelect(textArea.value, validateHostsElm);
			}
			textArea.value = '';
		});

		$('validateRemove').addEventListener('click', function() {
			removeOptionsFromSelect(validateHostsElm);
		});

		//	Add host on enter keypress
		$('validateHost').addEventListener('keypress', function(e) {
			if (e.which === 13) {
				//	Cancel submit
				e.preventDefault();
				$('validateAdd').click();
			}
		});

		//	Attach save and apply events
		$('apply').addEventListener('click', function() {
			saveOptions();
		});

		$('optionsForm').addEventListener('submit', function(e) {
			saveOptions();
			window.close();
			return false;
		});
	});
})();
{'fraction_non_alphanumeric': 0.1569159240604417, 'fraction_numerical': 0.0018080847216841018, 'mean_word_length': 3.9419272495213784, 'pattern_counts': {'":': 0, '<': 13, '<?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': '4589201', 'n_tokens_mistral': 2813, 'n_tokens_neox': 2352, 'n_words': 465}