{% extends "base.html" %}

{% block content %}

    {% block header %}
        <div class="span-20"><h1>{{ dir_name }}</h1></div> 
        <div class="span-1"><h1><a href="{% if static_html %}{{ base_path }}{% else %}/{{ db_name }}{% endif %}/{{ release_title }}/{{ st_test }}/{% if args %}{{ file_id }}/{% endif %}{% for arg in args %}{% if not loop.last %}{{ arg }}/{% endif %}{% endfor %}{% if threshold %}?threshold={{ threshold }}{% endif %}">..</a></h1></div>
        <div class="span-3 last"><img width="54" hight="54" class="top right"
            src="http://cms-service-reldqm.web.cern.ch/cms-service-reldqm/style/CMS.gif"></div>
        <hr>
        {% if parent_name %}
        <h2 class="alt">{{ parent_name }}</h2>
        <hr>
        {% endif %}
    {% endblock %}

    {% block directory_summary %}
    <div class="span-8"><h3>Summary</h3><p>
        <span class="caps alt">{{ total }} comparisons:</span></p>
        <ul>
            <li><span class="caps">Success: {{ success }}% ({{ successes }})</span></li>
            <li><span class="caps">Null: {{ null }}% ({{ nulls }})</span></li>
            <li><span class="caps">Fail: {{ fail }}% ({{ fails }})</span></li>
        </ul>
        <a href="http://cmsweb.cern.ch/dqm/relval/start?runnr={{run1}};dataset=/{{sample1}}/{{release1}}/DQMIO;sampletype=offline_data;filter=all;referencepos=on-side;referenceshow=all;referencenorm=True;referenceobj1=other:{{run2}}:/{{sample2}}/{{release2}}/DQMIO:;referenceobj2=none;referenceobj3=none;referenceobj4=none;search=;striptype=object;stripruns=;stripaxis=run;stripomit=none;workspace=Everything;size=M;focus=;zoom=no;">To the DQM GUI...</a>
    </div>
    <div class="span-5 colborder">
        <img class="top right" src="https://chart.googleapis.com/chart?cht=p3&amp;chco=00FF00|FFFF00|FF0000&amp;chs=200x200&amp;chd=t:{{ success }},{{ null }},{{ fail }}">
    </div>
    <div class="span-9 last">
        <h3>Releases:</h3>
            <ul>
                <li><p>{{ release1 }}</p></li>
                <li><p>{{ release2 }}</p></li>
           </ul>
           <h3>Statistical Test (Pvalue threshold):</h3>
           <p><ul><li>
               <div class="caps" style="display: inline-block;width: 100px;">{{ st_test }} (<label id="threshold"></label>)</div>{% if not static_html %}
               <span id="slider" class='ui-slider ui-widget ui-widget-content ui-corner-all'></span>
               <input type="button" class="defaultbtn" value="Default" title="">
             {% endif %}
           </li></ul></p>
    </div>
    <hr>
    {% endblock %}

    {% block subdirectories %}
        {% if subdirs %}
          <div class="span-20 colborder">
            <h2 class="alt">Sub-Directories</h2>
        {% for name, total, successes, nulls, fails, success, null, fail in subdirs %}
        <div class="span-4 prepend-2 colborder"><h3>{{ name }}</h3></div>
        <div class="span-7"><p><span class="caps alt">{{ total }} comparisons:</span></p>
            <ul>
                {% if successes %}
                <li><span class="caps">Success: {{ success }}% ({{ successes }})</span></li>
                {% endif %}
                {% if nulls %}
                <li><span class="caps">Null: {{ null }}% ({{ nulls }})</span></li>
                {% endif %}
                {% if fails %}
                <li><span class="caps">Fail: {{ fail }}% ({{ fails }})</span></li>
                {% endif %}
            </ul>
        </div>
        <div class="span-6 last"><a href="{{ file_id }}/{% if static_html %}{% endif %}{{ name }}{% if static_html %}.html{% endif %}{% if threshold
                %}?threshold={{ threshold }}{% endif %}"><img class="top right"
                src="https://chart.googleapis.com/chart?cht=p3&amp;chco=00FF00|FFFF00|FF0000&amp;chs=150x100&amp;chd=t:{{ success }},{{ null }},{{ fail }}"></a>
        </div>
        <hr>
        {% endfor %}
          </div>
        {% endif %}
    {% endblock %}


    {% block failed_comparisons %}
    {% if failed_histos %}
        <div class="span-20"><h2 class="alt">Failing Comparisons</h2></div>
    {% endif %}
    {% for name, p_value, url1, url2, overlay in failed_histos %}
    <div class="span-6  colborder {% if loop.index is divisibleby 3 %}last{% endif %}"><p>{{ name }}</p>
            <p class="alt">Chi2: {{ p_value }}</p>
            <div><a href="{{ url1 }}" class="black_link">{{ release1 }}</a></div>
            <div><a href="{{ url2 }}">{{ release2 }}</a></div>
            <a href="{{ overlay }}"><img class="top center fail" src="{{ overlay }}"></a>
        </div>
    {% endfor %}
    {% if failed_histos %}
    <hr>
    {% endif %}
    {% endblock %}

    {% block successful_comparisons %}
    {% if successful_histos %}
        <div class="span-20"><h2 class="alt">Successful Comparisons</h2></div>
    {% for name, p_value, url1, url2, overlay in successful_histos %}
        <div class="span-6  colborder {% if loop.index is divisibleby 3 %}last{% endif %}"><p>{{ name }}</p>
            <p class="alt">Chi2: {{ p_value }}</p>
            <div><a href="{{ url1 }}" class="black_link">{{ release1 }}</a></div>
            <div><a href="{{ url2 }}">{{ release2 }}</a></div>
            <a href="{{ overlay }}"><img class="top center succes" src="{{ overlay }}"></a>
        </div>
    {% endfor %}
    <hr>
    {% endif %}
    {% endblock %}

    {% block null_comparisons %}
    {% if null_histos %}
        <div class="span-20"><h2 class="alt">Null Comparisons</h2></div>
        {% for name, p_value, url1, url2, overlay in null_histos %}
            <div class="span-6  colborder {% if loop.index is divisibleby 3 %}last{% endif %}"><p>{{ name }}</p>
                <p class="alt">Chi2: {{ p_value }}</p>
                <div><a href="{{ url1 }}" class="black_link">{{ release1 }}</a></div>
                <div><a href="{{ url2 }}">{{ release2 }}</a></div>
                <a href="{{ overlay }}"><img class="top center null" src="{{ overlay }}"></a>
            </div>
        {% endfor %}
        <hr>
    {% endif %}
    {% endblock %}

    {% block ranks_summary %}
    {# Only if directory is RootFileComparison directory #}
    {% endblock %}

{% endblock %}
