<commit_before>$(function(){
	var last_query,
	searching,
	timer,
	delay = 300,
	input = $('#wompt_search');
	
	if(window.initialResults){
		last_query = input.val().trim();
		showResults(last_query, window.initialResults);
	}
	
	input.keyup(function(e){
		var query = input.val().trim();
		if(last_query == query && e.which != 13) return;
		scheduleSearch();
		last_query = query;
	})

	function scheduleSearch(){
		clearTimeout(timer);
		timer = setTimeout(function(){
			if(searching) return;
			searching = true;
			var query = input.val().trim();
			$.ajax({
				url: '/rooms/search',
				dataType: 'json',
				success: function(data){
					showResults(query, data)
				},
				complete: function(){
					searching = false
				},
				data: {term: query}
			});
		}, delay)
	}
	
	function showResults(query, data){
		if(!data) return;

		// Sort results by room population
		data.sort(function(a,b){
			return (b.u || 0) - (a.u || 0)
		});

		var results = $('#results'),
		title = $('<h3>'),
		titleText = query && query.length > 0 ?
			(data.length + " Room" + (data.length == 1 ? '' : 's') + " Matching '"+ query +"'")
			:
			"Popular Rooms";
			
		results.empty();
		results.append(
			row(
				td(
					title.text(titleText)
				).attr('colspan', 2)));
		title.append(" - ");
		title.append(
			link('permalink', '/search' + (query ? '/?q=' + query : '')),
			" to this search");

		data.forEach(function(room){
			var a = link(room.n.replace('/', ' / '), '/chat/' + room.n),
			td_count = td(room.u + '', 'count');
			results.append(row(td_count, td(a)));
		});
		
		if(data.length == 0 && query != ''){
			results
			.append(row(
				$('<h4>')<commit_msg>Fix a search page formatting bug<commit_after>$(function(){
	var last_query,
	searching,
	timer,
	delay = 300,
	input = $('#wompt_search');
	
	if(window.initialResults){
		last_query = input.val().trim();
		showResults(last_query, window.initialResults);
	}
	
	input.keyup(function(e){
		var query = input.val().trim();
		if(last_query == query && e.which != 13) return;
		scheduleSearch();
		last_query = query;
	})

	function scheduleSearch(){
		clearTimeout(timer);
		timer = setTimeout(function(){
			if(searching) return;
			searching = true;
			var query = input.val().trim();
			$.ajax({
				url: '/rooms/search',
				dataType: 'json',
				success: function(data){
					showResults(query, data)
				},
				complete: function(){
					searching = false
				},
				data: {term: query}
			});
		}, delay)
	}
	
	function showResults(query, data){
		if(!data) return;

		// Sort results by room population
		data.sort(function(a,b){
			return (b.u || 0) - (a.u || 0)
		});

		var results = $('#results'),
		title = $('<h3>'),
		titleText = query && query.length > 0 ?
			(data.length + " Room" + (data.length == 1 ? '' : 's') + " Matching '"+ query +"'")
			:
			"Popular Rooms";
			
		results.empty();
		results.append(
			row(
				td(
					title.text(titleText)
				).attr('colspan', 2)));
		title.append(" - ");
		title.append(
			link('permalink', '/search' + (query ? '/?q=' + query : '')),
			" to this search");

		data.forEach(function(room){
			var a = link(room.n.replace(/\//g, ' / '), '/chat/' + room.n),
			td_count = td(room.u + '', 'count');
			results.append(row(td_count, td(a)));
		});
		
		if(data.length == 0 && query != ''){
			results
			.append(row(
				$('<h4>')
{'fraction_non_alphanumeric': 0.20668058455114824, 'fraction_numerical': 0.007754249925439905, 'mean_word_length': 3.0556227327690446, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '1330365', 'n_tokens_mistral': 1434, 'n_tokens_neox': 1180, 'n_words': 250}