{% extends "base.html" %}
{% block title %}{{ assignment.name }}{% endblock %}
{% block path %}&rarr; <a href="/assignments">assignments</a> &rarr; <a href="/assignments/{{ assignment.id }}">{{ assignment.name }}</a>{% endblock %}
{% block includes %}
	<script type="text/javascript">
	$(function() {
		$("#email").focus()
	})
	function addFileField() {
		var new_file = $("#file_input_container").children(":last").clone()
		var input = $(new_file).children(":last")
		var old_id = input.attr("id")
		var new_suffix = parseInt(old_id.substring(old_id.indexOf("-") + 1)) + 1
		
		input.attr("id", "archive-" + new_suffix)
		input.attr("name", "archive-" + new_suffix)

		new_file.appendTo("#file_input_container")
	}
	</script>
{% endblock %}
{% block content %}
	{% if not assignment.due_cutoff or now < assignment.due_cutoff %}
	<div class="tab" id="upload_archive">
		<h2>Upload a Submission</h2>
		<form method="post" action="upload" enctype="multipart/form-data">
			{{ simple_archive_form.hidden_tag() }}
			<div class="heading directions">
				Select one of more files to include in your submission below.
				Click <b>Add More Files</b> if you need to include more than
				3 files <em>(Javascript must be enabled for this to work)</em>.
			</div>
			<div style="text-align: center">
				<div id="file_input_container" style="margin-bottom: 10px">
					{% for i in simple_archive_form.archive.entries %}
					<div>{{ i(class_ = "simple_file_input") }}</div>
					{% endfor %}
				</div>
				<input id="add_field" onclick="addFileField()" type="button" value="Add More Files">
				<input id="submit_archive" type="submit" value="Upload">
			</div>
		</form>
	</div>
	{% else %}
	<div style="text-align: center;">
		{% autoescape false %}
		No more submissions will be accepted (cutoff was {{ create_time_element(assignment.due_cutoff) }}).
		{% endautoescape %}
	</div>
	{% endif %}
	
	<div id="submissions">
		{% for submission in submissions %}
		{% if submission.id in new_submissions %}
		<div class="submission attention">
		{% else %}
		<div class="submission">
		{% endif %}
			<h3>
			Submission on {{ submission.timestamp_pretty }}
			</h3>
			{% if submission.uploaded_filenames %}
			<div class="uploaded_filenames">
				<span style="float: right">
					<a href="{{ submission.id }}/download.tar.gz"><input type="button" value="Download"></a>
				</span>
			<ul class="uploaded_filenames">
			{% for i in submission.uploaded_filenames %}
				<li>{{ i }}</li>
			{% endfor %}
			</ul>
			</div>
			{% endif %}
		</div>
		{% endfor %}
	</div>
{% endblock %}
