BibliographyBackbone: Difference between revisions
From Illustrations in German Translations of Mark Twain's Works
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
{{Seitenkopf|Bibliography Generator}} | {{Seitenkopf|Bibliography Generator}} | ||
<html> | |||
<div style="max-width: 1000px;"> | |||
<button id="generateBtn" style=" | <button id="generateBtn" style=" | ||
| Line 74: | Line 77: | ||
let citation = ''; | let citation = ''; | ||
const authors = formatAuthors(entry.authors); | const authors = formatAuthors(entry.authors); | ||
citation += authors + '. '; | citation += authors + '. '; | ||
const title = getOrUnknown(entry.title); | const title = getOrUnknown(entry.title); | ||
if (entry.type === 'bookSection' || entry.type === 'book') { | if (entry.type === 'bookSection' || entry.type === 'book') { | ||
| Line 86: | Line 87: | ||
} | } | ||
const container = entry.container; | const container = entry.container; | ||
if (container && container.trim()) { | if (container && container.trim()) { | ||
| Line 92: | Line 92: | ||
} | } | ||
const year = getOrUnknown(entry.year); | const year = getOrUnknown(entry.year); | ||
citation += `${year}. `; | citation += `${year}. `; | ||
if (entry.url && entry.url.trim()) { | if (entry.url && entry.url.trim()) { | ||
citation += `<a href="${escapeHtml(entry.url)}" target="_blank">${escapeHtml(entry.url)}</a>.`; | citation += `<a href="${escapeHtml(entry.url)}" target="_blank">${escapeHtml(entry.url)}</a>.`; | ||
| Line 152: | Line 150: | ||
async function generateBibliography() { | async function generateBibliography() { | ||
const output = document.getElementById('bibOutput'); | const output = document.getElementById('bibOutput'); | ||
output.value = 'Lade Daten...'; | output.value = 'Lade Daten...'; | ||
| Line 166: | Line 158: | ||
const entries = await response.json(); | const entries = await response.json(); | ||
const filtered = entries.filter(entry => { | const filtered = entries.filter(entry => { | ||
if (entry.tags && entry.tags.includes('Not relevant for Mark Twain')) { | if (entry.tags && entry.tags.includes('Not relevant for Mark Twain')) { | ||
| Line 179: | Line 169: | ||
}); | }); | ||
const allTags = new Set(); | const allTags = new Set(); | ||
filtered.forEach(entry => { | filtered.forEach(entry => { | ||
| Line 187: | Line 176: | ||
}); | }); | ||
const tagSpans = Array.from(allTags) | const tagSpans = Array.from(allTags) | ||
.sort() | .sort() | ||
| Line 211: | Line 199: | ||
output.value = html; | output.value = html; | ||
} catch (error) { | } catch (error) { | ||
output.value = 'ERROR: ' + error.message; | output.value = 'ERROR: ' + error.message; | ||
} | } | ||
} | } | ||
const btn = document.getElementById('generateBtn'); | |||
if (btn) { | |||
btn.addEventListener('click', generateBibliography); | |||
} | |||
} | |||
})(); | })(); | ||
</script> | </script> | ||
</div> | |||
</html> | |||
Latest revision as of 00:51, 12 May 2026
Bibliography Generator