{% extends "base.html" %}
{% load staticfiles %}

{% block title %}File loading{% endblock %}

{% block meta %}
    <script type='text/javascript'
      src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'>
    </script>
    <script type='text/javascript'
            src='https://ajax.aspnetcdn.com/ajax/jquery.validate/1.14.0/jquery.validate.min.js'>
    </script>
    <script>
      $(document).ready(function() {
      $('#id_file').on('change', function(evt) {
      var f = this.files[0];
      console.log(f);
      if (f.size > 4194304) {
        alert("File Size must be smaller than 4 MB");
        this.value = null;
      }
      if (f.size > 1048576) {
      $('#id_offline').val('True');
      console.log("Set offline to True");
      $('#extra_message').text('Because of the large size, the file will be processed offline. You will receive email when it is done. The extra actions will not be performed.');
      $('#extra_message').addClass('message');      
      }
      });
      });
    </script>
{% endblock %}

{% block content %}
    <form enctype="multipart/form-data" action="{{ formloc }}" method="post">
<div id="left" class="grid_6 alpha">
	<h1>Upload Workout File</h1>
    {% if form.errors %}
        <p style="color: red;">
            Please correct the error{{ form.errors|pluralize }} below.
        </p>
    {% endif %}

        <table>
            {{ rowerform.as_table }}
            {{ form.as_table }}
        </table>
        {% csrf_token %}
   <div id="formbutton" class="grid_1 prefix_4 suffix_1">
        <input class="button green" type="submit" value="Submit">
   </div>
</div>
<div id="right" class="grid_6 omega">
	<h1>Optional extra actions</h1>
	<p>
	<table>
	    {{ optionsform.as_table }}
	</table>
	</p>
        <p>
          You can select one static plot to be generated immediately for this workout. You can select to upload to Concept2 automatically. If you check "make private", this workout will not be visible to your followers and will not show up in your teams' workouts list.
        </p>
        
	<p>
	Valid file types are:
	<ul>
		<li>Painsled iOS Stroke Export (CSV)</li>
		<li>Painsled desktop version Stroke Export (CSV)</li>
		<li>A TCX file with location data (lat,long) - with or without Heart Rate value, for example from RiM or CrewNerd</li>
		<li>RowPro CSV export</li>
		<li>SpeedCoach GPS and SpeedCoach GPS 2 CSV export</li>
		<li>ErgData CSV export</li>
		<li>ErgStick CSV export</li>
                <li>BoatCoach CSV export</li>
		<li>A FIT file with location data (experimental)</li>
	</ul>
	</p>
</div>



</form>
{% endblock %}
