<commit_before>function save(page_name, key) {
	if(SirTrevor.onBeforeSubmit() == 0) {
		$('.sir-trevor').each(function() {
			trevor = SirTrevor.getInstance($(this).data('trevor-id'));
			$(this).val(trevor.$el.val());
		});

		var formData = $('form').serializeArray();
		formData.push({
			name: "q",
			value: "save"
		});
		formData.push({
			name: "00key",
			value: key
		});
		formData.push({
			name: "00page",
			value: page_name
		});

		$.ajax(getAjaxEndpoint(), {
			type: "POST",
			data: formData,
			beforeSend: function(data) {
				$('.form-status').hide();
				$('.save-button').html('<span class="glyphicon glyphicon-hourglass" aria-hidden="true"></span> Saving...');
				$('.save-button').attr('disabled', 'disabled');
				$('.form-group').removeClass('has-error');
			},
			complete: function(data) {
				$('.save-button').html('<span class="glyphicon glyphicon-save" aria-hidden="true"></span> Save');
				$('.save-button').removeAttr('disabled');
			},
			error: function(data) {
				message = data.responseJSON.message;

				if(data.responseJSON.widgets) {
					message += "\n\n";

					data.responseJSON.widgets.forEach(function(widget) {
						message += widget.reason + "\n";
						$('#grp-'+widget.name).addClass('has-error');
					});
				}

				alert(message);
			},
			success: function(data) {
				if($('#detailsview').length) {
					$('#detailsview').modal('hide');
				}

				$('.form-status').html('<span class="glyphicon glyphicon-ok"></span> Succesfully saved!');
				$('.form-status').fadeIn('fast').delay(5000).fadeOut('slow');

				if ($('#search-results').length) {
					search(page_name); // Reload results
				} else if($('#list-table').length) {
					// Get paginator page
					paginator_page = $('#list-table').attr('data-currentpage');

					refreshList(page_name, paginator_page); // Reload results
				}
			},
			cache: false
		});
	} else {
		alert("There is an error with your submission. Please scroll down and correct the highlighted errors.");
	}
}

function create(page_name) {
	if(SirTrevor.onBeforeSubmit() == 0) {
		$('.sir-trevor').each(function() {
			trevor = SirTrevor.getInstance($(this).data('trevor-id'));
			$(this).val(trevor.$el.val());
		});

		var formData = new FormData($('#new-form')[0]);
		formData.append('q', 'new');
		formData.append('00page', page_name);

		$.ajax(getAjaxEndpoint(), {
			type: "POST",
			data: formData,
			processData: false,
			contentType: false,
			beforeSend: function(data) {
				$('.form-status').hide();
				$('.new-button').html('<span class="glyphicon glyphicon-hourglass" aria-hidden="true"></span> Creating...');
				$('.new-button').attr('disabled', 'disabled');
				$('.form-group').removeClass('has-error');
			},
			complete: function(data) {
				$('.new-button').html('<span class="glyphicon glyphicon-saved" aria-hidden="true"></span> Create');
				$('.new-button').removeAttr('disabled');
			},
			error: function(data) {
				message = data.responseJSON.message;

				if(data.responseJSON.widgets) {
					message += "\n\n";

					data.responseJSON.widgets.forEach(function(widget) {
						message += widget.reason + "\n";
						$('#grp-'+widget.name).addClass('has-error');
					});
				}

				alert(message);
			},
			success: function(data) {
				$('.form-status').html('<span class="glyphicon glyphicon-ok"></span> Succesfully created! ' + data.key);
				$('.form-status').fadeIn('fast').delay(5000).fadeOut('slow');
				$('form').trigger("reset");

				$('.sir-trevor').each(function() {
					trevor = SirTrevor.getInstance($(this).data('trevor-id'));
					trevor.reinitialize();
				});

				$('.select2').val(null).trigger('change');
				$('.image-group .image-key').val(null);
				$('.image-group #current').html('<i>No image selected.</i>');
			},
			cache: false
		});
	} else {
		alert("There is an error with your submission. Please scroll down and correct the highlighted errors.");
	}
}

function runSearch(page_name, paginator_page) {
	var formData = $('#search-form').serializeArray();
	formData.push({
		name: "q",
		value: "search"
	});
	formData.push({
		name: "00page",
		value: page_name
	});
	formData.push({<commit_msg>Scroll to top after creation of new record<commit_after>function save(page_name, key) {
	if(SirTrevor.onBeforeSubmit() == 0) {
		$('.sir-trevor').each(function() {
			trevor = SirTrevor.getInstance($(this).data('trevor-id'));
			$(this).val(trevor.$el.val());
		});

		var formData = $('form').serializeArray();
		formData.push({
			name: "q",
			value: "save"
		});
		formData.push({
			name: "00key",
			value: key
		});
		formData.push({
			name: "00page",
			value: page_name
		});

		$.ajax(getAjaxEndpoint(), {
			type: "POST",
			data: formData,
			beforeSend: function(data) {
				$('.form-status').hide();
				$('.save-button').html('<span class="glyphicon glyphicon-hourglass" aria-hidden="true"></span> Saving...');
				$('.save-button').attr('disabled', 'disabled');
				$('.form-group').removeClass('has-error');
			},
			complete: function(data) {
				$('.save-button').html('<span class="glyphicon glyphicon-save" aria-hidden="true"></span> Save');
				$('.save-button').removeAttr('disabled');
			},
			error: function(data) {
				message = data.responseJSON.message;

				if(data.responseJSON.widgets) {
					message += "\n\n";

					data.responseJSON.widgets.forEach(function(widget) {
						message += widget.reason + "\n";
						$('#grp-'+widget.name).addClass('has-error');
					});
				}

				alert(message);
			},
			success: function(data) {
				if($('#detailsview').length) {
					$('#detailsview').modal('hide');
				}

				$('.form-status').html('<span class="glyphicon glyphicon-ok"></span> Succesfully saved!');
				$('.form-status').fadeIn('fast').delay(5000).fadeOut('slow');

				if ($('#search-results').length) {
					search(page_name); // Reload results
				} else if($('#list-table').length) {
					// Get paginator page
					paginator_page = $('#list-table').attr('data-currentpage');

					refreshList(page_name, paginator_page); // Reload results
				}
			},
			cache: false
		});
	} else {
		alert("There is an error with your submission. Please scroll down and correct the highlighted errors.");
	}
}

function create(page_name) {
	if(SirTrevor.onBeforeSubmit() == 0) {
		$('.sir-trevor').each(function() {
			trevor = SirTrevor.getInstance($(this).data('trevor-id'));
			$(this).val(trevor.$el.val());
		});

		var formData = new FormData($('#new-form')[0]);
		formData.append('q', 'new');
		formData.append('00page', page_name);

		$.ajax(getAjaxEndpoint(), {
			type: "POST",
			data: formData,
			processData: false,
			contentType: false,
			beforeSend: function(data) {
				$('.form-status').hide();
				$('.new-button').html('<span class="glyphicon glyphicon-hourglass" aria-hidden="true"></span> Creating...');
				$('.new-button').attr('disabled', 'disabled');
				$('.form-group').removeClass('has-error');
			},
			complete: function(data) {
				$('.new-button').html('<span class="glyphicon glyphicon-saved" aria-hidden="true"></span> Create');
				$('.new-button').removeAttr('disabled');
			},
			error: function(data) {
				message = data.responseJSON.message;

				if(data.responseJSON.widgets) {
					message += "\n\n";

					data.responseJSON.widgets.forEach(function(widget) {
						message += widget.reason + "\n";
						$('#grp-'+widget.name).addClass('has-error');
					});
				}

				alert(message);
			},
			success: function(data) {
				$('.form-status').html('<span class="glyphicon glyphicon-ok"></span> Succesfully created! ' + data.key);
				$('.form-status').fadeIn('fast').delay(5000).fadeOut('slow');
				$('form').trigger("reset");

				$('.sir-trevor').each(function() {
					trevor = SirTrevor.getInstance($(this).data('trevor-id'));
					trevor.reinitialize();
				});

				$('.select2').val(null).trigger('change');
				$('.image-group .image-key').val(null);
				$('.image-group #current').html('<i>No image selected.</i>');

				$('html, body').animate({
					scrollTop: $("body").offset().top
				}, 500);
			},
			cache: false
		});
	} else {
		alert("There is an error with your submission. Please scroll down and correct the highlighted errors.");
	}
}

function runSearch(page_name, paginator_page) {
	var formData = $('#search-form').serializeArray();
	formData.push({
		name: "q",
		value: "search"
	});
	formData.push({
		name: "00page",
		value: page_name
	});
	formData.push({
{'fraction_non_alphanumeric': 0.22030878859857483, 'fraction_numerical': 0.005106888361045131, 'mean_word_length': 3.6550580431177444, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, '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': '5717900', 'n_tokens_mistral': 3396, 'n_tokens_neox': 2754, 'n_words': 453}