Skip to content
Snippets Groups Projects
Commit 99507a29 authored by Anne Garcia-Fernandez's avatar Anne Garcia-Fernandez
Browse files

Group by book, add HTML title for books and move chapter info

parent 044c671d
No related branches found
No related tags found
1 merge request!99Merge Search functionnality to Master
......@@ -14,22 +14,30 @@ const renderSearchResults = (results) => {
//JSON.stringify(results);
//results = results.filter((result) => result.book == 1)//filter book 1
//results.sort((a,b) => a.n - b.n); //sort by n (only)
// sort by book, and then n (line number)
results.sort((a,b) => {
if (a.book < b.book) return -1;
if (a.book > b.book) return 1;
if (a.n < b.n) return -1;
if (a.n > b.n) return 1;
return 0;
const books = new Set(results.map(a => a.book));
let $result;
$resultsList.innerHTML = "";
for (let b of books){
$resultsList.innerHTML += "<h4>Livre "+b+"</h4>\n";
//filter by book
results_by_book = results.filter((result) => result.book == b)
//sort by n
results_by_book.sort((a,b) => {
return (a.n - b.n);
});
$resultsList.innerHTML = results.map(({ book, chapter, n, lem,BnFfr4967, BnFfr5299, BnFfr23145, BnFfr49967, Cha514, BnFfr23146, BnFfr17274, Vat966,
//}
$resultsList.innerHTML += results_by_book.map(({ book, chapter, n, lem,BnFfr4967, BnFfr5299, BnFfr23145, BnFfr49967, Cha514, BnFfr23146, BnFfr17274, Vat966,
Aix419, BnFfr1724, Aix966 }) => {
let $result=`<h5 xmlns="http://www.w3.org/1999/xhtml" class="mt-3">Vers <a href="/book${book}/${chapter}#${n}">${n}</a></h5><dl xmlns="http://www.w3.org/1999/xhtml">
<dt>Livre : </dt>
<dd>${book}</dd>
<dt>Chapitre : </dt>
<dd>${chapter}</dd>
<dt>Lemme :</dt>
let $chap = `${chapter}`.substring(0, `${chapter}`.indexOf("_"));
$result='<h5 xmlns="http://www.w3.org/1999/xhtml" class="mt-3">Vers <a href="';
$result+=`/book${book}/${chapter}#${n}">${n}</a> (chapitre `
$result+=$chap
$result+=`)</h5><dl xmlns="http://www.w3.org/1999/xhtml">
<dt>Lemme :</dt>
<dd>${lem}</dd>`
if (! (`${BnFfr4967}` === "undefined") ) {
$result += `
......@@ -87,8 +95,11 @@ Aix419, BnFfr1724, Aix966 }) => {
<dd>${Aix966}</dd>
`}
$result += `</dl>`
return $result
}).join('\n')
}
if (results.length > 0) {
$app.classList.add('hasResults')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment