{% extends "base.html" %}
{% set currentPage = "allVotes" %}

{# This page is for reviewing the votes made by all committee members #}

{% block body %}

<!--why are there two scripts?-->
<script>
  {% if fac is not none %}
    var numRows = {{fac|count}};
  {% endif %}
  function changeSize (ele, scale) {
      $("#"+ele).stop().animate({fontSize : scale});
    }
  
</script>

<h1> Voting Summary </h1>
<!--Menu-->
<ul class="nav nav-tabs">
  {% for menuItem in cfg["committee"] %}
    <li role="presentation"><a href="{{menuItem['link']}}">{{menuItem['title']}}</a></li>
  {% endfor %}
</ul>
<p></p>
<p style = "font-size: 150%; margin-bottom: 20px;">The table below shows the average of all committee members' votes.</p>
<div class = "row">
  <table class = "table table-striped table-hover table-sm">
    <tr>
      <th>Faculty/Proj. Title</th>
      <!--<th>Project Status</th>-->
      {% for title in cfg["voting"]%}
        <th style = "font-size: .6em;" 
        onmouseover = "changeSize('{{title['dbName']}}', '1.2em')"
        onmouseleave = "changeSize('{{title['dbName']}}', '.6em')"
        id = "{{title['dbName']}}">
          {{title["title"]}}
        </th>
      
      {% endfor %}
      <th>Total</th>
    </tr>
    {% if fac is not none %}
      {% for person in fac %}
        <tr id="row{{loop.index0}}" name = "leRow">
          <td>
            {{person.username.firstname}} {{person.username.lastname}} <span class = "small">({{person.programID.name}})</span>
            <br />
            <span class = "small">{{person.pID.title|truncate(50, True)}}</span>
          </td>
          <!--Loop for each project-->
          {% for vote in votes %}
            <!--Loop for each vote-->
            {% if vote is not none %}
        	    {% for result in vote %}
                <!--Check to see if current vote (result) is part of current project-->
                {% if result[0] == person.pID.pID %}
                  <!--Loop for each vote category-->
                  {% for field in cfg["voting"] %} 
                    <td name = "rowValue" class = "{{field['dbName']}} rowValue text-center" id="col{{loop.index0}}">
                      {{'%0.2f'| format(result[loop.index]|float)}}
                    </td>
                  {% endfor %}
                {% endif %}
              {% endfor %}
  	  {% endif %}
          {% endfor %}
          <th id = "average{{loop.index0}}">
          </th>
        </tr>
      
      {% endfor %}
    {% endif %}
  </table>
</div>

<script>

$(document).ready(function(){
     {% if fac is not none %}
    var numRows = {{fac|count}};
  {% endif %}
  function changeSize (ele, scale) {
      $("#"+ele).stop().animate({fontSize : scale});
    }
  }
});

</script>


{% endblock %}
