<commit_before>(function() {
	window.files = {
		init: function(componentType, formWindow) {
			if (componentType == 'UPLOAD FILE') {
				var outParam = formWindow.find("input[value=OUTPUT_CONNECTION]").parent().find("input[name$=value]");
				if (outParam.val()) {
					// editing workflow: a connection already exists 
					formWindow.append(this.fileSelectedView(outParam.val()));
				}
			}
		},

		fileSelectedView: function(fileUrl) {
			var successText = $("<div class=\"file-form-container\"></div>");
			var tableContent = "";
			if (fileUrl) {
				var fileName = fileUrl.substring(fileUrl.lastIndexOf("/") + 1);
				tableContent += "<tr><td>" + gettext("A file is uploaded") + ":</td><td><a href=\"" + fileUrl + "\"><b>" + fileName + "</b></a></td></tr>";
				successText.append("<table><tbody>" + tableContent + "</b></tbody></table>");
			}
			return successText;
		},

		// send request to the server to obtain file upload form
		update: function(dialog) {
			var url = window.componentFormUrls['UPLOAD FILE'];
			var fileForm = dialog.find(".file-form-container");
			if (fileForm.length == 0) {
				var fileForm = $("<div class=\"file-form-container\"></div>");
				dialog.append(fileForm);
				$.ajax({
					url: url,
					context: fileForm
				}).done(function(resp) {
					$(this).html(resp);
					dialog.dialog("option", "buttons", window.files.allButtons());
				});
			}
		},

		// upload form in the iframe
		doUpload: function(fileForm) {
			// TODO: clone does not preserve textarea and input values 
			// so we need to construct a placeholder differently 
			var fileFormPlaceholder = fileForm.clone(true);
			var fileUploadForm = $("#file-upload-form");
			// move the fields to the hidden form
			// replace them with a placeholder
			fileForm.after(fileFormPlaceholder).appendTo(fileUploadForm);

			$("#file-upload-iframe").off("load");
			$("#file-upload-iframe").on("load", function(resp) {
				window.files.handleUploadResponse(fileFormPlaceholder);
			});
			document.getElementById("file-upload-form").submit();
		},

		// process file upload response
		handleUploadResponse: function(fileFormPlaceholder) {
			var fileUploadIframe = $("#file-upload-iframe");
			var textContent = fileUploadIframe.contents().find("body")[0].textContent;

			// if we no text in the iframe, it means that this was not a POST
			// response, so we should exit<commit_msg>Changed textContent to text() for IE compatibility in file upload component.<commit_after>(function() {
	window.files = {
		init: function(componentType, formWindow) {
			if (componentType == 'UPLOAD FILE') {
				var outParam = formWindow.find("input[value=OUTPUT_CONNECTION]").parent().find("input[name$=value]");
				if (outParam.val()) {
					// editing workflow: a connection already exists 
					formWindow.append(this.fileSelectedView(outParam.val()));
				}
			}
		},

		fileSelectedView: function(fileUrl) {
			var successText = $("<div class=\"file-form-container\"></div>");
			var tableContent = "";
			if (fileUrl) {
				var fileName = fileUrl.substring(fileUrl.lastIndexOf("/") + 1);
				tableContent += "<tr><td>" + gettext("A file is uploaded") + ":</td><td><a href=\"" + fileUrl + "\"><b>" + fileName + "</b></a></td></tr>";
				successText.append("<table><tbody>" + tableContent + "</b></tbody></table>");
			}
			return successText;
		},

		// send request to the server to obtain file upload form
		update: function(dialog) {
			var url = window.componentFormUrls['UPLOAD FILE'];
			var fileForm = dialog.find(".file-form-container");
			if (fileForm.length == 0) {
				var fileForm = $("<div class=\"file-form-container\"></div>");
				dialog.append(fileForm);
				$.ajax({
					url: url,
					context: fileForm
				}).done(function(resp) {
					$(this).html(resp);
					dialog.dialog("option", "buttons", window.files.allButtons());
				});
			}
		},

		// upload form in the iframe
		doUpload: function(fileForm) {
			// TODO: clone does not preserve textarea and input values 
			// so we need to construct a placeholder differently 
			var fileFormPlaceholder = fileForm.clone(true);
			var fileUploadForm = $("#file-upload-form");
			// move the fields to the hidden form
			// replace them with a placeholder
			fileForm.after(fileFormPlaceholder).appendTo(fileUploadForm);

			$("#file-upload-iframe").off("load");
			$("#file-upload-iframe").on("load", function(resp) {
				window.files.handleUploadResponse(fileFormPlaceholder);
			});
			document.getElementById("file-upload-form").submit();
		},

		// process file upload response
		handleUploadResponse: function(fileFormPlaceholder) {
			var fileUploadIframe = $("#file-upload-iframe");
			var textContent = fileUploadIframe.contents().find("body").text();

			// if we no text in the iframe, it means that this was not a POST
			// response, so we should exit
{'fraction_non_alphanumeric': 0.16787414613951562, 'fraction_numerical': 0.0010349824052991099, 'mean_word_length': 3.7465618860510808, 'pattern_counts': {'":': 2, '<': 41, '<?xml version=': 0, '>': 41, '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': '4421371', 'n_tokens_mistral': 1699, 'n_tokens_neox': 1434, 'n_words': 347}