<commit_before>window.Dashboard = function(sites) {
	var queue = $({});
	
	$.extend(this, {
		sites: function() { return sites; },
		uniqArray: uniqArray
	});
	
	$(function() {
		addLastClassToSelectables();
		
		$(document).keyup(function(e) {
			if (e.keyCode == 27) // esc
				removeSelectablesWithForms();
		});
		
		$('.add').click(add);
		$('.domains').live('keyup', domainKeyUp);
		$('.header > .edit').live('click', edit);
		$('.header > .remove').live('click', remove);
		$('.selectable:not(.new)').live('click', selectableClick);
		$('select.conditions').live('change', testConditionsChange);
		$('#tests .edit a').live('click', testEdit);
		$('#tests .remove a').live('click', testRemove);
		$('.variants').live('keyup', variantKeyUp);
	});
	
	// Events
	
	function add() {
		var filter = $(this).parents('.filter');
		var id = filter.attr('id');
		
		removeSelectablesWithForms();
		
		if (id == 'tests')
			addTest();
		else if (id == 'envs')
			addEnv();
		else
			addOther(filter, id);
		
		return false;
	}
	
	function domainKeyUp() {
		if ($('.domains[value=]').length < 1) {
			$('.dialog .submit').before(
				$('#envs_form_domain_template').tmpl()
			);
			$('.dialog').trigger('resize');
		}
	}
	
	function edit() {
		var filter = $(this).parents('.filter');
		var id = filter.attr('id');
		
		removeSelectablesWithForms();
		
		if (id == 'sites')
			editSite();
		else if (id == 'envs')
			editEnv();
		
		return false;
	}
	
	function remove() {
		if (!confirm('Are you sure?'))
			return false;
		
		var filter = $(this).parents('.filter');
		var id = filter.attr('id');
		
		var data = currentState();
		var selected = $('.selectable.selected', filter);
		var name = selected.text();
		
		$(this).prev().addClass('hide');
		$(this).addClass('hide');
		hideNextAll(filter);
		selected.remove();
		
		if (id == 'sites')
			sites = withoutName(sites, name);
		else {
			var site = byName(sites, $('#sites .selected').text());
			site[id] = withoutName(site[id], name);
		}
		
		queue.queue(function() {
			$.post(
				'/' + id + '.json',
				{ '_method': 'DELETE', name: name },
				function() { queue.dequeue(); },
				'json'
			);
		});
		
		return false;
	}
	
	function selectableClick() {
		var filter = $(this).parents('.filter');
		var id = filter.attr('id');
		
		$(this).toggleClass('selected');
		hideNextAll(filter);
		
		if ($(this).hasClass('selected')) {
			var target = filter.next();
			var target_id = target.attr('id');
			
			var data = currentState();
			var site = data.site;
			var env = data.env;
			var category = data.category;
			
			filter.children('.selected').not(this).click();
			$('.edit, .remove', filter).removeClass('hide');
			target.removeClass('hide');
			
			if (target_id != 'tests') {
				if (target_id && site[target_id]) {
					target.children('.selectable').remove();
					
					$.each(site[target_id], function(i, item) {
						target.append(createSelectable(item.name));
					});
					
					addLastClassToSelectables();
				}
			} else {
				target.children(':not(.header)').remove();
				
				if (category.tests)
					$.each(category.tests, function(i, test) {<commit_msg>Fixing category clicks<commit_after>window.Dashboard = function(sites) {
	var queue = $({});
	
	$.extend(this, {
		sites: function() { return sites; },
		uniqArray: uniqArray
	});
	
	$(function() {
		addLastClassToSelectables();
		
		$(document).keyup(function(e) {
			if (e.keyCode == 27) // esc
				removeSelectablesWithForms();
		});
		
		$('.add').click(add);
		$('.domains').live('keyup', domainKeyUp);
		$('.header > .edit').live('click', edit);
		$('.header > .remove').live('click', remove);
		$('.selectable:not(.new)').live('click', selectableClick);
		$('select.conditions').live('change', testConditionsChange);
		$('#tests .edit a').live('click', testEdit);
		$('#tests .remove a').live('click', testRemove);
		$('.variants').live('keyup', variantKeyUp);
	});
	
	// Events
	
	function add() {
		var filter = $(this).parents('.filter');
		var id = filter.attr('id');
		
		removeSelectablesWithForms();
		
		if (id == 'tests')
			addTest();
		else if (id == 'envs')
			addEnv();
		else
			addOther(filter, id);
		
		return false;
	}
	
	function domainKeyUp() {
		if ($('.domains[value=]').length < 1) {
			$('.dialog .submit').before(
				$('#envs_form_domain_template').tmpl()
			);
			$('.dialog').trigger('resize');
		}
	}
	
	function edit() {
		var filter = $(this).parents('.filter');
		var id = filter.attr('id');
		
		removeSelectablesWithForms();
		
		if (id == 'sites')
			editSite();
		else if (id == 'envs')
			editEnv();
		
		return false;
	}
	
	function remove() {
		if (!confirm('Are you sure?'))
			return false;
		
		var filter = $(this).parents('.filter');
		var id = filter.attr('id');
		
		var data = currentState();
		var selected = $('.selectable.selected', filter);
		var name = selected.text();
		
		$(this).prev().addClass('hide');
		$(this).addClass('hide');
		hideNextAll(filter);
		selected.remove();
		
		if (id == 'sites')
			sites = withoutName(sites, name);
		else {
			var site = byName(sites, $('#sites .selected').text());
			site[id] = withoutName(site[id], name);
		}
		
		queue.queue(function() {
			$.post(
				'/' + id + '.json',
				{ '_method': 'DELETE', name: name },
				function() { queue.dequeue(); },
				'json'
			);
		});
		
		return false;
	}
	
	function selectableClick() {
		var filter = $(this).parents('.filter');
		var id = filter.attr('id');
		
		$(this).toggleClass('selected');
		hideNextAll(filter);
		
		if ($(this).hasClass('selected')) {
			var target = filter.next();
			var target_id = target.attr('id');
			
			filter.children('.selected').not(this).click();
			$('.edit, .remove', filter).removeClass('hide');
			target.removeClass('hide');
			
			var data = currentState();
			var site = data.site;
			var env = data.env;
			var category = data.category;
			
			if (target_id != 'tests') {
				if (target_id && site[target_id]) {
					target.children('.selectable').remove();
					
					$.each(site[target_id], function(i, item) {
						target.append(createSelectable(item.name));
					});
					
					addLastClassToSelectables();
				}
			} else {
				target.children(':not(.header)').remove();
				
				if (category.tests)
					$.each(category.tests, function(i, test) {
{'fraction_non_alphanumeric': 0.21282010497852713, 'fraction_numerical': 0.0009543502465404804, 'mean_word_length': 3.303901437371663, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '1035383', 'n_tokens_mistral': 2545, 'n_tokens_neox': 2033, 'n_words': 412}