66 lines
1.9 KiB
JavaScript
66 lines
1.9 KiB
JavaScript
document.getElementById('copyButton').addEventListener('click', () => {
|
|
const text = document.getElementById('formatText').innerText;
|
|
|
|
navigator.clipboard.writeText(text).then(() => {
|
|
alert('Format wurde in die Zwischenablage kopiert!');
|
|
}).catch(err => {
|
|
console.error('Konnte nicht kopieren: ', err);
|
|
});
|
|
});
|
|
|
|
const inputText = document.getElementById("inputText").value;
|
|
const cards = parseWordText(inputText);
|
|
function parseWordText(inputText) {
|
|
const wortBlocks = inputText.trim().split("\n\n");
|
|
const wortListe = [];
|
|
|
|
for (let block of wortBlocks) {
|
|
const lines = block.trim().split("\n").map(line => line.trim());
|
|
|
|
if (lines.length !== 5) {
|
|
console.warn("Block übersprungen (falsches Format):", block);
|
|
continue;
|
|
}
|
|
|
|
const wortObj = {
|
|
englisch: lines[0],
|
|
ipa: lines[1],
|
|
beispielEN: lines[2],
|
|
deutsch: lines[3],
|
|
beispielDE: lines[4]
|
|
};
|
|
|
|
wortListe.push(wortObj);
|
|
console.log(wortObj);
|
|
}
|
|
|
|
return wortListe;
|
|
}
|
|
|
|
const button = document.getElementById("kartenErstellen");
|
|
const container = document.getElementById("kartenContainer");
|
|
|
|
button.addEventListener("click", () => {
|
|
container.innerHTML = "";
|
|
parsedArray.forEach((karte, index) => {
|
|
const karteDiv = document.createElement("div");
|
|
karteDiv.classList.add("karte");
|
|
|
|
karteDiv.innerHTML = `
|
|
<div class="karte-inhalt">
|
|
<div class="karte-vorderseite">
|
|
<h2>${karte.englisch}</h2>
|
|
<p><em>${karte.ipa}</em></p>
|
|
<p>Beispiel: ${karte.beispielEN}</p>
|
|
</div>
|
|
<div class="karte-rückseite">
|
|
<h2>${karte.deutsch}</h2>
|
|
<p>Beispiel: ${karte.beispielDE}</p>
|
|
</div>
|
|
</div>
|
|
`;
|
|
container.appendChild(karteDiv);
|
|
|
|
});
|
|
});
|