<commit_before>var r = new Resumable({target: base + '/publish/'+addon+'/'+release+'/upload', permanentErrors: [403, 404, 415, 500, 501], query: {state: state}});

$('#resumable-error').hide();
if (!r.support) {
	$('#resumable').hide();
	$('#no-resumable').show();
} else {
	$('#no-resumable').hide();
	r.assignBrowse($('#resumable-select'));
	$('#resumable-pause').hide();
	$('#resumable-upload').click(function() {
		r.upload();
		updateState();
	});
	$('#resumable-pause').click(function() {
		r.pause();
		updateState();
	});
	$('#resumable').show();
	updateState();
}

function updateState() {
	if (r.files.length > 0) {
		$('#resumable-files').show();
		$('#resumable-files-none').hide();
	}
	else {
		$('#resumable-files').hide();
		$('#resumable-files-none').show();
	}
	if (r.files.length > 0 && r.progress() < 1) {
		$('#resumable-upload').removeAttr('disabled');
	}
	else {
		$('#resumable-upload').attr('disabled', true);
	}

	if (r.isUploading()) {
		$('#resumable-select').attr('disabled', true);
		$('#resumable-pause').show();
		$('#resumable-upload').hide();
	}
	else {
		$('#resumable-select').removeAttr('disabled');
		$('#resumable-pause').hide();
		$('#resumable-upload').show();
	}
}

r.on('fileAdded', function(file) {
	$('#resumable-files').append($('<li class="list-group-item resumable-item" data-unique="' + file.uniqueIdentifier + '"><span class="resumable-filename">' + file.fileName + '</span><button type="button" class="close" title="' + $('#text-remove').text() + '" aria-hidden="true">&times;</button><span class="resumable-progress"></span></li>'));
	$('li[data-unique="' + file.uniqueIdentifier + '"] .close').click(function() {
		$.each(r.files, function(key, clickedFile) {
			if (clickedFile.uniqueIdentifier === file.uniqueIdentifier) {
				$.ajax(base + '/api/upload/remove', {method: 'post'});
				$('li[data-unique="' + file.uniqueIdentifier + '"]').remove();
				file.cancel();
				updateState();
			}
		});
	});
	updateState();
});

r.on('fileProgress', function(file) {
	var percentage = Math.min(Math.round(file.progress() * 100), 99);
	$('li[data-unique="' + file.uniqueIdentifier + '"] .resumable-progress').text(percentage + '%');
});

r.on('fileSuccess', function(file) {
	$('li[data-unique="' + file.uniqueIdentifier + '"] .resumable-progress').addClass('resumable-complete');
	$('li[data-unique="' + file.uniqueIdentifier + '"] .resumable-progress').text($('#text-uploaded').text());<commit_msg>add drop-zone and automatic upload after selecting files<commit_after>var r = new Resumable({target: base + '/publish/'+addon+'/'+release+'/upload', permanentErrors: [403, 404, 415, 500, 501], query: {state: state}});

if (!r.support) {
	$('#resumable').hide();
	$('#no-resumable').show();
} else {
	$('#no-resumable').hide();
	r.assignBrowse($('#resumable-select'));
	r.assignDrop($('#files'));
	$('#resumable-pause').hide();
	$('#resumable-upload').click(function() {
		r.upload();
		updateState();
	});
	$('#resumable-pause').click(function() {
		r.pause();
		updateState();
	});
	$('#resumable').show();
	updateState();
}

function updateState() {
	if (r.files.length > 0) {
		$('#resumable-files').show();
		$('#resumable-files-none').hide();
	}
	else {
		$('#resumable-files').hide();
		$('#resumable-files-none').show();
	}
	if (r.files.length > 0 && r.progress() < 1) {
		$('#resumable-upload').removeAttr('disabled');
	}
	else {
		$('#resumable-upload').attr('disabled', true);
	}

	if (r.isUploading()) {
		$('#resumable-select').attr('disabled', true);
		$('#resumable-pause').show();
		$('#resumable-upload').hide();
	}
	else {
		$('#resumable-select').removeAttr('disabled');
		$('#resumable-pause').hide();
		$('#resumable-upload').show();
	}
}

r.on('fileAdded', function(file) {
	$('#resumable-files').append($('<li class="list-group-item resumable-item" data-unique="' + file.uniqueIdentifier + '"><span class="resumable-filename">' + file.fileName + '</span><button type="button" class="close" title="' + $('#text-remove').text() + '" aria-hidden="true">&times;</button><span class="resumable-progress"></span></li>'));
	$('li[data-unique="' + file.uniqueIdentifier + '"] .close').click(function() {
		$.each(r.files, function(key, clickedFile) {
			if (clickedFile.uniqueIdentifier === file.uniqueIdentifier) {
				$.ajax(base + '/api/upload/remove', {method: 'post'});
				$('li[data-unique="' + file.uniqueIdentifier + '"]').remove();
				file.cancel();
				updateState();
			}
		});
	});
	r.upload();
	updateState();
});

r.on('fileProgress', function(file) {
	var percentage = Math.min(Math.round(file.progress() * 100), 99);
	$('li[data-unique="' + file.uniqueIdentifier + '"] .resumable-progress').text(percentage + '%');
});

r.on('fileSuccess', function(file) {
	$('li[data-unique="' + file.uniqueIdentifier + '"] .resumable-progress').addClass('resumable-complete');
	$('li[data-unique="' + file.uniqueIdentifier + '"] .resumable-progress').text($('#text-uploaded').text());
{'fraction_non_alphanumeric': 0.2678787878787879, 'fraction_numerical': 0.009292929292929294, 'mean_word_length': 5.298982188295166, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, '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': '5205123', 'n_tokens_mistral': 1820, 'n_tokens_neox': 1734, 'n_words': 237}