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 = '';


    // Autoren
     const authors = formatAuthors(entry.authors);
     const authors = formatAuthors(entry.authors);
     citation += authors + '. ';
     citation += authors + '. ';


    // Titel
     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:
     }
     }


    // Container
     const container = entry.container;
     const container = entry.container;
     if (container && container.trim()) {
     if (container && container.trim()) {
Line 92: Line 92:
     }
     }


    // Jahr
     const year = getOrUnknown(entry.year);
     const year = getOrUnknown(entry.year);
     citation += `${year}. `;
     citation += `${year}. `;


    // URL
     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() {
    console.log('generateBibliography aufgerufen');
     const output = document.getElementById('bibOutput');
     const output = document.getElementById('bibOutput');
    if (!output) {
      console.error('bibOutput not found');
      return;
    }
     output.value = 'Lade Daten...';
     output.value = 'Lade Daten...';


Line 166: Line 158:
        
        
       const entries = await response.json();
       const entries = await response.json();
      console.log('JSON geparst, ' + entries.length + ' Einträge');


      // Filtere irrelevante Einträge
       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:
       });
       });


      // Extrahiere alle Tags
       const allTags = new Set();
       const allTags = new Set();
       filtered.forEach(entry => {
       filtered.forEach(entry => {
Line 187: Line 176:
       });
       });


      // Generiere HTML
       const tagSpans = Array.from(allTags)
       const tagSpans = Array.from(allTags)
         .sort()
         .sort()
Line 211: Line 199:


       output.value = html;
       output.value = html;
      console.log('Fertig - ' + filtered.length + ' Einträge generiert');
     } catch (error) {
     } catch (error) {
       output.value = 'ERROR: ' + error.message;
       output.value = 'ERROR: ' + error.message;
      console.error('Fehler:', error);
     }
     }
   }
   }


   document.addEventListener('DOMContentLoaded', function() {
   const btn = document.getElementById('generateBtn');
    const btn = document.getElementById('generateBtn');
  if (btn) {
    if (btn) {
    btn.addEventListener('click', generateBibliography);
      btn.addEventListener('click', generateBibliography);
   }
      console.log('Generate Button bereit');
    }
   });
})();
})();
</script>
</script>
</div>
</html>

Latest revision as of 00:51, 12 May 2026

Bibliography Generator