Added markers. Weird shit is happening when searching for "Win", see Letter 51

This commit is contained in:
Simon Martens
2022-11-11 14:16:13 +01:00
parent 501814b543
commit 7247640b0e
11 changed files with 60 additions and 18 deletions

View File

@@ -23,7 +23,7 @@ public class Briefecontroller : Controller {
[Route("/HKB/Briefe")] [Route("/HKB/Briefe")]
[Route("/HKB/Briefe/{id?}")] [Route("/HKB/Briefe/{id?}")]
public IActionResult Index(string? id) { public IActionResult Index(string? id, string? search = null) {
// Setup settings and variables // Setup settings and variables
var lib = _lib.GetLibrary(); var lib = _lib.GetLibrary();
var url = "/HKB/Briefe/"; var url = "/HKB/Briefe/";
@@ -50,6 +50,9 @@ public class Briefecontroller : Controller {
ViewData["Title"] = "Brief " + id.ToLower(); ViewData["Title"] = "Brief " + id.ToLower();
ViewData["SEODescription"] = "Johann Georg Hamann: Kommentierte Briefausgabe. Brief " + id.ToLower(); ViewData["SEODescription"] = "Johann Georg Hamann: Kommentierte Briefausgabe. Brief " + id.ToLower();
ViewData["Filename"] = "HKB_" + meta.Autopsic + ".pdf"; ViewData["Filename"] = "HKB_" + meta.Autopsic + ".pdf";
if (!string.IsNullOrWhiteSpace(search)) {
ViewData["Mark"] = "search";
}
// Model creation // Model creation
var hasMarginals = false; var hasMarginals = false;

View File

@@ -114,6 +114,7 @@ public class RegisterController : Controller {
var title = "Forschungsbibliographie"; var title = "Forschungsbibliographie";
ViewData["Title"] = "Forschungsbibliographie"; ViewData["Title"] = "Forschungsbibliographie";
ViewData["SEODescription"] = "Johann Georg Hamann: Kommentierte Briefausgabe. Forschungsbibliographie."; ViewData["SEODescription"] = "Johann Georg Hamann: Kommentierte Briefausgabe. Forschungsbibliographie.";
ViewData["Mark"] = "He";
// Normalisation and Validation // Normalisation and Validation
if (String.IsNullOrWhiteSpace(id)) return Redirect(url + defaultLetter); if (String.IsNullOrWhiteSpace(id)) return Redirect(url + defaultLetter);

View File

@@ -125,7 +125,7 @@
let pg = page.value; let pg = page.value;
window.location.href = "/HKB/" + vol + "/" + pg; window.location.href = "/HKB/" + vol + "/" + pg;
} }
window.addEventListener("load", () => { window.addEventListener("load", () => {
let vol = document.getElementById("ha-zhformvolume"); let vol = document.getElementById("ha-zhformvolume");
let pg = document.getElementById("ha-zhformpage"); let pg = document.getElementById("ha-zhformpage");
@@ -147,8 +147,9 @@
<div class="ha-filtertitle"> <div class="ha-filtertitle">
Volltextsuche Volltextsuche
</div> </div>
<form class="ha-searchform" id="ha-searchform" asp-controller="Suche" asp-action="Briefe" method="get"> <form class="ha-searchform" id="ha-searchform" asp-controller="Suche" asp-action="Briefe" asp-route-comments="true" method="get">
<input id="ha-searchformtext" name="search" type="text" placeholder="Suchbegriff"/> <input id="ha-searchformtext" name="search" type="text" placeholder="Suchbegriff"/>
<input type="hidden" name="comments" value="true"/>
<button id="ha-searchformsubmit" type="submit">Suchen</button> <button id="ha-searchformsubmit" type="submit">Suchen</button>
</form> </form>
</div> </div>

View File

@@ -3,6 +3,7 @@
ViewData["Title"] = "Briefauswahl & Suche"; 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["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"] = "false"; ViewData["showCredits"] = "false";
ViewData["Mark"] = Model.ActiveSearch;
} }
<div class="ha-search"> <div class="ha-search">
@@ -110,12 +111,12 @@
{ {
<div class="ha-letterlistsearchresult"> <div class="ha-letterlistsearchresult">
<div class="ha-searchresultlocation"> <div class="ha-searchresultlocation">
<a asp-controller="Briefe" asp-action="Index" asp-route-id="@letter.Meta.Autopsic" asp-fragment="@sr.Page-@sr.Line"> <a asp-controller="Briefe" asp-action="Index" asp-route-id="@letter.Meta.Autopsic" asp-route-search="@Model.ActiveSearch" asp-fragment="@sr.Page-@sr.Line">
HKB @sr.Page/@sr.Line HKB @sr.Page/@sr.Line
</a> </a>
</div> </div>
<div class="ha-searchresultpreview"> <div class="ha-searchresultpreview">
<a asp-controller="Briefe" asp-action="Index" asp-route-id="@letter.Meta.Autopsic" asp-fragment="@sr.Page-@sr.Line"> <a asp-controller="Briefe" asp-action="Index" asp-route-id="@letter.Meta.Autopsic" asp-route-search="@Model.ActiveSearch" asp-fragment="@sr.Page-@sr.Line">
@sr.Preview @sr.Preview
</a> </a>
@if (Model.Marginals != null && Model.Marginals.Any()) { @if (Model.Marginals != null && Model.Marginals.Any()) {

View File

@@ -18,7 +18,8 @@
<feature name="AdminService"> <feature name="AdminService">
<span> · <a asp-controller="Admin" asp-action="Index">Admin-Bereich</a></span> <span> · <a asp-controller="Admin" asp-action="Index">Admin-Bereich</a></span>
</feature> </feature>
</div> </div>
</div> </div>
</div> </div>
@await Html.PartialAsync("/Views/Shared/_Javascript.cshtml")

View File

@@ -18,9 +18,4 @@
<link rel="stylesheet" href="/css/output.css" asp-append-version="true" /> <link rel="stylesheet" href="/css/output.css" asp-append-version="true" />
<script src="~/js/site.js" asp-append-version="true"></script> <script src="~/js/site.js" asp-append-version="true"></script>
<environment exclude="Development">
@await Html.PartialAsync("/Views/Shared/_Javascript.cshtml")
</environment>

View File

@@ -1,6 +1,35 @@
@* Javascript gets inlined because it ain't much (but it's honest work) *@ @* Javascript gets inlined because it ain't much (but it's honest work) *@
@* Only put PRODUCTION JavaScript here *@
@* Mark searched term *@
@if(ViewData.ContainsKey("Mark")) {
<script src="~/js/mark.min.js" asp-append-version="true"></script>
<script>
var instance = new Mark(document.querySelectorAll(".ha-register-body, .ha-letterbody *, .ha-searchresultpreview, .ha-comment"));
instance.mark('@ViewData["Mark"]', { "element": "span", "className": "ha-found", "acrossElements": true, "separateWordSearch": false, "exclude": [".ha-searchresultcommentpill", ".ha-letlink", ".ha-letlinks", ".ha-hkb"]});
</script>
}
<script> <script>
function markanchor() {
var currentUrl = document.URL,
urlParts = currentUrl.split('#');
var anchor = (urlParts.length > 1) ? urlParts[1] : null;
if (anchor != null) {
var element = document.getElementById(anchor);
if (element !== null && element.classList.contains("ha-linecount") && element.firstChild.classList.contains("ha-hiddenlinecount")) {
element.classList.add("ha-found");
element.classList.add("font-bold");
element.classList.add("mr-3");
element.prepend("● ");
} else if (element !== null && element.classList.contains("ha-commenthead")) {
element.classList.add("ha-found");
element.classList.add("font-bold");
element.prepend("● ");
}
}
}
window.addEventListener("load", function () {
markanchor();
});
</script> </script>

View File

@@ -37,7 +37,7 @@
</div> </div>
} }
@if (Model.Letter.Meta.isProofread != HaDocument.Models.OptionalBool.True) { @* @if (Model.Letter.Meta.isProofread != HaDocument.Models.OptionalBool.True) {
<div class="ha-tooltip"> <div class="ha-tooltip">
<div class="ha-pill"> <div class="ha-pill">
<span class="ha-cross">geprüft</span> <span class="ha-cross">geprüft</span>
@@ -56,7 +56,7 @@
Textkritisch geprüft Textkritisch geprüft
</div> </div>
</div> </div>
} } *@
@if (Model.Letter.Meta.ZH != null && Model.Letter.Meta.ZH.dateChanged) { @if (Model.Letter.Meta.ZH != null && Model.Letter.Meta.ZH.dateChanged) {
<div class="ha-tooltip"> <div class="ha-tooltip">

File diff suppressed because one or more lines are too long

View File

@@ -57,6 +57,10 @@
@apply !hidden @apply !hidden
} }
.ha-found {
@apply !text-hamannSlate-300
}
.ha-zhbreak { .ha-zhbreak {
@apply hidden sm:inline @apply hidden sm:inline
} }

7
HaWeb/wwwroot/js/mark.min.js vendored Normal file

File diff suppressed because one or more lines are too long