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

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

{% localtime on %}
{% block content %}

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

<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
<script type="text/javascript" src="/static/js/bokeh-widgets-0.12.3.min.js"></script>
<script async="true" type="text/javascript">
  Bokeh.set_log_level("info");
</script>

{{ the_script |safe }}


<style>
  /* Need this to get the page in "desktop mode"; not having an infinite height.*/
  html, body {height: 100%; margin:5px;}
</style>

<div id="navigation" class="grid_12 alpha">
  {% if user.is_authenticated and mayedit %}
  <div class="grid_2 alpha">
    <p>
      <a class="button gray small" href="/rowers/workout/{{ id }}/edit">Edit Workout</a>
    </p>
  </div>
  <div class="grid_2 suffix_8 omega">
    <p>
      <a class="button gray small" href="/rowers/workout/{{ id }}/advanced">Advanced Edit</a>
    </p>

  </div>
  {% endif %}
</div>


<p>&nbsp;</p>

<div id="plotbuttons" class="grid_12 alpha">


  <div id="x-axis" class="grid_6 alpha">
    <div class="grid_2 alpha dropdown">
      <button class="grid_2 alpha button blue small dropbtn">X-axis</button>
      <div class="dropdown-content">
        {% for key, value in axchoicesbasic.items %}
        {% if key != 'None' %}
        <a class="button blue small alpha" href="/rowers/workout/{{ id }}/flexchart/{{ key }}/{{ yparam1 }}/{{ yparam2 }}/{{ plottype }}">{{ value }}</a>
        {% endif %}
        {% endfor %}
	{% if promember %}
        {% for key, value in axchoicespro.items %}
	<a class="button blue small alpha" href="/rowers/workout/{{ id }}/flexchart/{{ key }}/{{ yparam1 }}/{{ yparam2 }}/scatter">{{ value }}</a>
        {% endfor %}
	{% else %}
        {% for key, value in axchoicespro.items %}
	<a class="button rosy small" href="/rowers/promembership">{{ value }}</a>
        {% endfor %}
	{% endif %}
      </div>
    </div>
		
    <div id="left-y" class="grid_2 dropdown">
      <button class="grid_2 alpha button blue small dropbtn">Left</button>
      <div class="dropdown-content">
        {% for key, value in axchoicesbasic.items %}
        {% if key not in noylist and key != 'None' %}
	<a class="button blue small" href="/rowers/workout/{{ id }}/flexchart/{{ xparam }}/{{ key }}/{{ yparam2 }}/{{ plottype }}">{{ value }}</a>
        {% endif %}
        {% endfor %}
	{% if promember %}
        {% for key, value in axchoicespro.items %}
        {% if key not in noylist %}
	<a class="button blue small" href="/rowers/workout/{{ id }}/flexchart/{{ xparam }}/{{ key }}/{{ yparam2 }}/{{ plottype }}">{{ value }}</a>
        {% endif %}
        {% endfor %}
	{% else %}
        {% for key, value in axchoicespro.items %}
        {% if key not in noylist %}
	<a class="button rosy small" href="/rowers/promembership">{{ value }} (Pro)</a>
        {% endif %}
        {% endfor %}
	{% endif %}
        
      </div>
    </div>
    
    <div id="right-y" class="grid_2 dropdown omega">
      <button class="grid_2 alpha button blue small dropbtn">Right</button>
      <div class="dropdown-content">
        {% for key, value in axchoicesbasic.items %}
        {% if key not in noylist %}
	<a class="button blue small" href="/rowers/workout/{{ id }}/flexchart/{{ xparam }}/{{ yparam1 }}/{{ key }}/{{ plottype }}">{{ value }}</a>
        {% endif %}
        {% endfor %}
	{% if promember %}
        {% for key, value in axchoicespro.items %}
        {% if key not in noylist %}
	<a class="button blue small" href="/rowers/workout/{{ id }}/flexchart/{{ xparam }}/{{ yparam1 }}/{{ key }}/{{ plottype }}">{{ value }}</a>
        {% endif %}
        {% endfor %}
	{% else %}
        {% for key, value in axchoicespro.items %}
        {% if key not in noylist %}
	<a class="button rosy small" href="/rowers/promembership">{{ value }} (Pro)</a>
        {% endif %}
        {% endfor %}
	{% endif %}
        
      </div>
    </div>
    
  </div>

  <div id="y-axis" class="grid_6 omega">
    <div class="grid_2 alpha tooltip">
      <form enctype="multipart/form-data" action="{{ formloc }}" method="post">
        {% csrf_token %}
	{% if workstrokesonly %}
	<input type="hidden" name="workstrokesonly" value="True">
	<input class="grid_2 alpha button blue small" value="Remove Rest Strokes" type="Submit">
	{% else %}
	<input class="grid_2 alpha button blue small" type="hidden" name="workstrokesonly" value="False">
	<input class="grid_2 alpha button blue small" value="Include Rest Strokes" type="Submit">
	{% endif %}
      </form>
      <span class="tooltiptext">If your data source allows, this will show or hide strokes taken during rest intervals.</span>
    </div>
    <div class="grid_2">
      <a class="button blue small" href="/rowers/workout/{{ id }}/flexchart/{{ xparam }}/{{ yparam1 }}/{{ yparam2 }}/line">Line Plot</a>
    </div>
    <div class="grid_2 omega">
      <a class="button blue small" href="/rowers/workout/{{ id }}/flexchart/{{ xparam }}/{{ yparam1 }}/{{ yparam2 }}/scatter">Scatter Plot</a>
    </div>
  </div>

</div>

<div id="theplot" class="grid_12 alpha">


  {{ the_div|safe }}

</div>

{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
<div id="favorites" class="grid_12 alpha">
  <div class="grid_2 suffix_4 alpha">
    {% if maxfav >= 0 %}
    <a class="button gray small" href="/rowers/me/favoritecharts">Manage Favorites</a>
    {% else %}
    &nbsp;
    {% endif %}
  </div>
  <div class="grid_1">
    {% if favoritenr > 0 %}
    <a class="button blue small" href="/rowers/workout/{{ id }}/flexchart?favoritechart={{ favoritenr|add:-1 }}">&lt</a>
    {% else %}
    <a class="button blue small" href="/rowers/workout/{{ id }}/flexchart?favoritechart={{ maxfav }}">&lt</a>
    {% endif %}
  </div>
  <div class="grid_2">
    <form enctype="multipart/form-data" action="{{ formloc }}" method="post">
      {% 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 class="grid_2 alpha button blue small" value="Make Favorite" type="Submit">
    </form>
  </div>
  <div class="grid_1">
  {% if favoritenr < maxfav %}
  <a class="button blue small" href="/rowers/workout/{{ id }}/flexchart?favoritechart={{ favoritenr|add:1 }}">&gt</a>
    {% else %}
  <a class="button blue small" href="/rowers/workout/{{ id }}/flexchart?favoritechart=0">&gt</a>
    {% endif %}
  </div>                        
</div>
{% endif %}

{% endblock %}
{% endlocaltime %}
