{% extends "base.html" %}

{% block script %}
var cset = function(section, option, el) {
  value = el.value;
  window.qute.set(section, option, value);
}
{% endblock %}

{% block style %}
table { border: 1px solid grey; border-collapse: collapse; }
pre { margin: 2px; }
th, td { border: 1px solid grey; padding: 0px 5px; }
th { background: lightgrey; }
th pre { color: grey; text-align: left; }
.noscript, .noscript-text { color:red; }
.noscript-text { margin-bottom: 5cm; }
.option_description { margin: .5ex 0; color: grey; font-size: 80%; font-style: italic; white-space: pre-line; }
{% endblock %}

{% block content %}
<noscript><h1 class="noscript">View Only</h1><p class="noscript-text">Changing settings requires javascript to be enabled!</p></noscript>
<header><h1>{{ title }}</h1></header>
<table>
{% for section in config.DATA %}
  <tr><th colspan="2"><h3>{{ section }}</h3><pre>{{ config.SECTION_DESC.get(section)|wordwrap(width=120) }}</pre></th></tr>
  {% for d, e in config.DATA.get(section).items() %}
    <tr>
      <td>{{ d }} (Current: {{ confget(section, d)|truncate(100) }})
        {% if config.DATA.get(section).descriptions[d] %}
          <p class="option_description">{{ config.DATA.get(section).descriptions[d]|e }}</p>
        {% endif %}
      </td>
      <td>
        <input type="text"
          onblur="cset('{{ section }}', '{{ d }}', this)"
          value="{{ confget(section, d) }}">
        </input>
      </td>
    </tr>
  {% endfor %}
{% endfor %}
</table>

{% endblock %}
