{% if versions %}
<div style="padding-top: 36px">
  <h3>Versions</h3>

  <select id="versions">
    {% if versions.tags %}
      <optgroup label="Releases">
        {% for name, url in versions.tags %}
          <option value="{{ url }}" {% if name == current_version %}selected{% endif %}>{{ name }}</option>
        {% endfor %}
      </optgroup>
    {% endif %}

    {% if versions.branches %}
      <optgroup label="Branches">
        {% for name, url in versions.branches %}
          <option value="{{ url }}" {% if name == current_version %}selected{% endif %}>{{ name }}</option>
        {% endfor %}
      </optgroup>
    {% endif %}
  </select>

  <script>
    var versionsEl = document.querySelector("#versions");
    versionsEl.addEventListener('change', function(e) {
      window.location.href = e.target.value;
    });
  </script>
</div>
{% endif %}
