<html>
  <head>
    <title>{{ fhdhr.config.dict["fhdhr"]["friendlyname"] }}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
      table, th, td {border: 1px solid black;}
    </style>
    <link href="style.css" rel="stylesheet">
  </head>
    <body>
      <h1 style="text-align: center;">
        <span style="text-decoration: underline;"><strong><em>{{ fhdhr.config.dict["fhdhr"]["friendlyname"] }}</em></strong>
        </span>
        <img class="pull-left" src="/favicon.ico" alt="fHDHR Logo" width="100" height="100">
      </h1>
      <br><br>
      <p></p>
      <div>

      <button class="pull-left" onclick="OpenLink('/index')">fHDHR</a></button>

      <button class="pull-left" onclick="OpenLink('/origin')">{{ fhdhr.config.dict["main"]["servicename"] }}</a></button>

      <button class="pull-left" onclick="OpenLink('/channels')">Channels</a></button>

      <button class="pull-left" onclick="OpenLink('/guide')">Guide</a></button>

      <button class="pull-left" onclick="OpenLink('/cluster')">Cluster/SSDP</a></button>

      <button class="pull-left" onclick="OpenLink('/tuners')">Tuners</a></button>

      <button class="pull-left" onclick="OpenLink('/xmltv')">xmltv</a></button>

      {% if fhdhr.config.dict["web_ui"]["advanced"] %}
        <button class="pull-left" onclick="OpenLink('/version')">Version</a></button>
      {% endif %}

      {% if fhdhr.config.dict["web_ui"]["advanced"] %}
        <button class="pull-left" onclick="OpenLink('/diagnostics')">Diagnostics</a></button>
      {% endif %}

      <button class="pull-left" onclick="OpenLink('/settings')">Settings</a></button>

      <a class="pull-right" style="padding: 5px;" href="/api/xmltv?method=get&source={{ fhdhr.device.epg.def_method }}">xmltv</a>
      <a class="pull-right" style="padding: 5px;" href="/api/m3u?method=get&channel=all">m3u</a>
      <form  class="pull-right" style="padding: 5px;"  method="post" action="/api/settings?method=update&redirect={{ request.path }}">
        <input type="hidden" name="config_section" value="web_ui">
        <input type="hidden" name="config_name" value="advanced">
        {% if fhdhr.config.dict["web_ui"]["advanced"] %}
          <input type="hidden" name="config_value" value=False>
        {% else %}
          <input type="hidden" name="config_value" value=True>
        {% endif %}
        <input type="hidden" name="config_default" value=False>
        {% if fhdhr.config.dict["web_ui"]["advanced"] %}
          <a data-th="Reset"><input type="submit" value="Basic"></a>
        {% else %}
          <a data-th="Reset"><input type="submit" value="Advanced"></a>
        {% endif %}
      </form>

      </div>
      <hr align="center" width="100%">

      {% if fhdhr.config.dict["web_ui"]["cluster_bar"] %}
        {% set locations = fhdhr.device.cluster.get_cluster_dicts_web() %}
        {% if locations %}
          <div>
          {% for location in locations %}
              <button class="pull-left" onclick="OpenLink('{{ location["base_url"] }}')">{{ location["name"] }}</a></button>
          {% endfor %}
          </div>
          <hr align="center" width="100%">
        {% endif %}
      {% endif %}

      {% set retmessage = request.args.get('retmessage', default=None) %}
      {% if retmessage %}
        <p>{{ retmessage }}</p>
      {% endif %}

      {% block content %}{% endblock %}
    </body>
</html>
<script>
  function OpenLink(NewURL) {window.open(NewURL, "_self");}
</script>
