<commit_before>$(function(){

	function sorting() {
		$(".clevel1 .clist").sortable({handle: ".cmove2", cancel: "", stop: savespec});
		$(".clevel2 .clist").sortable({handle: ".cmove3", cancel: "", stop: savespec});
		$(".clevel3 .clist").sortable({handle: ".cmove4", cancel: "", stop: savespec});
	}
	sorting();
	
	$("body").on("click", ".cadd", function(e){
		/* pressing one of the '+' buttons copies the corresponding proforma structure to just before the button */
		e.preventDefault(); e.stopPropagation();
		var jself = $(this);
		$("#"+jself.attr("proforma")).clone().removeClass("cproforma").
			removeAttr("id").appendTo(jself.prev("ul.clist"));
		savespec();
		sorting();
	});

	$("body").on("click", ".cremove", function(e){
		/* pressing one of the 'X' buttons removes the group of options containing the button */
		e.preventDefault(); e.stopPropagation();
		var jself = $(this);
		jself.closest(".cgroup").remove();
		savespec();
	});

	$("body").on("change", "select", function(e){
		/* some select choices come with further options; the furtheroptions attribute identifies these. 
		   Make visible those and only those (in the same set of options) for this select */
		var jself = $(this);		
		var f = jself.find("option:selected").attr("furtheroptions");
		if (typeof f != "string") { return; }
		var jparent = jself.closest("div");
		jparent.find(".cfurtheroption").not(jself).hide();
		if (f == "") { return; }
		f.split(",").forEach(function(el,idx){ jparent.find("."+el).show(); });		
	});

	$("body").on("change", "select,input[type=text],input[type=checkbox],textarea", function(e){
		/* always keep the current state in storage so we can restore it on revisiting the page */
		savespec();
	});

	$("body").on("click", "a.chelp", function(e){
		/* show the help panel */
		e.preventDefault(); e.stopPropagation();
		$("#ihelpframe").attr({src: $(this).attr("href")}).closest("#ihelp").css({top: $(window).scrollTop()+70, height: $(window).height()-100}).show();
	});

	$("#ihelpclose").click(function(e){
		/* close the help panel */
		e.preventDefault(); e.stopPropagation();
		$("#ihelp").hide();
	});

	function toggleqif() {
		/* qif format has some differences in the options, particularly the field names, which are fixed */
		var qif = $("#ioutputformat").val() == "qif";
		$(".cqif").toggle(qif);
		$(".cnotqif").toggle(! qif);
	}
	
	$("#ioutputformat").change(toggleqif);
	
	$("#ireset").click(function(e){
		e.preventDefault(); e.stopPropagation();
		loadspec("{\"comment\":\"\",\"outputTo\":\"attachment\",\"outputFormat\":\"jsonarray\",\"encoding\":\"auto\",\"headerRows\":0,\"rowCount\":1}");	
	});
	
	function recurse(level, jel){
		/* use the DOM structure to create a corresponding JSON object to send to the API */
		var j = {};
		jel.find(".cinput"+level+":visible").each(function(idx,el){
			var v = $(el).val();
			if (v == "" || ($(el).attr("type") == "checkbox" && ! $(el).is(":checked"))) { return; }
			if ($(el).hasClass("cint")) { v = parseInt(v); }
			j[$(el).attr("name")] = v;
		});
		jel.find(".clevel"+(level+1)).each(function(idx,el){
			var name = $(el).attr("name");
			if (! (name in j)) { j[name] = []; }<commit_msg>Fix problem with initial setting for outputFormat<commit_after>$(function(){

	function sorting() {
		$(".clevel1 .clist").sortable({handle: ".cmove2", cancel: "", stop: savespec});
		$(".clevel2 .clist").sortable({handle: ".cmove3", cancel: "", stop: savespec});
		$(".clevel3 .clist").sortable({handle: ".cmove4", cancel: "", stop: savespec});
	}
	sorting();
	
	$("body").on("click", ".cadd", function(e){
		/* pressing one of the '+' buttons copies the corresponding proforma structure to just before the button */
		e.preventDefault(); e.stopPropagation();
		var jself = $(this);
		$("#"+jself.attr("proforma")).clone().removeClass("cproforma").
			removeAttr("id").appendTo(jself.prev("ul.clist"));
		savespec();
		sorting();
	});

	$("body").on("click", ".cremove", function(e){
		/* pressing one of the 'X' buttons removes the group of options containing the button */
		e.preventDefault(); e.stopPropagation();
		var jself = $(this);
		jself.closest(".cgroup").remove();
		savespec();
	});

	$("body").on("change", "select", function(e){
		/* some select choices come with further options; the furtheroptions attribute identifies these. 
		   Make visible those and only those (in the same set of options) for this select */
		var jself = $(this);		
		var f = jself.find("option:selected").attr("furtheroptions");
		if (typeof f != "string") { return; }
		var jparent = jself.closest("div");
		jparent.find(".cfurtheroption").not(jself).hide();
		if (f == "") { return; }
		f.split(",").forEach(function(el,idx){ jparent.find("."+el).show(); });		
	});

	$("body").on("change", "select,input[type=text],input[type=checkbox],textarea", function(e){
		/* always keep the current state in storage so we can restore it on revisiting the page */
		savespec();
	});

	$("body").on("click", "a.chelp", function(e){
		/* show the help panel */
		e.preventDefault(); e.stopPropagation();
		$("#ihelpframe").attr({src: $(this).attr("href")}).closest("#ihelp").css({top: $(window).scrollTop()+70, height: $(window).height()-100}).show();
	});

	$("#ihelpclose").click(function(e){
		/* close the help panel */
		e.preventDefault(); e.stopPropagation();
		$("#ihelp").hide();
	});

	function toggleqif() {
		/* qif format has some differences in the options, particularly the field names, which are fixed */
		var qif = $("#ioutputformat").val() == "qif";
		$(".cqif").toggle(qif);
		$(".cnotqif").toggle(! qif);
	}
	
	$("#ioutputformat").change(toggleqif);
	
	$("#ireset").click(function(e){
		e.preventDefault(); e.stopPropagation();
		loadspec("{\"comment\":\"\",\"outputTo\":\"attachment\",\"outputFormat\":\"json\",\"encoding\":\"auto\",\"headerRows\":0,\"rowCount\":1}");	
	});
	
	function recurse(level, jel){
		/* use the DOM structure to create a corresponding JSON object to send to the API */
		var j = {};
		jel.find(".cinput"+level+":visible").each(function(idx,el){
			var v = $(el).val();
			if (v == "" || ($(el).attr("type") == "checkbox" && ! $(el).is(":checked"))) { return; }
			if ($(el).hasClass("cint")) { v = parseInt(v); }
			j[$(el).attr("name")] = v;
		});
		jel.find(".clevel"+(level+1)).each(function(idx,el){
			var name = $(el).attr("name");
			if (! (name in j)) { j[name] = []; }
{'fraction_non_alphanumeric': 0.23837118245888803, 'fraction_numerical': 0.004385277995301488, 'mean_word_length': 4.529004329004329, 'pattern_counts': {'":': 16, '<': 3, '<?xml version=': 0, '>': 3, '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': '6215145', 'n_tokens_mistral': 2251, 'n_tokens_neox': 2134, 'n_words': 484}