<commit_before>function onerror(message) {
	console.error(message);
}

function zipBlob(blob, callback) {
	zip.createWriter(new zip.BlobWriter("application/zip"), function(zipWriter) {
		zipWriter.add(FILENAME, new zip.BlobReader(blob), function() {
			zipWriter.close(callback);
		});
	}, onerror);
}

// http://stackoverflow.com/questions/750486/javascript-closure-inside-loops-simple-practical-example
function closureHack(zipReader, entry, callback) {
	return function(data) {
		zipReader.close();
		callback(entry, data);
	};
}

function unzipBlob(blob, callback) {
	zip.createReader(new zip.BlobReader(blob), function(zipReader) {
		zipReader.getEntries(function(entries) {
			for (var i = 0; i < entries.length; i++) {
				var entry = entries[i];
				entry.getData(new zip.BlobWriter("text/plain"), closureHack(zipReader, entry, callback));
			}
		});
	}, onerror);
}

function handleFileSelect(event) {
	var files = event.target.files;

	for (var i = 0, f; f = files[i]; i++) {
		zip.useWebWorkers = false;
		unzipBlob(f, function(entry, unzippedBlob) {
			handleEntry(entry, unzippedBlob);
		});
	}
}

function handleEntry(entry, blob) {
	if (entry.filename != "content.xml") return;

	root = xml.loadFromURL(URL.createObjectURL(blob));
	console.log(root);
	
	document.getElementById('output').innerText = root.documentElement.textContent;
}<commit_msg>add linebreaks<commit_after>function onerror(message) {
	console.error(message);
}

function zipBlob(blob, callback) {
	zip.createWriter(new zip.BlobWriter("application/zip"), function(zipWriter) {
		zipWriter.add(FILENAME, new zip.BlobReader(blob), function() {
			zipWriter.close(callback);
		});
	}, onerror);
}

// http://stackoverflow.com/questions/750486/javascript-closure-inside-loops-simple-practical-example
function closureHack(zipReader, entry, callback) {
	return function(data) {
		zipReader.close();
		callback(entry, data);
	};
}

function unzipBlob(blob, callback) {
	zip.createReader(new zip.BlobReader(blob), function(zipReader) {
		zipReader.getEntries(function(entries) {
			for (var i = 0; i < entries.length; i++) {
				var entry = entries[i];
				entry.getData(new zip.BlobWriter("text/plain"), closureHack(zipReader, entry, callback));
			}
		});
	}, onerror);
}

function handleFileSelect(event) {
	var files = event.target.files;

	for (var i = 0, f; f = files[i]; i++) {
		zip.useWebWorkers = false;
		unzipBlob(f, function(entry, unzippedBlob) {
			handleEntry(entry, unzippedBlob);
		});
	}
}

function handleEntry(entry, blob) {
	if (entry.filename != "content.xml") return;

	root = xml.loadFromURL(URL.createObjectURL(blob));
	console.log(root);

    var output = document.getElementById('output');
    output.innerText = "";
    
    var children = root.documentElement.lastChild.childNodes[0].childNodes;
	for (var i = 0; i < children.length; i++) {
	    output.innerHTML += "<br />" + children[i].textContent;
	}
}
{'fraction_non_alphanumeric': 0.15728021978021978, 'fraction_numerical': 0.006181318681318681, 'mean_word_length': 4.884848484848485, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '6382036', 'n_tokens_mistral': 1039, 'n_tokens_neox': 964, 'n_words': 176}