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> | <html> | ||
<button id="testBtn" style=" | |||
<button id=" | |||
background-color: #008CBA; | background-color: #008CBA; | ||
color: white; | color: white; | ||
| Line 16: | Line 10: | ||
cursor: pointer; | cursor: pointer; | ||
margin-bottom: 1rem; | margin-bottom: 1rem; | ||
"> | ">Test Fetch</button> | ||
<textarea id="bibOutput" style=" | <textarea id="bibOutput" style=" | ||
| Line 36: | Line 25: | ||
"></textarea> | "></textarea> | ||
</ | <script> | ||
/** | |||
* Minimales Test-Script für BibliographyData | |||
*/ | |||
< | (function() { | ||
{{ | 'use strict'; | ||
async function testFetch() { | |||
const output = document.getElementById('bibOutput'); | |||
output.value = 'Versuche zu laden...\n'; | |||
// Test 1: Normales Fetch | |||
try { | |||
output.value += '\n=== Test 1: Normales Fetch ===\n'; | |||
const response = await fetch('/BibliographyData'); | |||
output.value += `Status: ${response.status}\n`; | |||
const text = await response.text(); | |||
output.value += `Länge: ${text.length} Zeichen\n`; | |||
output.value += `Erste 500 Zeichen:\n${text.substring(0, 500)}\n`; | |||
} catch (err) { | |||
output.value += `Fehler: ${err.message}\n`; | |||
} | |||
// Test 2: Mit ?action=raw | |||
try { | |||
output.value += '\n=== Test 2: Mit ?action=raw ===\n'; | |||
const response = await fetch('/BibliographyData?action=raw'); | |||
output.value += `Status: ${response.status}\n`; | |||
const text = await response.text(); | |||
output.value += `Länge: ${text.length} Zeichen\n`; | |||
output.value += `Erste 500 Zeichen:\n${text.substring(0, 500)}\n`; | |||
} catch (err) { | |||
output.value += `Fehler: ${err.message}\n`; | |||
} | |||
// Test 3: Versuche JSON zu parsen | |||
try { | |||
output.value += '\n=== Test 3: JSON Parse ===\n'; | |||
const response = await fetch('/BibliographyData?action=raw'); | |||
const text = await response.text(); | |||
// Versuche direkt zu parsen | |||
const json = JSON.parse(text); | |||
output.value += `✓ JSON erfolgreich geparst!\n`; | |||
output.value += `Anzahl Einträge: ${json.length}\n`; | |||
if (json.length > 0) { | |||
output.value += `Erster Eintrag: ${JSON.stringify(json[0], null, 2)}\n`; | |||
} | |||
} catch (err) { | |||
output.value += `Fehler beim JSON Parse: ${err.message}\n`; | |||
// Versuche die nowiki zu entfernen | |||
try { | |||
output.value += '\n--- Versuche <nowiki> zu entfernen ---\n'; | |||
const response = await fetch('/BibliographyData?action=raw'); | |||
let text = await response.text(); | |||
// Entferne <nowiki> Tags | |||
text = text.replace(/<\/?nowiki>/g, ''); | |||
output.value += `Nach Entfernung von nowiki, erste 500 Zeichen:\n${text.substring(0, 500)}\n`; | |||
const json = JSON.parse(text); | |||
output.value += `✓ JSON erfolgreich geparst!\n`; | |||
output.value += `Anzahl Einträge: ${json.length}\n`; | |||
} catch (err2) { | |||
output.value += `Immer noch Fehler: ${err2.message}\n`; | |||
} | |||
} | |||
} | |||
function init() { | |||
const btn = document.getElementById('testBtn'); | |||
if (btn) { | |||
btn.addEventListener('click', testFetch); | |||
console.log('Test-Script bereit'); | |||
} else { | |||
console.error('Button nicht gefunden'); | |||
} | |||
} | |||
if (document.readyState === 'loading') { | |||
document.addEventListener('DOMContentLoaded', init); | |||
} else { | |||
init(); | |||
} | |||
})(); | |||
</script> | </script> | ||
</html> | </html> | ||
Revision as of 00:22, 12 May 2026
Bibliography Generator