{% extends "layout.html" %}
{% block headers %}
<script>
var categories = "{% for item in subcategories: %}{{item.id}}{{ ',' if not loop.last else '' }}{% endfor %}";
</script>
<script src="/static/js/jquery-3.6.0.min.js"></script>
<script src="/static/js/ranking.js"></script>
<style>
.tile-item {
    display: inline-block;
    margin: 0pt 10pt 10pt 0pt;
    padding: 10pt;
    width: 135pt;
    border-radius: 10pt;
    cursor: pointer;
    background: #f9f9f9;
}
.tile-item:hover { background: #eeeeee; }
.tile-item:active { background: #e9e9e9; }
.tile-title {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
    overflow: hidden;
    max-width: 150pt;
    height: 4em;
    font-size: 1.3em;
    font-weight: bold;
}
.tile-preview {
    overflow: hidden;
    width: 100%;
    height: 130pt;
    margin: 0 auto;
    user-select: none;
}
.tile-title a:hover { color: #df7e0e; }
.tabs ul { margin: 0em; padding: 0em; }
.tabs li {
    display: inline-block;
    list-style-type: none;
    text-decoration: none;
    color: #000000;
    font-size: 12pt;
    padding: .5em .75em .5em .75em;
    margin: 0pt 5pt 0pt 0pt;
    user-select: none;
    border-radius: .5em .5em 0em 0em;
}
.tabs li.active { background: #f49120; }
.tabs li.active a { color: #ffffff; text-decoration: none; }
#top-datasets th { text-align: left; white-space: nowrap; color: #ffffff; padding: .5em; }
#top-datasets-wrapper table { width: 100%; max-width: 880pt; border: solid 2pt #f49120; }
#top-datasets thead tr { background: #f49120; }
#top-datasets tbody tr td { padding: .5em; z-index: 50; }
#top-datasets tbody tr:nth-child(odd) { background: #fafafa; }
#top-datasets tbody tr td:last-child { text-align: right; width: 130pt; }
#top-datasets thead tr th:last-child { text-align: right; }
#top-datasets tbody tr td:nth-child(1) {
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    max-width: 750pt;
}
#top-datasets td { text-align: left; }
</style>
{% endblock %}
{% block body %}
<h1>{{category.title}}</h1>
<noscript>
  <p class="no-script">Sorry, the top datasets and latest datasets require JavaScript.</p>
</noscript>

<h2>Top datasets</h2>
<div id="top-buttons" class="tabs">
  <ul>
    <li class="top-downloads"><a href="#" onclick="top_datasets('downloads'); return false">Downloads</a></li>
    <li class="top-views"><a href="#" onclick="top_datasets('views'); return false">Views</a></li>
    <li class="top-shares"><a href="#" onclick="top_datasets('shares'); return false">Shares</a></li>
    <li class="top-cites"><a href="#" onclick="top_datasets('cites'); return false">Citations</a></li>
  </ul>
</div>
<div id="top-datasets-wrapper">
  <table id="top-datasets">
    <thead>
      <tr><th>Dataset</th><th></th></tr>
    </thead>
    <tbody>
      <tr><td colspan="2">&nbsp;</td></tr>
      <tr><td colspan="2">&nbsp;</td></tr>
      <tr><td colspan="2">&nbsp;</td></tr>
      <tr><td colspan="2">&nbsp;</td></tr>
      <tr><td colspan="2">&nbsp;</td></tr>
      <tr><td colspan="2">&nbsp;</td></tr>
      <tr><td colspan="2">&nbsp;</td></tr>
      <tr><td colspan="2">&nbsp;</td></tr>
      <tr><td colspan="2">&nbsp;</td></tr>
    </tbody>
  </table>
</div>

<h2>Latest datasets</h2>
<div id="latest-datasets-loader" class="loader"></div>
<div id="latest-datasets"></div>

<h2>Collections</h2>
{% for item in collections %}
<div class="tile-item">
  <a href="/collections/{{item.container_uuid}}">{% if item.thumb | length: %}
  <img class="tile-preview" src="{{item.thumb}}" aria-hidden="true" alt="thumbnail for {{item.container_uuid}}" />
  {% else: %}
  <img class="tile-preview" src="/static/images/collection-thumb.svg" aria-hidden="true" alt="thumbnail for {{item.container_uuid}}" />
  {% endif %}</a>
  <div class="tile-title"><a href="/collections/{{item.container_uuid}}">{{item.title}}</a></div>
  <div class="tile-date">Posted on {{item.timeline_posted | truncate(10,False,'')}}</div>
  <div class="tile-authors">
  </div>
</div>
{% endfor %}

<h2>All datasets</h2>
{% for item in articles %}
<div class="tile-item">
  <a href="/datasets/{{item.container_uuid}}">{% if item.thumb | length: %}
  <img class="tile-preview" src="{{item.thumb}}" aria-hidden="true" alt="thumbnail for {{item.container_uuid}}" />
  {% else: %}
  <img class="tile-preview" src="/static/images/dataset-thumb.svg" aria-hidden="true" alt="thumbnail for {{item.container_uuid}}" />
  {% endif %}</a>
  <div class="tile-title"><a href="/datasets/{{item.container_uuid}}">{{item.title}}</a></div>
  <div class="tile-date">Posted on {{item.timeline_posted | truncate(10,False,'')}}</div>
  <div class="tile-authors">
  </div>
</div>
{% endfor %}
{% endblock %}
