{% extends "newbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% load tz %}

{% block title %} Flexible Plot {% endblock %}

{% localtime on %}
{% block main %}

{{ js_res | safe }}
{{ css_res| safe }}

<script src="https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.js"></script>
<script src="https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.js"></script>
<script async="true" type="text/javascript">
  Bokeh.set_log_level("info");
</script>

{{ the_script |safe }}

<p>
  {% if workout|previousworkout:rower.user %}
  <a href="/rowers/workout/{{ workout|previousworkout:rower.user }}/flexchart/"
     title="Jump to preceding workout"><em>Previous</em></a>&nbsp;
  {% endif %}
  {% if workout|nextworkout:rower.user %}
  <a href="/rowers/workout/{{ workout|nextworkout:rower.user }}/flexchart/"
     title="Jump to following workout"><em>Next</em></a>
  {% endif %}
</p>


<h1>Flexible Chart</h1>

<ul class="main-content">
  <li class="grid_4">
    <div id="theplot" class="flexplot">
      {{ the_div|safe }}
    </div>
  </li>
  <li class="grid_2">
    <form enctype="multipart/form-data"
          action=""
          method="post">
      {% csrf_token %}
      <table>
        {{ chartform.as_table }}
      </table>
      <table>
        {{ optionsform.as_table }}
      </table>
      <p>
        <input name="chartform" type="submit"
               value="Update Chart">
      </p>
    </form>
  </li>

  <li class="grid_2">
    <form enctype="multipart/form-data" action="{{ formloc }}" method="post">
    {% if favoritenr > 0 %}
    <a
       href="/rowers/workout/{{ id }}/flexchart/?favoritechart={{ favoritenr|add:-1 }}">
      <i class="fas fa-arrow-alt-left"></i>
    </a>
    {% else %}
    <a
       href="/rowers/workout/{{ id }}/flexchart/?favoritechart={{ maxfav }}">
      <i class="fas fa-arrow-alt-left"></i>
    </a>
    {% endif %}
      {% csrf_token %}
      <input class="grid_2 alpha button blue small" type="hidden" name="savefavorite" value="True">
      {% if workstrokesonly %}
      <input type="hidden" name="workstrokesonlysave" value="False">
      {% else %}
      <input type="hidden" name="workstrokesonlysave" value="True">
      {% endif %}
      <input value="Make Favorite" type="Submit">
    {% if favoritenr < maxfav %}
    <a
       href="/rowers/workout/{{ id }}/flexchart/?favoritechart={{ favoritenr|add:1 }}">
      <i class="fas fa-arrow-alt-right"></i>
    </a>
    {% else %}
    <a
       href="/rowers/workout/{{ id }}/flexchart/?favoritechart=0">
      <i class="fas fa-arrow-alt-right"></i>
    </a>
    {% endif %}
    </form>
    {% if favoritechartnotes %}
    <p>Chart {{ favoritenr|add:1 }}:{{ favoritechartnotes }}</p>
    {% endif %}
  </li>
</ul>

{% endblock %}
{% endlocaltime %}

{% block sidebar %}
{% include 'menu_workout.html' %}
{% endblock %}
