{% extends "layout.html" %}
{% set d = s.row %}
{% block title %}Summary{% endblock %}
{% block bar1 %}
SUMMARY
{% endblock %}
{% block content %}
{% if not open_ase_gui %}
    <script src="{{ url_for('static', filename='jsmol/JSmol.min.js') }}">
    </script>
    <script>
    Jmol._isAsync = false;
    var jmolApplet0;
    jmol_isReady = function(applet) {
        Jmol._getElement(applet, "appletdiv").style.border="1px solid black";
        Jmol.script(jmolApplet0, "load /cif/{{ d.id }}.cif;");
    }

    var Info = {
        width: 400,
        height: 400,
        debug: false,
        color: "0xFFFFFF",
        addSelectionOptions: false,
        use: "HTML5",   // JAVA HTML5 WEBGL are all options
        j2sPath: "/static/jsmol/j2s", // XXX how coded for now.
        //serverURL: "http://chemapps.stolaf.edu/jmol/jsmol/php/jsmol.php",
        readyFunction: jmol_isReady,
        disableJ2SLoadMonitor: true,
        disableInitialConsole: true,
        allowJavaScript: false
    };

    function repeatCell(repeat) {
        if (repeat == 2) {
            Jmol.script(jmolApplet0, 'load "" {2 2 2}');
        } else {
            Jmol.script(jmolApplet0, 'load "" {1 1 1}');
        }
    }

    $(document).ready(function() {
    $("#appdiv").html(Jmol.getAppletHtml("jmolApplet0", Info))})
    </script>
{% endif %}
Download:
<a href="/xyz/{{ d.id }}">xyz</a>,
<a href="/sqlite/{{ d.id }}">db</a>,
<a href="/json/{{ d.id }}">json</a>
<br>
{% if d.numbers|length %}
    {% if open_ase_gui %}
        <a href="/gui/{{ d.id }}">
        <img src="/image/{{ d.id }}.png">
        </a>
    {% else %}
        <div id="appdiv"></div>
        Unitcell: <button onclick="repeatCell(1)"> Single </button>
                  <button onclick="repeatCell(2)"> 2x2x2</button>

    {% endif %}
{% endif %}
<br>
<br>
{% for name in s.plots %}
<img src="/plot/{{ name }}-{{ d.id }}.png"><br>
{% endfor %}

<table>
<tr><th>name</th><th>unit</th><th>value</th></tr>
{% for name, unit, value in s.table %}
    <tr class={{ loop.cycle('even', 'odd') }}>
        <td> {{ name }} </td>
        <td> {{ unit }} </td>
        <td>{{ value|safe }}</td>
    </tr>
{% endfor %}
</table>
Unit cell in Ang:
<table>
<tr><th>axis</th><th>periodic</th><th>x</th><th>y</th><th>z</th></tr>
{% for axis in s.cell %}
<tr class={{ loop.cycle('even', 'odd') }}>
<td>{{ loop.index }}</td>
<td>{{ d.pbc[loop.index0] }}</td>
{% for a in axis %} <td class=right>{{ a }}</td>{% endfor %}</tr>
{% endfor %}
</table>

{% if s.key_value_pairs %}
Key-value pairs:
<table>
<tr><th>Key</th><th>Value</th></tr>
{% for key, value in s.key_value_pairs %}
<tr class={{ loop.cycle('even', 'odd') }}>
<td>{{ key }}</td><td>{{ value }}</td></tr>
{% endfor %}
</table>
{% endif %}

{% if s.forces %}
Forces in ev/Ang:
<table>
<tr><th>#</th><th>symbol</th><th>x</th><th>y</th><th>z</th></tr>
{% for f in s.forces %}
<tr class={{ loop.cycle('even', 'odd') }}>
<td>{{ f[0] }}</td><td>{{ f[1] }}</td>
<td class=right>{{ f[2] }}</td>
<td class=right>{{ f[3] }}</td>
<td class=right>{{ f[4] }}</td>
</tr>
{% endfor %}
</table>
{% endif %}

{% if s.stress %}
Stress tensor (xx, yy, zz, zy, zx, yx) in eV/Ang<sup>3</sup>:<br>
{{ s.stress }}
{% endif %}

{% if s.dipole %}
Dipole moment in e*Ang: ({{ s.dipole }})
{% endif %}

{% if s.constraints %}
Constraints: {{ s.constraints }}
{% endif %}

{% if s.data %}
Data keys: {{ s.data }}
{% endif %}

{% endblock content %}
