<commit_before><!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title>TEST - jQuery Ajax Retry</title>
	<style type="text/css">
		table {border:none;}
		th {text-align:right;}
	</style>
</head>
<body>
	<table border="0" cellpadding="0" cellspacing="0">
		<tr>
			<th><label for="attempts">Attempts:</label></th>
			<td><input type="text" id="attempts" value="" /></td>
		</tr>
		<tr>
			<th><label for="cutoff">Cutoff:</label></th>
			<td><input type="text" id="cutoff" value="" /></td>
		</tr>
		<tr>
			<th><label for="slot_time">Slot Time:</label></th>
			<td><input type="text" id="slot_time" value="" /></td>
		</tr>
		<tr>
			<td colspan="2"><input type="button" id="run" value="Run" /></td>
		</tr>
	</table>

	<div id="page"></div>

	<script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
	<script src="../src/jquery.ajaxretry.js"></script>
	<script>
		(function($) {
			// Backoff tick callback
			function on_tick(backoff_info) {
				var count = backoff_info.ticks,
					minutes = Math.floor(count / 60),
					seconds = count % 60,
					display = seconds + '秒';

				if (0 < minutes) {
					display = [minutes, '分', display].join('');
				}

				$('#page').html([
					'<div>',
						backoff_info.attempts, '回中',
						backoff_info.failures, '回失敗していますが、',
						display, '後にリトライします',
						'（slot_time:', backoff_info.slot_time, '）',
					'</div>'
				].join(''));
			}

			// Error handler
			function on_error() {
				$('#page').html("<div>OnError</div>");
			}

			// Success handler
			function on_success(data) {
				$('#page').html("<div>OnSuccess<br />" + data + "</div>");
			}

			// Set-up
			$(document).ready(function(){
				var retry_defaults = $.ajaxRetrySetup({
					attempts: 30,
					cutoff: 7,
					slot_time: 100,
				});

				$('#attempts').val(retry_defaults.attempts);
				$('#cutoff').val(retry_defaults.cutoff);
				$('#slot_time').val(retry_defaults.slot_time);

				$('#run').click(function(){
					var retry_opts = {
							attempts: $('#attempts').val(),	// Attempts after which to give up
							cutoff: $('#cutoff').val(),	// Attempts after which to stop exponentiation
							tick: on_tick,	// Tick callback
							slot_time: $('#slot_time').val()	// Slot time (duration between ticks)
						};
					$.ajax({
						url: 'this/file/does/not/exist',
						retry: retry_opts,
						error: on_error,
						success: on_success,
						async: true,
						cache: false
					});
				});
			});
		})(jQuery);
	</script>
<!-- vim: set ts=4 sw=4 sts=4 noet :-->
</body>
</html>
<commit_msg>Revamp tests (add more options)<commit_after><!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title>TEST - jQuery Ajax Retry</title>
	<style type="text/css">
		table {border:none;}
		th {text-align:right;}
		td {text-align:center;}
		#ajax, #ajax-vals, #ajaxRetrySetup {width:100%;}
	</style>
</head>
<body>
	<table border="0" cellpadding="0" cellspacing="0">
		<tr>
			<th><label for="attempts">Attempts:</label></th>
			<td><input type="text" id="attempts" value="" /></td>
		</tr>
		<tr>
			<th><label for="cutoff">Cutoff:</label></th>
			<td><input type="text" id="cutoff" value="" /></td>
		</tr>
		<tr>
			<th><label for="slot_time">Slot Time:</label></th>
			<td><input type="text" id="slot_time" value="" /></td>
		</tr>
		<tr>
			<td><input type="button" id="ajax" value="$.ajax()" /></td>
			<td><input type="button" id="ajax-vals" value="$.ajax({})" /></td>
		</tr>
		<tr>
			<td colspan="2"><input type="button" id="ajaxRetrySetup" value="$.ajaxRetrySetup()" /></td>
		</tr>
	</table>

	<div id="page"></div>

	<script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
	<script src="../src/jquery.ajaxretry.js"></script>
	<script>
		(function($) {
			// Backoff tick callback
			function on_tick(backoff_info) {
				var count = backoff_info.ticks,
					minutes = Math.floor(count / 60),
					seconds = count % 60,
					display = seconds + '秒';

				if (0 < minutes) {
					display = [minutes, '分', display].join('');
				}

				$('#page').html([
					'<div>',
						backoff_info.attempts, '回中',
						backoff_info.failures, '回失敗していますが、',
						display, '後にリトライします',
						'（slot_time:', backoff_info.slot_time, '）',
					'</div>'
				].join(''));
			}

			// Error handler
			function on_error() {
				$('#page').html("<div>OnError</div>");
				enableGui(true);
			}

			// Success handler
			function on_success(data) {
				$('#page').html("<div>OnSuccess<br />" + data + "</div>");
				enableGui(true);
			}

			// Complete handler
			function on_complete(xhr, status) {
				console.log(['OnComplete -- "',status,'"'].join(''));
			}

			var elmIds = [
					'#ajax',
					'#ajax-vals',
					'#ajaxRetrySetup',
					'#attempts',
					'#cutoff',
					'#slot_time'
				].join(', ');

			function enableGui(enable){
				if (!enable) {
					$(elmIds).attr('disabled','disabled');
				}
				else {
					$(elmIds).removeAttr('disabled');
				}
			}

			// Set-up
			$(document).ready(function(){
				var def_opts = {
						attempts: 8,
						cutoff: 5,
						slot_time: 100,
					},
					ajaxSettings = {
						url: 'this/file/does/not/exist',
						error: on_error,
						success: on_success,
						complete: on_complete,
						async: true,
						cache: false
					};

				$('#attempts').val(def_opts.attempts);
				$('#cutoff').val(def_opts.cutoff);
				$('#slot_time').val(def_opts.slot_time);

				function getRetryOpts() {
					return {
						attempts: $('#attempts').val(),	// Attempts after which to give up
						cutoff: $('#cutoff').val(),	// Attempts after which to stop exponentiation
						slot_time: $('#slot_time').val()	// Slot time (duration between ticks)
					};
				}

				function initiateAjax(opts) {
					$.ajax($.extend(true, {}, ajaxSettings, {retry: opts}));
				}

				$('#ajax').click(function(){
					enableGui(false);
					initiateAjax($.extend(true, {}, $.ajaxRetrySettings, {tick: on_tick}));
				});

				$('#ajax-vals').click(function(){
					enableGui(false);
					initiateAjax($.extend(true, getRetryOpts(), {tick: on_tick}));
				});

				$('#ajaxRetrySetup').click(function(){
					$.ajaxRetrySetup(getRetryOpts());
				});
			});
		})(jQuery);
	</script>
<!-- vim: set ts=4 sw=4 sts=4 noet :-->
</body>
</html>

{'fraction_non_alphanumeric': 0.22207917605407146, 'fraction_numerical': 0.007402639201802382, 'mean_word_length': 3.0045103092783507, 'pattern_counts': {'":': 0, '<': 137, '<?xml version=': 0, '>': 135, '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': '6223549', 'n_tokens_mistral': 2881, 'n_tokens_neox': 2255, 'n_words': 428}