Widget:Deklinationsklasse ermitteln: Unterschied zwischen den Versionen
Sn (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Sn (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung Markierung: Zurückgesetzt |
||
Zeile 4: | Zeile 4: | ||
<label for="input-gen">Genitiv:</label><input type="text" id="input-gen" oninput="detectDecl()"/></p> | <label for="input-gen">Genitiv:</label><input type="text" id="input-gen" oninput="detectDecl()"/></p> | ||
<script> | <script> | ||
const edges = [ | |||
document.getElementById('L-gen-genis').children[0], | |||
document.getElementById('L-genis-i').children[0], | |||
document.getElementById('L-genis-k').children[0], | |||
document.getElementById('L-gen-geni').children[0], | |||
document.getElementById('L-geni-e').children[0], | |||
document.getElementById('L-geni-o').children[0], | |||
document.getElementById('L-gen-a').children[0], | |||
document.getElementById('L-gen-u').children[0], | |||
document.getElementById('L-gen-i').children[0], | |||
document.getElementById('L-gen-o').children[0], | |||
document.getElementById('L-gen-k').children[0] | |||
] | |||
function colorAllEdges(color) { | |||
for (e of edges) { | |||
colorEdge(e, color) | |||
} | |||
} | |||
function colorEdge(edge, color) { | |||
edge.style = "stroke: " + color + "; fill: none;" | |||
} | |||
function detectDecl() { | function detectDecl() { | ||
Zeile 11: | Zeile 34: | ||
let gen = document.getElementById('input-gen').value | let gen = document.getElementById('input-gen').value | ||
if (nom == '' || gen == '') { | if (nom == '' || gen == '') { | ||
colorAllEdges('black') | |||
return | return | ||
} else { | } else { | ||
colorAllEdges('lightgray') | |||
} | } | ||
if (gen.endsWith('is')) { | if (gen.endsWith('is')) { | ||
document.getElementById('L-gen-genis').children[0] | colorEdge(document.getElementById('L-gen-genis').children[0], 'red') | ||
if (nom == gen || nom.endsWith('ar') || nom.endsWith('e') || nom.endsWith('al')) { | if (nom == gen || nom.endsWith('ar') || nom.endsWith('e') || nom.endsWith('al')) { | ||
document.getElementById('L-genis-i').children[0] | colorEdge(document.getElementById('L-genis-i').children[0], 'red') | ||
} else { | } else { | ||
document.getElementById('L-genis-k').children[0] | colorEdge(document.getElementById('L-genis-k').children[0], 'red') | ||
} | } | ||
return | return | ||
} | } | ||
if (gen.endsWith('i')) { | if (gen.endsWith('i')) { | ||
document.getElementById('L-gen-geni').children[0] | colorEdge(document.getElementById('L-gen-geni').children[0], 'red') | ||
if (nom.endsWith('es')) { | if (nom.endsWith('es')) { | ||
document.getElementById('L-geni-e').children[0] | colorEdge(document.getElementById('L-geni-e').children[0], 'red') | ||
} else { | } else { | ||
document.getElementById('L-geni-o').children[0] | colorEdge(document.getElementById('L-geni-o').children[0], 'red') | ||
} | } | ||
return | return | ||
} | } | ||
if (gen.endsWith('ae') || gen.endsWith('arum')) { | if (gen.endsWith('ae') || gen.endsWith('arum')) { | ||
document.getElementById('L-gen-a').children[0] | colorEdge(document.getElementById('L-gen-a').children[0], 'red') | ||
return | return | ||
} | } | ||
if (gen.endsWith('us') || gen.endsWith('ūs') || gen.endsWith('uum')) { | if (gen.endsWith('us') || gen.endsWith('ūs') || gen.endsWith('uum')) { | ||
document.getElementById('L-gen-u').children[0] | colorEdge(document.getElementById('L-gen-u').children[0], 'red') | ||
return | return | ||
} | } | ||
if (gen.endsWith('ium')) { | if (gen.endsWith('ium')) { | ||
document.getElementById('L-gen-i').children[0] | colorEdge(document.getElementById('L-gen-i').children[0], 'red') | ||
return | return | ||
} | } | ||
if (gen.endsWith('orum')) { | if (gen.endsWith('orum')) { | ||
document.getElementById('L-gen-o').children[0] | colorEdge(document.getElementById('L-gen-o').children[0], 'red') | ||
return | return | ||
} | } | ||
if (gen.endsWith('um')) { | if (gen.endsWith('um')) { | ||
document.getElementById('L-gen-k').children[0] | colorEdge(document.getElementById('L-gen-k').children[0], 'red') | ||
return | return | ||
} | } | ||
} | } | ||
</script> | </script> |
Version vom 4. Juli 2024, 07:56 Uhr
Probier es selbst aus! Gib hier den Nominativ und Genitiv eines Substantivs ein und ermittle die Deklinationsklasse!
<label for="input-nom">Nominativ:</label><input type="text" id="input-nom" oninput="detectDecl()"/> <label for="input-gen">Genitiv:</label><input type="text" id="input-gen" oninput="detectDecl()"/>
<script> const edges = [ document.getElementById('L-gen-genis').children[0], document.getElementById('L-genis-i').children[0], document.getElementById('L-genis-k').children[0], document.getElementById('L-gen-geni').children[0], document.getElementById('L-geni-e').children[0], document.getElementById('L-geni-o').children[0], document.getElementById('L-gen-a').children[0], document.getElementById('L-gen-u').children[0], document.getElementById('L-gen-i').children[0], document.getElementById('L-gen-o').children[0], document.getElementById('L-gen-k').children[0] ] function colorAllEdges(color) { for (e of edges) { colorEdge(e, color) } }
function colorEdge(edge, color) { edge.style = "stroke: " + color + "; fill: none;" }
function detectDecl() {
let nom = document.getElementById('input-nom').value
let gen = document.getElementById('input-gen').value
if (nom == || gen == ) {
colorAllEdges('black')
return
} else {
colorAllEdges('lightgray')
}
if (gen.endsWith('is')) {
colorEdge(document.getElementById('L-gen-genis').children[0], 'red')
if (nom == gen || nom.endsWith('ar') || nom.endsWith('e') || nom.endsWith('al')) {
colorEdge(document.getElementById('L-genis-i').children[0], 'red')
} else {
colorEdge(document.getElementById('L-genis-k').children[0], 'red')
}
return
}
if (gen.endsWith('i')) {
colorEdge(document.getElementById('L-gen-geni').children[0], 'red')
if (nom.endsWith('es')) {
colorEdge(document.getElementById('L-geni-e').children[0], 'red')
} else {
colorEdge(document.getElementById('L-geni-o').children[0], 'red')
}
return
}
if (gen.endsWith('ae') || gen.endsWith('arum')) {
colorEdge(document.getElementById('L-gen-a').children[0], 'red')
return
}
if (gen.endsWith('us') || gen.endsWith('ūs') || gen.endsWith('uum')) {
colorEdge(document.getElementById('L-gen-u').children[0], 'red')
return
}
if (gen.endsWith('ium')) {
colorEdge(document.getElementById('L-gen-i').children[0], 'red')
return
}
if (gen.endsWith('orum')) {
colorEdge(document.getElementById('L-gen-o').children[0], 'red')
return
}
if (gen.endsWith('um')) {
colorEdge(document.getElementById('L-gen-k').children[0], 'red')
return
}
}
</script>