{% extends "base.html" %}
{% block introduction %}
{% if msgs.lede %}
  <div class="hatnote">
    🔗 <a href="/id/{{abif_id}}">{{abif_id}}</a> &nbsp; &nbsp;
    (tags: { {% for t in msgs.taglist %}
    <a href="/tag/{{t}}">{{t}}</a>
    {% if not loop.last %}, {% endif %}
    {% endfor %})
  </div>
<p>{{ msgs.lede | safe }}</p>
{% else %}
<p>Your .abif has been processed.  See <a href="#results">results below</a></p>
{% endif %}
{% endblock introduction %}
{% block content %}
{% set all_results_generated = (result_types|length == 5) %}
{% include 'abifbox-snippet.html' %}
<h2 id="results">{{ webenv.statusStr }}Results</h2>
{% if abif_id %}
{% set pathpart="/id/" + abif_id  %}
{% set abslink=webenv.base_url + pathpart %}
<div class="hatnote">🔗<a href="{{abslink}}">{{abslink}}</a></div>
{% endif %}
{% if msgs.results_name %}
<p>The {{msgs.results_name}} of {{abif_id}} are below,
and can be edited in the field above.</p>
{% elif msgs.results_lede %}
{# msgs.results_lede is DEPRECATED as of 2024-06-19 #}
<p>{{ msgs.results_lede | safe }}</p>
{% else %}
<p>Below are various abiftool output blocks for the ABIF above.
  {% endif %}
  <ul>
    {% if 'dot' in result_types %}
    <li><a href="#dot">Pairwise diagram</a> &mdash; Winner: {{copewinnerstring}}</li>
    {% endif %}
    {% if 'wlt' in result_types %}
    <li>
      <a href="#wlt">Win-loss-tie table</a> &mdash; Winner: {{copewinnerstring}}
    </li>
    {% endif %}
    {% if 'FPTP' in result_types %}
    <li>
      <a href="#FPTP">FPTP output</a> &mdash;
      {{ "Winners (tie):" if resblob['FPTP_result']['winners'] | length > 1 else "Winner:" }}
      {{resblob['FPTP_result']['winners'][0]}}
    </li>
    {% endif %}
    {% if 'IRV' in result_types %}
    <li>
      <a href="#IRV">IRV output</a> &mdash;
      {{ "Winners (tie):" if IRV_dict['winner'] | length > 1 else "Winner:" }}
      {{IRV_dict['winnerstr']}}
    </li>
    {% endif %}
    {% if 'STAR' in result_types %}
    <li>
      <a href="#STAR">STAR output</a> &mdash; Winner: {{ scorestardict['scoremodel']['winner'] }}
    </li>
    {% endif %}
    {% if abif_id and not all_results_generated %}
    <li>Generate other results for {{abif_id}}:</li>
    <ul>
      {% if not 'dot' in result_types %}
      <li>
        <a href="/id/{{abif_id}}/dot#dot">Pairwise diagram for {{abif_id}}</a>
      </li>
      {% endif %}
      {% if not 'wlt' in result_types %}
      <li>
        <a href="/id/{{abif_id}}/wlt#wlt">Win-loss-tie table for {{abif_id}}</a>
      </li>
      {% endif %}
      {% if not 'FPTP' in result_types %}
      <li>
        <a href="/id/{{abif_id}}/FPTP#FPTP">FPTP results for {{abif_id}}</a>
      </li>
      {% endif %}
      {% if not 'IRV' in result_types %}
      <li>
        <a href="/id/{{abif_id}}/IRV#IRV">IRV table for {{abif_id}}</a>
      </li>
      {% endif %}
      {% if not 'STAR' in result_types %}
      <li>
        <a href="/id/{{abif_id}}/STAR#STAR">STAR results for {{abif_id}}</a>
      </li>
      {% endif %}
    </ul>
    <li><a href="/id/{{abif_id}}/all">Generate all results for {{abif_id}}</a></li>
    {% endif %}
  </ul>
</p>
{############ dot ############}
{% set restype="dot" %}
{% set rellink=restype + "#" + restype %}
{% if 'dot' in result_types and dotsvg_html %}
<h3><a name="{{restype}}"></a>Pairwise diagram</h3>
{% if abif_id %}
{% set pathpart="/id/" + abif_id + "/" + rellink %}
{% set abslink=webenv.base_url + pathpart %}
<div class="hatnote">
  {{abif_id}} pairwise diagram permalink:<br>
  🔗<a href="{{abslink}}">{{abslink}}</a>
</div>
<p><a href="/id/{{abif_id}}/dot/svg">{{ dotsvg_html | safe }}</a></p>
{% else %}
<p>{{ dotsvg_html | safe }}</p>
{% endif %}
{% endif %}
{############ wlt ############}
{% set restype="wlt" %}
{% set rellink=restype + "#" + restype %}
{% if 'wlt' in result_types and pairwise_html %}
<h3><a name="{{restype}}"></a>Win-loss-tie table</h3>
{% if abif_id %}
{% set pathpart="/id/" + abif_id + "/" + rellink %}
{% set abslink=webenv.base_url + pathpart %}
<div class="hatnote">
  {{abif_id}} w-l-t table permalink:<br>
  🔗<a href="{{abslink}}">{{abslink}}</a>
</div>
{% endif %}
<p><b>Pairwise winner(s)</b>: {{copewinnerstring}}</p>
<div class="scaletable">
  {{ pairwise_html | safe }}
</div>
{% endif %}
{############ FPTP ############}
{% set restype="FPTP" %}
{% set rellink=restype + "#" + restype %}
{#{% if 'FPTP' in result_types and resblob['FPTP_result'] %}#}
{% if 'FPTP' in result_types %}

<h3><a name="{{restype}}"></a>FPTP result</h3>
{% if abif_id %}
{% set pathpart="/id/" + abif_id + "/" + rellink %}
{% set abslink=webenv.base_url + pathpart %}
<div class="hatnote">
  "FPTP" is "First-past-the-post", also known as "plurality" or "choose-one"<br>
  {{abif_id}} FPTP results permalink:<br>
  🔗<a href="{{abslink}}">{{abslink}}</a><br>
</div>
{% endif %}
<p>{% include 'fptp-snippet.html' %}</p>
{% endif %}
{############ IRV ############}
{% set restype="IRV" %}
{% set rellink=restype + "#" + restype %}
{% if 'IRV' in result_types and IRV_dict %}
<h3><a name="{{restype}}"></a>IRV/RCV results</h3>
{% if abif_id %}
{% set pathpart="/id/" + abif_id + "/" + rellink %}
{% set abslink=webenv.base_url + pathpart %}
<div class="hatnote">
  {{abif_id}} IRV/RCV result permalink:<br>
  🔗<a href="{{abslink}}">{{abslink}}</a>
</div>
{% endif %}
<p>{% include 'irv-snippet.html' %}</p>
{% endif %}
{############ STAR ############}
{% set restype="STAR" %}
{% set rellink=restype + "#" + restype %}
{% if 'STAR' in result_types and STAR_html %}
<h3><a name="{{restype}}"></a>STAR results</h3>
{% if abif_id %}
{% set pathpart="/id/" + abif_id + "/" + rellink %}
{% set abslink=webenv.base_url + pathpart %}
<div class="hatnote">
  {{abif_id}} STAR results permalink:<br>
  🔗<a href="{{abslink}}">{{abslink}}</a>
</div>
{% endif %}
{% if scorestardict['star_lede'] %}
<p class="description">
   {{ scorestardict['star_lede'] }}
</p>
{% endif %}
<p>{% include 'star-snippet.html' %}</p>
{% if scorestardict['star_foot'] %}
<p class="description">
  {{ scorestardict['star_foot'] }}
</p>
{% endif %}
{% endif %}
<p>(<a href="/">homepage</a>)</p>
{% endblock content %}
