{"size": 973, "ext": "js", "max_stars_repo_path": "ui/js/search.js", "max_stars_repo_name": "modethirteen/Usivity", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ui/js/search.js", "max_issues_repo_name": "modethirteen/Usivity", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ui/js/search.js", "max_forks_repo_name": "modethirteen/Usivity", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.6222222222, "max_line_length": 112, "alphanum_fraction": 0.5775950668}
/*
	search.js - conduct application wide search - client side, no server side yet
	
	FUNCTIONS
		- 
		-
*/
$(document).ready(function() {

	/*SEARCH*/
	$(".search input").keyup( function() {
		var q = $(this).val();
		
		// Get Rid of Existing Highlighted Search Terms
		$(".search_highlight").each(function(){
			$(this).replaceWith( $(this).text() ); 
		});
		
		if (q == "") 
		{
			$(".target tbody tr").show();
		}
		else if (q.length >= 3)
		{		
			// Loop through the messages and look for matching search terms
			$(".streams .message_text").each( function() {
				highlight(q,$(this));
			});
			
			$(".contacts .contact_name").each( function() {
				highlight(q,$(this));
			});
		}
	
	});
});

function highlight(q,ele,parent) 
{
	var content = ele.html().replace(new RegExp( '(' + q + ')', 'gi'), '<span class="search_highlight">$1</span>');
	ele.html(content);
	ele.show();
	$(".target tbody tr").hide();
	$(".search_highlight").parents("tbody tr").show();	
}