<commit_before>function formatCurrency(amount) {
	var temp = amount.toFixed(2);
	temp.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
	return '$' + temp;
}

function debounce(fn, delay) {
	var timer = null;
	return function () {
		var context = this, args = arguments;
		clearTimeout(timer);
		timer = setTimeout(function () {
			fn.apply(context, args);
		}, delay);
	};
}

$(document).ready(function() {
	//when receiving the http code that indicates the user is logged out, redirect to the login page
	$(document).ajaxError(function(event, jqxhr, settings, exception) {
		if (jqxhr.status === 401) {
			window.location.href = 'login.php';
		}
	});

	//add close for all actions
	$('.popup').on('click', '.close', function(event) {
		$('.popup').hide();
		event.preventDefault();
	});
	
	//add
	$('#topControlCenter .controlAdd').click(function(event) {
		$.ajax({
			url: 'ajax.php',
			type: 'POST',
			data: {
				'action': 'add',
				'type': type
			}
		}).done(function(data) {
			$('#defaultPopup > div > div').html(data.html);
			$('#defaultPopup').show();
			
			$('#addBtn').click(function() {
				var ajaxData = $('#defaultPopup input[type!="checkbox"], #defaultPopup select').serializeArray();
				ajaxData.push(
					{'name': 'action', 'value': 'addSave'},
					{'name': 'type', 'value': type}
				);
				$.ajax({
					url: 'ajax.php',
					type: 'POST',
					data: ajaxData
				}).done(function(data) {
					$('#defaultPopup .invalid').removeClass('invalid');
					if (data.status == 'success') {
						//TODO: do something if it doesn't get sent html
						$('#defaultPopup > div > div').html(data.html);
					}
					else {
						$.each(data, function(key, value) {
							if (key != 'status') {
								$('#defaultPopup [name=' + key + ']').addClass('invalid');
								$('#defaultPopup [name=' + key + ']').qtip({
									'content': value,<commit_msg>If adding something brings back html, display it, otherwise reload the page.<commit_after>function formatCurrency(amount) {
	var temp = amount.toFixed(2);
	temp.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
	return '$' + temp;
}

function debounce(fn, delay) {
	var timer = null;
	return function () {
		var context = this, args = arguments;
		clearTimeout(timer);
		timer = setTimeout(function () {
			fn.apply(context, args);
		}, delay);
	};
}

$(document).ready(function() {
	//when receiving the http code that indicates the user is logged out, redirect to the login page
	$(document).ajaxError(function(event, jqxhr, settings, exception) {
		if (jqxhr.status === 401) {
			window.location.href = 'login.php';
		}
	});

	//add close for all actions
	$('.popup').on('click', '.close', function(event) {
		$('.popup').hide();
		event.preventDefault();
	});
	
	//add
	$('#topControlCenter .controlAdd').click(function(event) {
		$.ajax({
			url: 'ajax.php',
			type: 'POST',
			data: {
				'action': 'add',
				'type': type
			}
		}).done(function(data) {
			$('#defaultPopup > div > div').html(data.html);
			$('#defaultPopup').show();
			
			$('#addBtn').click(function() {
				var ajaxData = $('#defaultPopup input[type!="checkbox"], #defaultPopup select').serializeArray();
				ajaxData.push(
					{'name': 'action', 'value': 'addSave'},
					{'name': 'type', 'value': type}
				);
				$.ajax({
					url: 'ajax.php',
					type: 'POST',
					data: ajaxData
				}).done(function(data) {
					$('#defaultPopup .invalid').removeClass('invalid');
					if (data.status == 'success') {
						if ('html' in data) {
							$('#defaultPopup > div > div').html(data.html);
						}
						else {
							location.reload();
						}
					}
					else {
						$.each(data, function(key, value) {
							if (key != 'status') {
								$('#defaultPopup [name=' + key + ']').addClass('invalid');
								$('#defaultPopup [name=' + key + ']').qtip({
									'content': value,
{'fraction_non_alphanumeric': 0.21089676746611052, 'fraction_numerical': 0.0026068821689259644, 'mean_word_length': 3.239779005524862, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '6762094', 'n_tokens_mistral': 1531, 'n_tokens_neox': 1262, 'n_words': 287}