<commit_before>(function( $ ) {
	$.fn.filterAny = function( options ) {
		
		return this.each(function() {
			var settings = $.extend({
				debounceTimeout: 200,
				highlightedClass: 'filter-highlighted',
				inputSelector: 'input[type=search]',
				itemsContainerSelector: 'ul',
				itemSelector: 'li',
				itemTextSelector: '',
				onSearch: function() {}
			}, options );

			var $this = $(this);
			var $input = $this.find(settings.inputSelector);
			if ( !$input.length ) {
				console.error('filterAny: No input found');
				return;
			}

			var $itemContainers = $this.find(settings.itemsContainerSelector);
			if ( !$itemContainers.length ) {
				console.error('filterAny: No item container found');
				return;
			}

			var containers = [];
			
			$itemContainers.each(function(index, value){
				var $nodes = $(value).find(settings.itemSelector, display);
				var display = $nodes.length > 0 ? $nodes[0].style.display : 'block';
				if ( display === 'none' ) {
					display = 'block'
				}
				cleanNodes($nodes.toArray());
				var textNodes = $nodes.map(function(){
					return settings.itemTextSelector ? this.querySelector(settings.itemTextSelector) : this;
				});
				var strings = textNodes.map(function(){
					return this.textContent;
				});
				containers.push({
					'containerElement': this,
					'strings': strings,
					'nodes': $nodes,
					'textNodes': textNodes,
					'display': display
				});
			});

			var triggerTimer;

			$input.off('input.fa change.fa').on('input.fa change.fa', function(){
				clearTimeout(triggerTimer);
				triggerTimer = setTimeout(search, settings.debounceTimeout);
			}).each(function(){
				$(this.form).off('reset.fa').on('reset.fa', function(){
					// If there are multiple filterAny instances in one form,
					// this handler will only be called for the last one.
					cleanItems()
				});
			});

			if ($input.val()) {
				search();
			}

			function search() {
				var query = $input.val();
				var itemsFound = [];
				cleanItems()
				if ( !query ) {
					settings.onSearch.call(this, $(''));
					return;
				}

				for (var i = containers.length - 1; i >= 0; i--) {
					var container = containers[i];
					var containerElement = container.containerElement;
					var $nodes = $(container.nodes);
					
					// remembering container position in DOM before detaching
					// var containerParent = containerElement.parentNode;
					// var containerIndex = Array.prototype.indexOf.call(containerParent.childNodes, containerElement);
					// if ( containerElement.nextSibling ) {
					// 	var containerNextSibling = containerElement.nextSibling;
					// }
					// containerParent.removeChild(containerElement);

					for (var j = container.strings.length - 1; j >= 0; j--) {
						var node = container.nodes[j];
						var textNode = container.textNodes[j];

						var occurenceIndex = container.strings[j].toLowerCase().indexOf(query.toLowerCase());
						if ( occurenceIndex === -1 ) {
							node.style.display = 'none';
							continue;
						}
						else {
							itemsFound.push(node);
						}

						// highlighting all occurences
						if ( settings.highlightedClass ) {
							while (occurenceIndex != -1) {
								highlightNode(textNode, occurenceIndex, query.length);
								occurenceIndex = container.strings[j].toLowerCase().indexOf(query.toLowerCase(), occurenceIndex + 1);
							}
						}
					};
					//appending container back to it's origin
					// if ( containerNextSibling ) {
					// 	containerParent.insertBefore(containerElement, containerNextSibling);
					// }
					// else {
					// 	containerParent.appendChild(containerElement)
					// }
				};

				settings.onSearch.call(this, $(itemsFound));
			}

			function cleanItems() {
				for (var i = containers.length - 1; i >= 0; i--) {
					var container = containers[i];
					cleanNodes(container.nodes, container.display);
				};
			}

			function cleanNodes(nodes, display, callback) {
				for (var i = nodes.length - 1; i >= 0; i--) {
					var node = nodes[i];
					node.style.display = display;
					var previouslyHighlighted = node.querySelectorAll('.' + settings.highlightedClass);
					if ( !previouslyHighlighted.length ) {
						continue;
					}
					for (var j = previouslyHighlighted.length - 1; j >= 0; j--) {
						var el = previouslyHighlighted[j];
						el.parentNode.replaceChild(el.childNodes[0], el);	//unwrapping
					};
					node.normalize();	//concat textNodes
				};
			}

			function findTextNode(node) {
				var children = node.childNodes,
					child = null,
					textNode = null;
				for (var i = 0; i < children.length; i++) {
					child = children[i];
					if ( isTextNode(child) ) {
						return child;
					}
					else {
						textNode = findTextNode(child);
						if ( textNode ) {
							return textNode;
						}
					}<commit_msg>fixed: showing items<commit_after>(function( $ ) {
	$.fn.filterAny = function( options ) {
		
		return this.each(function() {
			var settings = $.extend({
				debounceTimeout: 200,
				highlightedClass: 'filter-highlighted',
				inputSelector: 'input[type=search]',
				itemsContainerSelector: 'ul',
				itemSelector: 'li',
				itemTextSelector: '',
				onSearch: function() {}
			}, options );

			var $this = $(this);
			var $input = $this.find(settings.inputSelector);
			if ( !$input.length ) {
				console.error('filterAny: No input found');
				return;
			}

			var $itemContainers = $this.find(settings.itemsContainerSelector);
			if ( !$itemContainers.length ) {
				console.error('filterAny: No item container found');
				return;
			}

			var containers = [];
			
			$itemContainers.each(function(index, value){
				var $nodes = $(value).find(settings.itemSelector);

				cleanNodes($nodes.toArray());
				var textNodes = $nodes.map(function(){
					return settings.itemTextSelector ? this.querySelector(settings.itemTextSelector) : this;
				});
				var strings = textNodes.map(function(){
					return this.textContent;
				});
				containers.push({
					'containerElement': this,
					'strings': strings,
					'nodes': $nodes,
					'textNodes': textNodes
				});
			});

			var triggerTimer;

			$input.off('input.fa change.fa').on('input.fa change.fa', function(){
				clearTimeout(triggerTimer);
				triggerTimer = setTimeout(search, settings.debounceTimeout);
			}).each(function(){
				$(this.form).off('reset.fa').on('reset.fa', function(){
					// If there are multiple filterAny instances in one form,
					// this handler will only be called for the last one.
					cleanItems()
				});
			});

			if ($input.val()) {
				search();
			}

			function search() {
				var query = $input.val();
				var itemsFound = [];
				cleanItems()
				if ( !query ) {
					settings.onSearch.call(this, $(''));
					return;
				}

				for (var i = containers.length - 1; i >= 0; i--) {
					var container = containers[i];
					var containerElement = container.containerElement;
					var $nodes = $(container.nodes);
					
					// remembering container position in DOM before detaching
					// var containerParent = containerElement.parentNode;
					// var containerIndex = Array.prototype.indexOf.call(containerParent.childNodes, containerElement);
					// if ( containerElement.nextSibling ) {
					// 	var containerNextSibling = containerElement.nextSibling;
					// }
					// containerParent.removeChild(containerElement);

					for (var j = container.strings.length - 1; j >= 0; j--) {
						var node = container.nodes[j];
						var textNode = container.textNodes[j];

						var occurenceIndex = container.strings[j].toLowerCase().indexOf(query.toLowerCase());
						if ( occurenceIndex === -1 ) {
							node.style.display = 'none';
							continue;
						}
						else {
							itemsFound.push(node);
						}

						// highlighting all occurences
						if ( settings.highlightedClass ) {
							while (occurenceIndex != -1) {
								highlightNode(textNode, occurenceIndex, query.length);
								occurenceIndex = container.strings[j].toLowerCase().indexOf(query.toLowerCase(), occurenceIndex + 1);
							}
						}
					};
					//appending container back to it's origin
					// if ( containerNextSibling ) {
					// 	containerParent.insertBefore(containerElement, containerNextSibling);
					// }
					// else {
					// 	containerParent.appendChild(containerElement)
					// }
				};

				settings.onSearch.call(this, $(itemsFound));
			}

			function cleanItems() {
				for (var i = containers.length - 1; i >= 0; i--) {
					var container = containers[i];
					cleanNodes(container.nodes);
				};
			}

			function cleanNodes(nodes, callback) {
				for (var i = nodes.length - 1; i >= 0; i--) {
					var node = nodes[i];
					node.style.display = '';
					var previouslyHighlighted = node.querySelectorAll('.' + settings.highlightedClass);
					if ( !previouslyHighlighted.length ) {
						continue;
					}
					for (var j = previouslyHighlighted.length - 1; j >= 0; j--) {
						var el = previouslyHighlighted[j];
						el.parentNode.replaceChild(el.childNodes[0], el);	//unwrapping
					};
					node.normalize();	//concat textNodes
				};
			}

			function findTextNode(node) {
				var children = node.childNodes,
					child = null,
					textNode = null;
				for (var i = 0; i < children.length; i++) {
					child = children[i];
					if ( isTextNode(child) ) {
						return child;
					}
					else {
						textNode = findTextNode(child);
						if ( textNode ) {
							return textNode;
						}
					}
{'fraction_non_alphanumeric': 0.1425841384435715, 'fraction_numerical': 0.00403439855610999, 'mean_word_length': 2.6653696498054473, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, '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': '4504649', 'n_tokens_mistral': 3840, 'n_tokens_neox': 2788, 'n_words': 613}