{% extends "base.html" %}

{% block content %}

<div class="row">
  <div class="col m-5">
    <a href="{{ url_for('main.index') }}" class="h1 text-left"> ⇽ </a>
    <p class="h1 text-center">a timeline of inventions</p>
  </div>
</div>

<div class="row p-3">
  <form action="{{ url_for('search.basic_search') }}" method="POST">
    <input type="hidden" name="search" value="{{ search }}">
    <input type="hidden" name="searchopt" value="{{ core }}">
    sort by:
    <select name="sort" id="sort" onchange="this.form.submit()">
      <option value="relevance" {% if sort == 'relevance' %} selected {% endif %}>relevance</option>
      <option value="year desc" {% if sort == 'year desc' %} selected {% endif %}>year descending</option>
      <option value="year asc" {% if sort == 'year asc' %} selected {% endif %}>year ascending</option>
    </select>
    <noscript>
      <input type="submit" class="btn btn-default" value="Set" />
    </noscript>
  </form>
</div>

{% if results == 'no results found' %}

  {{ results }}

{% else %}

  {% for result in results %}

    <p class="h1">

    Year:

    {{ result['year'] }}

    </p>

    {% if result['title'] is defined %}
    <p class="mb-2 mt-5">
      <span class="emphasis">Title:</span>
      <span class="result-entry">
        {{ result['title'] }}
      </span>
    </p>
    {% endif %}

    {% if result['abstract'] is defined %}
    <p class="mb-2">
      <span class="emphasis">Abstract:</span>
      <span class="result-entry">
        {{ result['abstract'] }}
      </span>
    </p>
    {% endif %}

    <div class="mt-2 mb-5 search-links">
      <p>
        <span class="emphasis">European Patent Office PDF:</span>
        <a href="{{ url_for('search.id_search', id=result['id'], core='all') }}">
          <span class="result-entry">
            {{ result['application_id'] }}
          </span>
        </a>
      </p>
    </div>

  {% endfor %}

{% endif %}

<script type="text/javascript">
  highlightSearchTerms({{ search|tojson}})
</script>

{% endblock %}
