<commit_before>
var Admin = {

	/**
	 * Initialize global events.
	 */
	initialize: function() {
		$('.clickable tbody tr').click(function(e) {
			var target = $(e.target),
				tag = target.prop('tagName').toLowerCase();

			if (tag === 'a' || tag === 'input') {
				return;
			}

			var id = $(this).find('.click-target');

			if (id.length) {
				location.href = id.attr('href');
			}
		});

		$('#check-all').click(function() {
			$('#table').find('input[type="checkbox"]:not(:disabled)').prop('checked', $(this).prop('checked'));
		});

		Admin.nullChecks();
	},

	/**
	 * Initialize type ahead for belongs to input fields.
	 *
	 * @param {String} id
	 * @param {String} url
	 * @param {Object} data
	 */
	typeAhead: function(id, url, data) {
		var sourceMap = {},
			inputTA = $('#' + id + 'TypeAhead'),
			inputNull = $('#' + id + 'Null'),
			inputRaw = $('#' + id);

		inputTA.typeahead({
			items: 15,
			minLength: 1,
			source: function(query, process) {
				data = data || {};
				data.query = query;

				return $.ajax({
					url: url,
					type: 'get',
					data: data,
					dataType: 'json',
					success: function(json) {
						var source = [],
							display;

						$.each(json, function(id, title) {
							// Display ID in front of title
							//display = (id != title) ? id + ' - ' + title : title;
							display = title;

							sourceMap[display] = [id, title];
							source.push(display);
						});

						return process(source);
					}
				});
			},
			updater: function(item) {
				item = sourceMap[item];

				inputRaw.val(item[0]);
				inputNull.prop('checked', false);

				return item[1];
			}
		});

		// Reset raw input if type ahead is cleared
		inputTA.keyup(function() {
			if (!this.value) {
				inputRaw.val('');
				inputNull.prop('checked', true);
			}
		});
	},

	/**
	 * Monitor null input fields and toggle the checkbox depending on the input length.
	 * Does not support date selects.
	 */
	nullChecks: function() {
		$('.controls-null input:checkbox').each(function() {
			var self = $(this),
				related = $('#' + self.attr('id').replace('Null', ''));

			if (related.length) {
				var callback = function() {
					self.prop('checked', !(this.value));
				};

				if (related.prop('tagName').toLowerCase() === 'input') {
					related.keyup(callback);
				} else {
					related.change(callback);
				}
			}
		});
	},
<commit_msg>Allow date selects to reset null checkbox<commit_after>
var Admin = {

	/**
	 * Initialize global events.
	 */
	initialize: function() {
		$('.clickable tbody tr').click(function(e) {
			var target = $(e.target),
				tag = target.prop('tagName').toLowerCase();

			if (tag === 'a' || tag === 'input') {
				return;
			}

			var id = $(this).find('.click-target');

			if (id.length) {
				location.href = id.attr('href');
			}
		});

		$('#check-all').click(function() {
			$('#table').find('input[type="checkbox"]:not(:disabled)').prop('checked', $(this).prop('checked'));
		});

		Admin.nullChecks();
	},

	/**
	 * Initialize type ahead for belongs to input fields.
	 *
	 * @param {String} id
	 * @param {String} url
	 * @param {Object} data
	 */
	typeAhead: function(id, url, data) {
		var sourceMap = {},
			inputTA = $('#' + id + 'TypeAhead'),
			inputNull = $('#' + id + 'Null'),
			inputRaw = $('#' + id);

		inputTA.typeahead({
			items: 15,
			minLength: 1,
			source: function(query, process) {
				data = data || {};
				data.query = query;

				return $.ajax({
					url: url,
					type: 'get',
					data: data,
					dataType: 'json',
					success: function(json) {
						var source = [],
							display;

						$.each(json, function(id, title) {
							// Display ID in front of title
							//display = (id != title) ? id + ' - ' + title : title;
							display = title;

							sourceMap[display] = [id, title];
							source.push(display);
						});

						return process(source);
					}
				});
			},
			updater: function(item) {
				item = sourceMap[item];

				inputRaw.val(item[0]);
				inputNull.prop('checked', false);

				return item[1];
			}
		});

		// Reset raw input if type ahead is cleared
		inputTA.keyup(function() {
			if (!this.value) {
				inputRaw.val('');
				inputNull.prop('checked', true);
			}
		});
	},

	/**
	 * Monitor null input fields and toggle the checkbox depending on the input length.
	 */
	nullChecks: function() {
		$('.controls-null input:checkbox').each(function() {
			var self = $(this),
				related = self.parent().siblings('select, input');

			if (related.length) {
				var callback = function() {
					self.prop('checked', !(this.value));
				};

				if (related.prop('tagName').toLowerCase() === 'input') {
					related.keyup(callback);
				} else {
					related.change(callback);
				}
			}
		});
	},

{'fraction_non_alphanumeric': 0.19523005487547487, 'fraction_numerical': 0.002110595187842972, 'mean_word_length': 2.601063829787234, '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': '7617802', 'n_tokens_mistral': 1998, 'n_tokens_neox': 1541, 'n_words': 356}