<table class="table table-striped table-hover table-sm" id="torrents-table">
  <thead class="thead-dark">
    <tr>
      <th>
        <!-- magnet, torrent, peers -->
      </th>
      <th onClick="sortTbody(this, 'torrents-tbody', sortStr)">version</th>
      <th onClick="sortTbody(this, 'torrents-tbody', sortStr)">name</th>
      <th onClick="sortTbody(this, 'torrents-tbody', sortStr)">info hash</th>
      <th onClick="sortTbody(this, 'torrents-tbody', sortByte)">size</th>
      <th onClick="sortTbody(this, 'torrents-tbody', sortInt)">seeders</th>
      <th onClick="sortTbody(this, 'torrents-tbody', sortInt)">leechers</th>
      <th onClick="sortTbody(this, 'torrents-tbody', sortInt)">completed</th>
    </tr>
  </thead>

  <tbody id="torrents-tbody">

    {{*torrents}}
    <tr>
      <td>
        <a href="magnet:?xt=urn:{{magnet_key}}&amp;dn={{name|u}}{{*tracker_udp}}&amp;tr={{tracker_udp|u}}{{/tracker_udp}}&amp;tr={{tracker_http|u}}"
          title="Magnet link">
          <img src="/img/magnet-icon.gif" />
        </a>
        {{*show_torrent}}
        <a href="/file/{{name|u}}.torrent?info_hash={{info_hash|b16}}" title="Torrent">
          <img src="/img/torrent-icon.png" />
        </a>
        {{/show_torrent}}
        {{*show_peers}}
        <a href="/peers?info_hash={{info_hash|b16}}" title="List peers">
          <img src="/img/peers.png" />
        </a>
        {{/show_peers}}
      </td>
      <td>{{version}}</td>
      <td>{{name}}</td>
      <td>{{info_hash|b16}}</td>
      <td>{{length}}</td>
      <td>{{seeders}}</td>
      <td>{{leechers}}</td>
      <td>{{completed}}</td>
    </tr>
    {{/torrents}}

  </tbody>

  <tfoot>
    <tr>
      <td colspan="4" style="text-align: right;"><strong>Total</strong></td>
      <td>{{total_length}}</td>
      <td>{{total_seeders}}</td>
      <td>{{total_leechers}}</td>
      <td>{{total_completed}}</td>
    </tr>
  </tfoot>
</table>

<!-- sort torrents by name -->
<script language="javascript">
  sortTbody2(document.getElementById('torrents-tbody'), 2, sortStr)
</script>