<commit_before>;(function ( $, window, document, undefined ) {

		var pluginName = "AIU",
				defaults = {
				'photo_preview' : '#photo_preview',
				'photo_error' : '.photo_error',
				'img_loading_path' : 'images/ajax-loader.gif',
				'php_path' : 'photo_controller.php'
		};

		// Constructor
		function Plugin ( element, options ) {
				this.element = element;
				this._input = $("input[type=file]", $(this));
				this._options = options;
				this.settings = $.extend( {}, defaults, options );
				this._defaults = defaults;
				this._name = pluginName;
				this.init();
		}

		Plugin.prototype = {
				init: function () {

					$(this._input).on("change", $.proxy(function(){


						var photo_preview = this.settings.photo_preview;
						var photo_error = this.settings.photo_error;
						var image_default = $(photo_preview).attr("src"); 	/* Saves the default-image path. If something fails, it'll be shown again..*/
						var the_data = this;
						var accept_ext = ["jpeg","jpg","gif","bmp","png"];
						var file_extension = $(this._input).val().split('.').pop();
						var result = $.inArray(file_extension, accept_ext);
						var extensions = accept_ext.join(", ");

						$(photo_preview).attr("src", this.settings.img_loading_path).addClass("loading");
						$(photo_error).hide(); /* Hides the error message, if it is visible.*/

						if (result == -1) {
							$(photo_error).show().html(" The image needs to be the in following extensions:" + extensions + "");
							$(photo_preview).attr("src", image_default).removeClass("loading");
							return false;
						}
						 if(! this.isAjaxUploadSupported()){
						            var iframe = document.createElement("iframe");
						            iframe.setAttribute("id", "upload_iframe_myFile");
						            iframe.setAttribute("name", "upload_iframe_myFile");
						            iframe.setAttribute("width", "0");
						            iframe.setAttribute("height", "0");
						            iframe.setAttribute("border", "0");
						            iframe.setAttribute("src","javascript:false;");
						            iframe.style.display = "none";
						            var form = document.createElement("form");
						            form.setAttribute("target", "upload_iframe_myFile");
						            form.setAttribute("action", this.settings.php_path);
						            form.setAttribute("method", "post");
						            form.setAttribute("enctype", "multipart/form-data");
						            form.setAttribute("encoding", "multipart/form-data");
						            form.style.display = "none";

						            var files = $(this)[0];
						            form.appendChild(files);
						            document.body.appendChild(form);
						            document.body.appendChild(iframe);

						            iframeIdmyFile = document.getElementById("upload_iframe_myFile");
						            var eventHandlermyFile = function () {
						                if (iframeIdmyFile.detachEvent)
						                    iframeIdmyFile.detachEvent("onload", eventHandlermyFile);
						                else
						                    iframeIdmyFile.removeEventListener("load", eventHandlermyFile, false);

						                response = this.getIframeContentJSON(iframeIdmyFile);
						                if(response.success)
						                {
						                    $(photo_preview).attr("src", response.src).removeClass("loading");
						                }
						                else
						                {
						                    $(photo_preview).attr("src", image_default).removeClass("loading");
						                         if(response.msg) {
						                            $(photo_error).show().html(response.msg);
						                        } else {
						                            $(photo_error).show().html(" An error occured. Check the image extension and size.");
						                        }
						                }
						            };

						            if (iframeIdmyFile.addEventListener)
						                iframeIdmyFile.addEventListener("load", eventHandlermyFile, true);
						            if (iframeIdmyFile.attachEvent)
						                iframeIdmyFile.attachEvent("onload", eventHandlermyFile);

						            form.submit();

						            $(photo_form).append(the_data);

						        } else {
						                 /*********************************************************** Nice Browsers ********************************************************************************/
						            var data = new FormData();
						            data.append("Photo", $(this._input).prop("files")[0]);

						            $.ajax(
						            {
						                url: this.settings.php_path,
						                secureuri: false,
						                fileElementId: 'photo_input',
						                dataType: "json",
						                data: data,
						                cache: false,
						                enctype: "multipart/form-data",
						                type: "POST",
						                processData: false,
						                contentType: false,
						                success: function(data)
						                {
						                   if(data.success)
						                   {
						                        $(photo_preview).attr("src", data.src).removeClass("loading");
						                   }
						                   else
						                   {
						                        $(photo_preview).attr("src", image_default).removeClass("loading");
						                       if (data.msg) {
						                            $(photo_error).show().html(data.msg);
						                        } else {
						                            $(photo_error).show().html(" An error occured. Check the image extension and size.");
						                        }
						                   }
						                },
						                error: function(xhr, textStatus, errorThrown)
						                {
						                    $(photo_preview).attr("src", image_default).removeClass("loading");
						                     if (data.msg) {
						                            $(photo_error).show().html(data.msg);
						                        } else {
						                            $(photo_error).show().html(" An error occured. Check the image extension and size.");
						                        }
						                    return false;
						                }
						            });
						        }
					}, this));

				},

				'isAjaxUploadSupported' : function(){
			       		     var input = document.createElement("input");
				                input.type = "file";
				                return (<commit_msg>melhoria/otimizacao no codigo<commit_after>;(function ( $, window, document, undefined ) {

		var pluginName = "AIU",
				defaults = {
				'photo_preview' : '#photo_preview',
				'photo_error' : '.photo_error',
				'img_loading_path' : 'images/ajax-loader.gif',
				'php_path' : 'photo_controller.php'
		};

		// Constructor
		function Plugin ( element, options ) {
				this.element = element;
				this._input = $("input[type=file]", $(this));
				this._options = options;
				this.settings = $.extend( {}, defaults, options );
				this._defaults = defaults;
				this._name = pluginName;
				this.init();
		}

		Plugin.prototype = {
				init: function () {

					$(this._input).on("change", $.proxy(function(){
						var $photo_preview = $(this.settings.photo_preview);
						var $photo_error = $(this.settings.photo_error);
						var image_default = $photo_preview.attr("src"); 	/* Saves the default-image path. If something fails, it'll be shown again..*/
						var the_data = this;
						var accept_ext = ["jpeg","jpg","gif","bmp","png"];
						var file_extension = $(this._input).val().split('.').pop();
						var result = $.inArray(file_extension, accept_ext);
						var extensions = accept_ext.join(", ");
						var msgErrorDefault = " An error occured. Check the image extension and size.";

						$photo_preview.attr("src", this.settings.img_loading_path).addClass("loading");
						$photo_error.hide(); /* Hides the error message, if it is visible.*/

						if (result == -1) {
							$photo_error.show().html(" The image needs to be the in following extensions:" + extensions + "");
							$photo_preview.attr("src", image_default).removeClass("loading");
							return false;
						}
						 if(! this.isAjaxUploadSupported()){
						            var iframe = document.createElement("iframe");
						            iframe.setAttribute("id", "upload_iframe_myFile");
						            iframe.setAttribute("name", "upload_iframe_myFile");
						            iframe.setAttribute("width", "0");
						            iframe.setAttribute("height", "0");
						            iframe.setAttribute("border", "0");
						            iframe.setAttribute("src","javascript:false;");
						            iframe.style.display = "none";
						            var form = document.createElement("form");
						            form.setAttribute("target", "upload_iframe_myFile");
						            form.setAttribute("action", this.settings.php_path);
						            form.setAttribute("method", "post");
						            form.setAttribute("enctype", "multipart/form-data");
						            form.setAttribute("encoding", "multipart/form-data");
						            form.style.display = "none";

						            var files = $(this)[0];
						            form.appendChild(files);
						            document.body.appendChild(form);
						            document.body.appendChild(iframe);

						            iframeIdmyFile = document.getElementById("upload_iframe_myFile");
						            var eventHandlermyFile = function () {
						                if (iframeIdmyFile.detachEvent)
						                    iframeIdmyFile.detachEvent("onload", eventHandlermyFile);
						                else
						                    iframeIdmyFile.removeEventListener("load", eventHandlermyFile, false);

						                response = this.getIframeContentJSON(iframeIdmyFile);
						                if(response.success)
						                {
						                    $photo_preview.attr("src", response.src).removeClass("loading");
						                }
						                else
						                {
						                	var message = response.msg || msgErrorDefault;

					                    	$photo_error.show().html(message);
						                    $photo_preview.attr("src", image_default).removeClass("loading");
						                }
						            };

						            if (iframeIdmyFile.addEventListener)
						                iframeIdmyFile.addEventListener("load", eventHandlermyFile, true);
						            if (iframeIdmyFile.attachEvent)
						                iframeIdmyFile.attachEvent("onload", eventHandlermyFile);

						            form.submit();

						            $(photo_form).append(the_data);

						        } else {
						                 /*********************************************************** Nice Browsers ********************************************************************************/
						            var data = new FormData();
						            data.append("Photo", $(this._input).prop("files")[0]);

						            $.ajax(
						            {
						                url: this.settings.php_path,
						                secureuri: false,
						                fileElementId: 'photo_input',
						                dataType: "json",
						                data: data,
						                cache: false,
						                enctype: "multipart/form-data",
						                type: "POST",
						                processData: false,
						                contentType: false,
						                success: function(data)
						                {
						                   if(data.success)
						                   {
						                        $photo_preview.attr("src", data.src).removeClass("loading");
						                   }
						                   else
						                   {
						                   		var message = data.msg || msgErrorDefault;

						                    	$photo_error.show().html(message);
							                    $photo_preview.attr("src", image_default).removeClass("loading");
						                   }
						                },
						                error: function(xhr, textStatus, errorThrown)
						                {
						                    var message = data.msg || msgErrorDefault;

					                    	$photo_error.show().html(message);
						                    $photo_preview.attr("src", image_default).removeClass("loading");

						                    return false;
						                }
						            });
						        }
					}, this));

				},

				'isAjaxUploadSupported' : function(){
			       		     var input = document.createElement("input");
				                input.type = "file";
				                return (
{'fraction_non_alphanumeric': 0.13984599828886987, 'fraction_numerical': 0.0009333437038189313, 'mean_word_length': 1.4384600796510525, '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': '6225488', 'n_tokens_mistral': 4425, 'n_tokens_neox': 2918, 'n_words': 535}