<commit_before>function sendSampleRequest(type, apiName) {

	var dict = {};

	$(".sample-param-" + apiName).each(function(i, element) {
		var key = element.id;
		var value = element.value;
		dict[key] = value;
	});

	var url = $("#sample-url-" + apiName)[0].value;

	$.ajax({
		url: "/api" + url,
		dataType: "json",
		data: dict,
		type: type.toUpperCase(),
		success: displaySuccess,
		error: displayError
	});

	function displaySuccess(data) {
		$("#sample-response-" + apiName).show();
		$("#sample-response-json-" + apiName).html(JSON.stringify(data, null, 4));
		refreshScrollSpy();
	};

	function displayError(jqXHR, textStatus, errorThrown) {
		$("#sample-response-" + apiName).show();
		$("#sample-response-json-" + apiName).html(jqXHR.status + " Error: " + errorThrown);
		refreshScrollSpy();
	};
};

function clearSampleRequest(apiName) {
	$("#sample-response-json-" + apiName).html("");
	$("#sample-response-" + apiName).hide();

	$(".sample-param-" + apiName).each(function(i, element) {
		element.value = "";
	});

	refreshScrollSpy();
};

function refreshScrollSpy() {
  	$('[data-spy="scroll"]').each(function () {
  		$(this).scrollspy('refresh');
	}); 
};<commit_msg>Improved sample request clearing function, added better commenting.<commit_after>function sendSampleRequest(type, apiName) {
	// create JSON dictionary of parameters
	var dict = {};
	$(".sample-param-" + apiName).each(function(i, element) {
		var key = element.id;
		var value = element.value;
		dict[key] = value;
	});

	// grab user-inputted URL
	var url = $("#sample-url-" + apiName)[0].value;

	// send AJAX request, catch success or error callback
	$.ajax({
		url: "/api" + url,
		dataType: "json",
		data: dict,
		type: type.toUpperCase(),
		success: displaySuccess,
		error: displayError
	});

	function displaySuccess(data) {
		$("#sample-response-" + apiName).show();
		$("#sample-response-json-" + apiName).html(JSON.stringify(data, null, 4));
		refreshScrollSpy();
	};

	function displayError(jqXHR, textStatus, errorThrown) {
		$("#sample-response-" + apiName).show();
		$("#sample-response-json-" + apiName).html(jqXHR.status + " Error: " + errorThrown);
		refreshScrollSpy();
	};
};

function clearSampleRequest(apiName) {
	// hide sample response
	$("#sample-response-json-" + apiName).html("");
	$("#sample-response-" + apiName).hide();

	// reset value of parameters
	$(".sample-param-" + apiName).each(function(i, element) {
		element.value = "";
	});

	// retore default URL
	var sampleURLelement = $("#sample-url-" + apiName)[0];
	sampleURLelement.value = sampleURLelement.defaultValue;

	refreshScrollSpy();
};

function refreshScrollSpy() {
  	$('[data-spy="scroll"]').each(function () {
  		$(this).scrollspy('refresh');
	}); 
};
{'fraction_non_alphanumeric': 0.20058458165875045, 'fraction_numerical': 0.001826817683595177, 'mean_word_length': 4.389763779527559, 'pattern_counts': {'":': 0, '<': 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': '2217588', 'n_tokens_mistral': 981, 'n_tokens_neox': 919, 'n_words': 177}