diff --git a/contents/static/suche.html b/contents/static/suche.html index 85cee20..e79531e 100644 --- a/contents/static/suche.html +++ b/contents/static/suche.html @@ -1,5 +1,13 @@

Fragensuche

+ +
@@ -104,7 +112,7 @@ if (query.length === 0) { resultsBox.innerHTML = - '
Bitte gib eine Frage-ID ein, z. B. AB123.
'; + '
Bitte gib eine Frage-ID ein, z. B. VD102.
'; return; } @@ -114,7 +122,7 @@ (questionId) => questionId.includes(query) && !questionId.startsWith(query) ); - const matches = [...exactMatches, ...startsWithMatches, ...includesMatches].slice(0, 50); + const matches = [...exactMatches, ...startsWithMatches, ...includesMatches]; if (matches.length === 0) { resultsBox.innerHTML = @@ -122,44 +130,52 @@ return; } - const cards = matches.flatMap((questionId) => { - const entries = Array.isArray(questionIndex[questionId]) ? questionIndex[questionId] : []; - return entries - .map((entry) => { - const sectionIdentRaw = entry.section || ""; - const chapterTitle = escapeHtml(entry.chapter_title || "Unbekanntes Kapitel"); - const sectionTitle = escapeHtml(entry.section_title || entry.section || "Unbekannte Sektion"); - const editions = sortEditions(Array.isArray(entry.editions) ? entry.editions : []); - const editionLinks = editions - .map((edition) => { - const editionSafe = escapeHtml(edition); - const editionLabel = escapeHtml(getEditionLabel(edition)); - const targetClass = getTargetClass(edition); - const targetColor = targetColorByClass[targetClass] || "#6c757d"; - const targetTitle = targetClass ? `Zielklasse ${targetClass}` : "Zielklasse unbekannt"; - const href = `${encodeURIComponent(edition)}_${encodeURIComponent(sectionIdentRaw)}.html#${encodeURIComponent(questionId)}`; - return `${editionLabel}`; - }) - .join(""); - return ` -
-
- -
-
-
${editionLinks || '-'}
-
+ const cards = matches.map((questionId) => { + const entry = questionIndex[questionId] || {}; + const sectionIdentRaw = entry.section || ""; + const chapterTitle = escapeHtml(entry.chapter_title || "Unbekanntes Kapitel"); + const sectionTitle = escapeHtml(entry.section_title || entry.section || "Unbekannte Sektion"); + const hasSolution = Boolean(entry.has_solution); + const editions = sortEditions(Array.isArray(entry.editions) ? entry.editions : []); + const editionLinks = editions + .map((edition) => { + const editionSafe = escapeHtml(edition); + const editionLabel = escapeHtml(getEditionLabel(edition)); + const targetClass = getTargetClass(edition); + const targetColor = targetColorByClass[targetClass] || "#6c757d"; + const targetTitle = targetClass ? `Zielklasse ${targetClass}` : "Zielklasse unbekannt"; + const href = `${encodeURIComponent(edition)}_${encodeURIComponent(sectionIdentRaw)}.html#${encodeURIComponent(questionId)}`; + return `${editionLabel}`; + }) + .join(""); + const solutionLink = hasSolution + ? ` + + Lösungsweg + ` + : ""; + + return ` +
+
+
${escapeHtml(questionId)}
+ +
+
+
+ ${editionLinks || '-'} + ${solutionLink}
- `; - }); +
+
+ `; }); resultsBox.innerHTML = ` @@ -170,7 +186,7 @@ async function loadQuestionIndex() { try { - const response = await fetch("/question_index.json", { + const response = await fetch("/assets/question_index.json", { cache: "no-cache", headers: { Accept: "application/json", @@ -200,7 +216,7 @@ errorBox.classList.remove("d-none"); errorBox.textContent = "Suchindex konnte nicht geladen werden: " + error.message; - console.error("Failed to load /question_index.json", error); + console.error("Failed to load question_index.json", error); } }