<commit_before>function jsonTree(jsonURL, selector) {

	var element = document.querySelector(selector);
	if(!element) {
		console.log('jsonTree element not found!');
	}

	element.classList.add('jsonTree');
	var request = new XMLHttpRequest();
	request.open("GET", jsonURL, true);
	request.send();
	request.addEventListener('load', function() {
		var parsed = JSON.parse(request.responseText);
		element.innerHTML = json2html(parsed);
		top = document.querySelectorAll('#top');
		top.addEventListener('click', function(e) {
			e.preventDefault();
			if(e.target && e.target.nodeName == "LI") {
				if(toArray(e.target.childNodes).length > 1) {
					toggleClass(e.target, 'selected');
				}
			}
		});
		var liParents = toArray(document.querySelectorAll(selector + ' li'));
		liParents.forEach(function(ele, i, a){
			var filter = toArray(ele.children).filter(function(el) { return el.tagName.toLowerCase() == 'ul'; });
				if(filter.length > 0) { //its a parent!
					if (ele.classList) {
						ele.classList.add('parent');
					}
					else {
						ele.className += ' ' + 'parent';
					}
					if(ele.classList.contains('parent')) {
						ele.style.cursor = 'pointer';
					}
				} else {
					ele.style.cursor = 'auto';
				}
			});
		var ulParents = toArray(document.querySelectorAll(selector + ' ul'));
		ulParents.forEach(function(ele, i, a){
			var filter = toArray(ele.children).filter(function(el) { return el.tagName.toLowerCase() == 'li'; });
				if(filter.length > 0) { //its a parent!
					if (ele.classList) {
						ele.classList.add('parent');
					}
					else {
						ele.className += ' ' + 'parent';
					}
					if(ele.classList.contains('parent')) {
						ele.style.cursor = 'pointer';
					}
				} else {
					ele.style.cursor = 'auto';
				}
			});
	});
}

function toArray(o) {
	return Array.prototype.slice.call(o);
}
<commit_msg>refactored children/parent class application<commit_after>function jsonTree(jsonURL, selector) {

	var element = document.querySelector(selector);
	if(!element) {
		console.log('jsonTree element not found!');
	}

	element.classList.add('jsonTree');
	var request = new XMLHttpRequest();
	request.open("GET", jsonURL, true);
	request.send();
	request.addEventListener('load', function() {
		var parsed = JSON.parse(request.responseText);
		element.innerHTML = json2html(parsed);
		top = document.querySelectorAll('#top');
		top.addEventListener('click', function(e) {
			e.preventDefault();
			if(e.target && e.target.nodeName == "LI") {
				if(toArray(e.target.childNodes).length > 1) {
					toggleClass(e.target, 'selected');
				}
			}
		});
		applyParent(selector, 'li', 'ul');
		applyParent(selector, 'ul', 'li');
	});
}

function applyParent(selector, parent, child) {
	var parents = toArray(document.querySelectorAll(selector + ' ' + parent));
	parents.forEach(function(ele, i, a){
		var filter = toArray(ele.children).filter(function(el) { return el.tagName.toLowerCase() == child; });
			if(filter.length > 0) { //its a parent!
				if (ele.classList) {
					ele.classList.add('parent');
				}
				else {
					ele.className += ' ' + 'parent';
				}
				if(ele.classList.contains('parent')) {
					ele.style.cursor = 'pointer';
				}
			} else {
				ele.style.cursor = 'auto';
			}
		});
}

function toArray(o) {
	return Array.prototype.slice.call(o);
}

{'fraction_non_alphanumeric': 0.1756348246674728, 'fraction_numerical': 0.002116082224909311, 'mean_word_length': 3.570441988950276, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '2534012', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1091, 'n_words': 189}