Files
hamann-ausgabe-core/HaWeb/Views/HKB/Dynamic/Suche.cshtml
2022-11-01 17:14:49 +01:00

91 lines
4.1 KiB
Plaintext

@model SucheViewModel;
@{
ViewData["Title"] = "Briefauswahl & Suche";
ViewData["SEODescription"] = "Johann Georg Hamann: Kommentierte Briefausgabe, Hg. v. Leonard Keidel und Janina Reibold. Durchsuchbare Online-Ausgabe der Briefe von und an Johann Georg Hamann.";
ViewData["showCredits"] = "true";
}
<div class="ha-search">
@if (Model.Letters != null) {
<div class="ha-searchhead">
<h1>Suche</h1>
@* Full-Text-Search *@
<div class="ha-searchfilter">
<div class="ha-filtertitle">
@if (Model.ActiveSearch != null) {
<a class="ha-reversefilter" asp-controller="Suche" asp-action="index">← Auswahl aufheben</a>
}
</div>
<form class="ha-searchform" id="ha-searchform" asp-controller="Suche" asp-action="Index" method="get">
<input id="ha-searchformtext" name="search" type="text" placeholder="Suchbegriff" value="@Model.ActiveSearch"/>
<button id="ha-searchformsubmit" type="submit">Suchen</button>
</form>
</div>
<script>
const ACTIVATESEARCHFILTER = function(filter, button) {
let f = filter.value;
if (f === "") {
button.disabled = true;
return;
}
button.disabled = false;
}
window.addEventListener("load", () => {
let searchfilter = document.getElementById("ha-searchformtext");
let searchsubmitbtn = document.getElementById("ha-searchformsubmit");
let searchform = document.getElementById("ha-searchform");
ACTIVATESEARCHFILTER(searchfilter, searchsubmitbtn);
searchfilter.addEventListener("input", () => ACTIVATESEARCHFILTER(searchfilter, searchsubmitbtn));
});
</script>
<div class="ha-searchnav">
@if (Model.AvailablePages != null && Model.AvailablePages.Any() && Model.AvailablePages.Count > 1) {
@for(var i = 0; i < Model.AvailablePages.Count; i++) {
<a class="@(Model.ActivePage == i ? "active" : "")" asp-route-search="@Model.ActiveSearch" asp-controller="Suche" asp-route-page="@i">
<span>
@Model.AvailablePages[i]
</span>
</a>
}
}
</div>
</div>
<div class="ha-searchbody">
<div class="ha-letterlist">
@* Letter Loop *@
@foreach (var year in Model.Letters) {
foreach (var letter in year.LetterList) {
<div class="ha-letterlistentry">
<a asp-controller="Briefe" asp-action="Index" asp-route-id="@letter.Meta.Autopsic">
@await Html.PartialAsync("/Views/Shared/_LetterHead.cshtml", (letter, true, false))
</a>
@if (Model.SearchResults != null && Model.SearchResults.ContainsKey(letter.Meta.Index)) {
<div class="ha-letterlistsearchresults">
@foreach (var sr in Model.SearchResults[letter.Meta.Index])
{
<a class="ha-letterlistsearchresult" asp-controller="Briefe" asp-action="Index" asp-route-id="@letter.Meta.Autopsic" asp-fragment="@sr.Page-@sr.Line">
<div class="ha-searchresultlocation caps-allpetite">
HKB @sr.Page/@sr.Line</div><div class="ha-searchresultpreview">@sr.Preview
</div>
</a>
}
</div>
}
</div>
}
}
</div>
<div class="ha-filterlist">
</div>
</div>
}
</div>