{{template "layout.html" .}}

{{define "title"}}Historical Figures{{end}}

{{define "content"}}
<h3>Historical Figures</h3>

{{ json .Params }}

<div class="row">
    <div class="col-md-10">
        <table class="table table-hover table-sm table-borderless object-table">
            <tr>
                <th>Name</th>
                <th>Race</th>
                <th>Lived</th>
                <th>Kills</th>
            </tr>
            {{- range .Hfs }}{{- if not (eq .Name "") }}
            <tr>
                <td><a class="hf" href="/hf/{{.Id}}">{{ title .Name }}</a></td>
                <td>{{ .Race }}</td>
                <td>
                    {{- if eq .DeathYear -1 }}
                    from {{ .BirthYear }} till now
                    {{- else }}
                    from {{ .BirthYear }} till {{ .DeathYear }}
                    {{- end }}
                </td>
                <td>{{ len .Kills }}</td>
            </tr>
            {{- end}}{{- end}}
        </table>
    </div>
    <div class="col-md-2">
        <h5>Filter</h5>
        <form action="/hfs" method="GET">
            <div class="checkbox"><label><input class="filter" type="checkbox" name="leader" value="1" {{if eq .Params.leader "1"
                        }}checked{{end}}> Leader</label></div>
            <div class="checkbox"><label><input class="filter" type="checkbox" name="deity" value="1" {{if eq .Params.deity "1"
                        }}checked{{end}}> Deity</label></div>
            <div class="checkbox"><label><input class="filter" type="checkbox" name="force" value="1" {{if eq .Params.force "1"
                        }}checked{{end}}> Force</label></div>
            <div class="checkbox"><label><input class="filter" type="checkbox" name="vampire" value="1" {{if eq .Params.vampire "1"
                        }}checked{{end}}> Vampire</label></div>
            <div class="checkbox"><label><input class="filter" type="checkbox" name="werebeast" value="1" {{if eq .Params.werebeast "1"
                        }}checked{{end}}> Werebeast</label></div>
            <div class="checkbox"><label><input class="filter" type="checkbox" name="necromancer" value="1" {{if eq .Params.necromancer "1"
                        }}checked{{end}}> Necromancer</label></div>
            <div class="checkbox"><label><input class="filter" type="checkbox" name="alive" value="1" {{if eq .Params.alive "1"
                        }}checked{{end}}> Alive</label></div>
            <div class="checkbox"><label><input class="filter" type="checkbox" name="ghost" value="1" {{if eq .Params.ghost "1"
                        }}checked{{end}}> Ghost</label></div>
            <div class="checkbox"><label><input class="filter" type="checkbox" name="adventurer" value="1" {{if eq .Params.adventurer "1"
                        }}checked{{end}}> Adventurer</label></div>
            <div class="select form-group mt-1 mb-3">
                <select class="form-control" name="race">
                    <option class="text-muted" value="">Race</option>
                    {{- range world.Races -}}
                    <option value="{{ . }}" {{if eq $.Params.race . }}selected{{end}}>{{ . }}</option>
                    {{- end -}}
                </select>
            </div>
            <h4>Sorting</h4>
            <div class="select form-group">
                <select class="form-control" name="sort">
                    <option value="">Default</option>
                    <option value="name" {{if eq .Params.sort "name" }}selected{{end}}>Name</option>
                    <option value="race" {{if eq .Params.sort "race" }}selected{{end}}>Race</option>
                    <option value="birth" {{if eq .Params.sort "birth" }}selected{{end}}>Birth</option>
                    <option value="death" {{if eq .Params.sort "death" }}selected{{end}}>Death</option>
                    <option value="kills" {{if eq .Params.sort "kills" }}selected{{end}}>Kills</option>
                </select>
            </div>
            <button type="submit" class="btn btn-primary mt-4">Refresh</button>
        </form>
    </div>
</div>
{{- end }}