{% import "strconv" %}
{% code type searchField struct{
id, name string
} %}
Common seatch part of many pages
{% func SearchCommon(search SearchForm) %}
All categories
{%= 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"},
}) %}
Show all
{%= searchOptions(search.Status, []searchField{
{"2", "Filter Remakes"},
{"3", "Trusted"},
{"4", "A+"},
}) %}
{% endfunc %}
Options fields of a search element
{% func searchOptions(selected string, s []searchField) %}
{% for _, s := range s %}
{%= searchOption(selected, s) %}
{% endfor %}
{% endfunc %}
Single search optiion field of a
{% func searchOption(selected string, s searchField) %}
{%s= s.name %}
{% endfunc %}
{% func SearchAdvanced(nav Navigation, search SearchForm) %}
{%= searchOptions(search.Sort, []searchField{
{"torrent_id", "ID"},
{"torrent_name", "Name"},
{"date", "Date"},
{"downloads", "Downloads"},
{"filesize", "Size"},
}) %}
{%= searchOptions(search.Order, []searchField{
{"desc", "Descending"},
{"asc", "Ascending"},
}) %}
{% 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 %}
{% endfunc %}
{% func SearchButton(search SearchForm) %}
Search
{% endfunc %}