<commit_before>/**
 * Copyright 2013-2014 Academe Computing Ltd
 * Released under the MIT license
 * Author: <NAME> <<EMAIL>>
 * Version: 1.1.0
 */
/**
 * jquery.maxsubmit.js
 *
 * Checks how many parameters a form is going to submit, and
 * gives the user a chance to cancel if it exceeds a set number.
 * PHP5.3+ has limits set by default on the number of POST parameters
 * that will be accepted. Parameters beyond that number, usually 1000,
 * will be silently discarded. This can have nasty side-effects in some
 * applications, such as editiong shop products with many variations
 * against a product, which can result in well over 1000 submitted
 * parameters (looking at you WooCommerce). This aims to provide some
 * level of protection.
 *
 */

(function($) {
	$.fn.maxSubmit = function(options) {
		// this.each() is the wrapper for each selected group of checkboxes.
		return this.each(function() {

			var settings = $.extend({
				// The maximum number of parameters the form will be allowed to submit
				// before the user is issued a confirm (OK/Cancel) dialogue.

				max_count: 1000,

				// The message given to the user to confirm they want to submit anyway.
				// Can use {max_count} as a placeholder for the permitted maximum
				// and {form_count} for the counted form items.

				max_exceeded_message:
					'This form has too many fields for the server to accept.\n'
					+ ' Data may be lost if you submit. Are you sure you want to go ahead?',

				// The function that will display the confirm message.
				// Replace this with something fancy such as jquery.ui if you wish.

				confirm_display: function(form_count = '') {
					return confirm(
						settings
							.max_exceeded_message
							.replace("{max_count}", settings.max_count)
							.replace("{form_count}", form_count)
					);
				}
			}, options);

			// Form elements will be passed in, so we need to trigger on
			// an attempt to submit that form.

			// First check we do have a form.
			if ($(this).is("form")) {
				$(this).on('submit', function(e) {
					// We have a form, so count up the form items that will be
					// submitted to the server.

					// Text fields and submit buttons will all post one parameter.
					var form_count = $('input:text:enabled, input:submit:enabled, input:password:enabled, textarea:enabled', this).length;

					// Checkboxes will post only if checked.
					$('input:checkbox:enabled', this).each(function() {
						if (this.checked) form_count++;
					});

					// Single-select lists will always post one value.<commit_msg>Fixed JS syntax error that onlt Chrome was throwing up.<commit_after>/**
 * Copyright 2013-2014 Academe Computing Ltd
 * Released under the MIT license
 * Author: <NAME> <<EMAIL>>
 * Version: 1.1.0
 */
/**
 * jquery.maxsubmit.js
 *
 * Checks how many parameters a form is going to submit, and
 * gives the user a chance to cancel if it exceeds a set number.
 * PHP5.3+ has limits set by default on the number of POST parameters
 * that will be accepted. Parameters beyond that number, usually 1000,
 * will be silently discarded. This can have nasty side-effects in some
 * applications, such as editiong shop products with many variations
 * against a product, which can result in well over 1000 submitted
 * parameters (looking at you WooCommerce). This aims to provide some
 * level of protection.
 *
 */

(function($) {
	$.fn.maxSubmit = function(options) {
		// this.each() is the wrapper for each selected group of checkboxes.
		return this.each(function() {

			var settings = $.extend({
				// The maximum number of parameters the form will be allowed to submit
				// before the user is issued a confirm (OK/Cancel) dialogue.

				max_count: 1000,

				// The message given to the user to confirm they want to submit anyway.
				// Can use {max_count} as a placeholder for the permitted maximum
				// and {form_count} for the counted form items.

				max_exceeded_message:
					'This form has too many fields for the server to accept.\n'
					+ ' Data may be lost if you submit. Are you sure you want to go ahead?',

				// The function that will display the confirm message.
				// Replace this with something fancy such as jquery.ui if you wish.

				confirm_display: function(form_count) {
					if (typeof(form_count) === 'undefined') form_count = '';
					return confirm(
						settings
							.max_exceeded_message
							.replace("{max_count}", settings.max_count)
							.replace("{form_count}", form_count)
					);
				}
			}, options);

			// Form elements will be passed in, so we need to trigger on
			// an attempt to submit that form.

			// First check we do have a form.
			if ($(this).is("form")) {
				$(this).on('submit', function(e) {
					// We have a form, so count up the form items that will be
					// submitted to the server.

					// Text fields and submit buttons will all post one parameter.
					var form_count = $('input:text:enabled, input:submit:enabled, input:password:enabled, textarea:enabled', this).length;

					// Checkboxes will post only if checked.
					$('input:checkbox:enabled', this).each(function() {
						if (this.checked) form_count++;
					});

					// Single-select lists will always post one value.
{'fraction_non_alphanumeric': 0.09630480566724105, 'fraction_numerical': 0.009573042312847023, 'mean_word_length': 3.003065134099617, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '1068851', 'n_tokens_mistral': 1732, 'n_tokens_neox': 1389, 'n_words': 644}