Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/templates/search.html
2017-05-07 00:21:16 +03:00

93 lignes
3,1 Kio
HTML

{% import "strconv" %}
{% code type searchField struct{
id, name string
} %}
Common seatch part of many pages
{% func SearchCommon(search SearchForm) %}
<select name="c" class="form-control input-sm" value>
<option value="_">All categories</option>
{%= searchOptions(search.Category, []searchField{
{"3_", "Anime"},
{"3_12", "Anime - Anime Music Video"},
{"3_5", "Anime - English-translated"},
{"3_13", "Anime - Non-English-translated"},
{"3_6", "Anime - Raw"},
{"2_", "Audio"},
{"2_3", "Audio - Lossless"},
{"2_4", "Audio - Lossy"},
{"4_", "Literature"},
{"4_7", "Literature - English-translated"},
{"4_8", "Literature - Raw"},
{"4_14", "Literature - Non-English-translated"},
{"5_", "Live Action"},
{"5_9", "Live Action - English-translated"},
{"5_10", "Live Action - Idol/Promotional Video"},
{"5_18", "Live Action - Non-English-translated"},
{"5_11", "Live Action - Raw"},
{"6_", "Pictures"},
{"6_15", "Pictures - Graphics"},
{"6_16", "Pictures - Photos"},
{"1_", "Software"},
{"1_1", "Software - Applications"},
{"1_2", "Software - Games"},
}) %}
</select>
<select name="s" class="form-control input-sm">
<option value="">Show all</option>
{%= searchOptions(search.Status, []searchField{
{"2", "Filter Remakes"},
{"3", "Trusted"},
{"4", "A+"},
}) %}
</select>
{% endfunc %}
Options fields of a search <select> element
{% func searchOptions(selected string, s []searchField) %}
{% for _, s := range s %}
{%= searchOption(selected, s) %}
{% endfor %}
{% endfunc %}
Single search optiion field of a <select>
{% func searchOption(selected string, s searchField) %}
<option value="{%s= s.id %}" {% if selected == s.id %}selected{% endif %}>{%s= s.name %}</option>
{% endfunc %}
{% func SearchAdvanced(nav Navigation, search SearchForm) %}
<select name="sort" class="form-control input-sm">
{%= searchOptions(search.Sort, []searchField{
{"torrent_id", "ID"},
{"torrent_name", "Name"},
{"date", "Date"},
{"downloads", "Downloads"},
}) %}
</select>
<select name="order" class="form-control input-sm">
{%= searchOptions(search.Order, []searchField{
{"desc", "Descending"},
{"asc", "Ascending"},
}) %}
</select>
<select name="max" class="form-control input-sm">
{% code sel := strconv.Itoa(nav.MaxItemPerPage) %}
{% for _, m := range [...]int{5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 70, 100, 150, 200, 300} %}
{% code id := strconv.Itoa(m) %}
{%= searchOption(sel, searchField{id, id}) %}
{% endfor %}
</select>
{% endfunc %}
{% func SearchButton(search SearchForm) %}
<div class="input-group">
<input name="q" class="form-control input-sm" placeholder="Search" type="text" value="{%s search.Query %}">
<span class="input-group-btn">
<button type="submit" class="btn btn-sm btn-success">
<span class="glyphicon glyphicon-search" aria-hidden="true"></span>
Search
</button>
</span>
</div>
{% endfunc %}