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

{% get_current_timezone as TIME_ZONE %}

{% block title %}{{ workout.name }}{% endblock %}
{% block og_title %}{{ workout.name }}{% endblock %}
{% block description %}{{ workout.name }}
{{ workout.date }} - {{ workout.distance }}m - {{ workout.duration |durationprint:"%H:%M:%S.%f" }}{% endblock %}
{% block og_description %}{{ workout.name }}
{{ workout.date }} - {{ workout.distance }}m - {{ workout.duration |durationprint:"%H:%M:%S.%f" }}{% endblock %}

{% block meta %}
{% leaflet_js %}
{% leaflet_css %}
<script src="https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.js"></script>
<script async="true" type="text/javascript">
  Bokeh.set_log_level("info");
</script>

{% for chart in charts %}
{{ chart.script |safe }}
{% endfor %}
{% endblock %}

{% block scripts %}
{% include "monitorjobs.html" %}
<script>
  $(function($) {
  console.log('loading script');
  var workoutid = '{{ workout.id|encode }}';
  console.log(workoutid);
  var shownotes = true;
  if("{{ rower.showfavoritechartnotes }}" == "False") {
     shownotes = false;
  }
  $.getJSON(window.location.protocol + '//'+window.location.host + '/rowers/workout/{{ workout.id|encode }}/get-thumbnails/', function(json) {
  var counter=0;
  $("#id_sitready").remove();
  $("#id_thumbs").append(
  "<li class=\"grid_4\"><p>Click on the thumbnails to view the full chart.</p></li>");
  $.each(json, function(index, element) {
  console.log('adding thumbnail');
  var counter2 = counter+1;
  $("#id_thumbs").append(
  "<li>"+
    "<big>"+counter2+"</big>"+
      "<a href=\"/rowers/workout/"+workoutid+"/flexchart?favoritechart="+counter+"\">"+element.div+"</a>"+
      "</li>");

  $("#id_thumbscripts").append(element.script);
  counter += 1;
    });
  });


  });
</script>

{% endblock %}


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

<h1>{{ workout.name }}</h1>
{% if workout.user.user != user %}
<h2>{{ workout.user.user.first_name }} {{ workout.user.user.last_name }}</h2>
{% endif %}

{% block middle_panel %}
{% for templateName in middleTemplates %}
{% include templateName %}
{% endfor %}
{% endblock %}
{% block right_panel %}
{% endblock %}

{% endblock %}

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