<commit_before>$(function() {
	$("#uploadbrowse").click(function() {
		$("#fileselect").click();
	});

	//------------------- FILEDRAG -----------------------------

	var allowedFileTypes = ['txt', 'xml', 'html', 'sgml'];

	// getElementById
	function $id(id) {
		return document.getElementById(id);
	}

	// output information
	function Output(msg) {
		var m = $id("manage-previews");
		m.innerHTML = msg + m.innerHTML;
	}

	function AllowedFileType(filename) {
		var splitName = filename.split(".");
		var fileType = splitName[splitName.length-1];
		if ($.inArray(fileType, allowedFileTypes) > -1) {
			return true;
		}
		else {
			return false;
		}
	}

	// file drag hover
	function FileDragHover(e) {
		e.stopPropagation();
		e.preventDefault();
		e.target.className = (e.type == "dragover" ? "hover" : "");
	}

	// file selection
	function FileSelectHandler(e) {

		// cancel event and hover styling
		FileDragHover(e);

		// fetch FileList object
		var files = e.target.files || e.dataTransfer.files;

		// process all File objects
		for (var i = 0, f; f = files[i]; i++) {
			UploadAndParseFile(f);
		}
	}

	// upload and display file contents
	function UploadAndParseFile(file) {
		var filesUploaded = false;

		var filename = file.name.replace(/ /g, "_");

		if (AllowedFileType(file.name) && file.size <= $id("MAX_FILE_SIZE").value) {
			
			// ajax call to upload files
			$.ajax({
				type: 'POST',
				data: file,
				url: document.URL,
				processData: false,
				contentType: file.type,
				beforeSend: function(xhr){
					xhr.setRequestHeader("X_FILENAME", encodeURIComponent(filename));
				},
				success: function(res){
					filesUploaded = true;

					var reader = new FileReader();
					reader.onload = function(e) {
						// Detect whether the file has HTML or XML tags
						var pattern = new RegExp("<[^>]+>");
						var hasTags = pattern.test(e.target.result);
						// Update the checkTags and formmatingbox hidden inputs.
						// Show the strip tags form fields.
						if (hasTags == true) {
							$("#tags").val("on");
						}
						Output(<commit_msg>Setting upload ajax to synchronous<commit_after>$(function() {
	$("#uploadbrowse").click(function() {
		$("#fileselect").click();
	});

	//------------------- FILEDRAG -----------------------------

	var allowedFileTypes = ['txt', 'xml', 'html', 'sgml'];

	// getElementById
	function $id(id) {
		return document.getElementById(id);
	}

	// output information
	function Output(msg) {
		var m = $id("manage-previews");
		m.innerHTML = msg + m.innerHTML;
	}

	function AllowedFileType(filename) {
		var splitName = filename.split(".");
		var fileType = splitName[splitName.length-1];
		if ($.inArray(fileType, allowedFileTypes) > -1) {
			return true;
		}
		else {
			return false;
		}
	}

	// file drag hover
	function FileDragHover(e) {
		e.stopPropagation();
		e.preventDefault();
		e.target.className = (e.type == "dragover" ? "hover" : "");
	}

	// file selection
	function FileSelectHandler(e) {

		// cancel event and hover styling
		FileDragHover(e);

		// fetch FileList object
		var files = e.target.files || e.dataTransfer.files;

		// process all File objects
		for (var i = 0, f; f = files[i]; i++) {
			UploadAndParseFile(f);
		}
	}

	// upload and display file contents
	function UploadAndParseFile(file) {
		var filesUploaded = false;

		var filename = file.name.replace(/ /g, "_");

		if (AllowedFileType(file.name) && file.size <= $id("MAX_FILE_SIZE").value) {
			
			// ajax call to upload files
			$.ajax({
				type: 'POST',
				data: file,
				url: document.URL,
				processData: false,
				async: false,
				contentType: file.type,
				beforeSend: function(xhr){
					xhr.setRequestHeader("X_FILENAME", encodeURIComponent(filename));
				},
				success: function(res){
					filesUploaded = true;

					var reader = new FileReader();
					reader.onload = function(e) {
						// Detect whether the file has HTML or XML tags
						var pattern = new RegExp("<[^>]+>");
						var hasTags = pattern.test(e.target.result);
						// Update the checkTags and formmatingbox hidden inputs.
						// Show the strip tags form fields.
						if (hasTags == true) {
							$("#tags").val("on");
						}
						Output(
{'fraction_non_alphanumeric': 0.172815996191383, 'fraction_numerical': 0.0014282313734825041, 'mean_word_length': 2.788999098286745, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '7030028', 'n_tokens_mistral': 1616, 'n_tokens_neox': 1337, 'n_words': 335}