Sortierung der Handschriften

This commit is contained in:
Simon Martens
2023-02-03 14:38:18 +01:00
parent 7032a89bb7
commit c232820639
3 changed files with 47 additions and 31 deletions

View File

@@ -2,24 +2,6 @@ const eleventyNavigationPlugin = require("@11ty/eleventy-navigation");
module.exports = function (config) {
config.addCollection("handschriften", function(collectionApi) {
return collectionApi
.getFilteredByGlob("**/lists/handschriften/*.html")
.sort(function(a, b) {
if (a.data.Jahr !== null && b.data.Jahr !== null &&
a.data.Jahr !== b.data.Jahr) {
return a.data.Jahr - b.data.Jahr;
} else if ( a.data.Autor !== null && b.data.Autor !== null &&
a.data.Autor !== b.data.Autor) {
return a.data.Autor.localeCompare(b.data.Autor);
} else if (a.data.Sort !== null && b.data.Sort !== null &&
a.data.Sort !== b.data.Sort) {
return a.data.Sort - b.data.Sort;
}
return 0;
});
});
config.addCollection("sekundaer", function(collectionApi) {
return collectionApi
.getFilteredByGlob("**/lists/sekundaerliteratur/*.html")
@@ -86,6 +68,22 @@ module.exports = function (config) {
});
});
config.addCollection("handschriften", function(collectionApi) {
return collectionApi
.getFilteredByGlob("**/lists/handschriften/*.html")
.sort(function(a, b) {
if ( a.data.Ort !== null && b.data.Ort !== null &&
a.data.Ort !== b.data.Ort) {
return a.data.Ort.localeCompare(b.data.Ort);
} else if (a.data.Sort !== null && b.data.Sort !== null &&
a.data.Sort !== b.data.Sort) {
return a.data.Sort - b.data.Sort;
}
return 0;
});
});
config.setServerOptions({
// Default values are shown:

View File

@@ -1,5 +1,5 @@
---
Ort: [Auzeville, zuletzt Privatbesitz]
Ort: Auzeville, zuletzt Privatbesitz
---
<div class="gruppe">

View File

@@ -125,39 +125,57 @@
let found = dictionary;
let sw = "";
let swl = 0;
$("input[name='keyword']").keyup(function() {
var term = $(this).val() || '';
var term = $(this).val().trim() || '';
if( term ) {
// Hide everything tagged hideifseaching
$(".hideifsearching").each( (ind, el) => {
$(el).hide();
});
if (sw.length > 1) {
// Unmark everything previously marked
if (sw.length > 0) {
for (let item of found) {
$(item.element).unmark();
}
}
// Only search in prior found elements if word starts the same
if (term.length > swl && term.startsWith(sw)) {
found = findWord( term, found );
} else {
found = findWord( term, dictionary );
}
$("#list .category").hide();
// Hide all categories by default
requestAnimationFrame(function() {
$("#list .category").hide();
});
for (let item of dictionary) {
if (found.indexOf(item) !== -1) {
$(item.category).addClass("search-expanded").show();
$(item.element).show();
if (term.length >= 3) {
$(item.element).mark(term, {
"separateWordSearch": false
});
}
requestAnimationFrame(function() {
$(item.category).addClass("search-expanded").show();
$(item.element).show();
if (term.length >= 3) {
$(item.element).mark(term, {
"separateWordSearch": false,
"acrossElements": true
});
}
});
} else {
$(item.element).unmark().hide();
requestAnimationFrame(function() {
$(item.element).hide();
});
}
}
sw = term;
swl = term.length;
} else {
}
else {
$("#list .category").show().removeClass("search-expanded").unmark();
$("#list .searchable").show();
found = dictionary;