From Jonathan Gardner's Latin Notebook
|
|
(6 intermediate revisions by the same user not shown) |
Line 8: |
Line 8: |
| <option>genitive</option> | | <option>genitive</option> |
| <option>dative</option> | | <option>dative</option> |
− | <opion>ablative</option> | + | <option>ablative</option> |
| </select> | | </select> |
| <select name="number"> | | <select name="number"> |
Line 21: |
Line 21: |
| Error: <span id="decline_error"/> | | Error: <span id="decline_error"/> |
| </div> | | </div> |
− | <script type="text/javascript">
| |
− | function decline_submit(form) {
| |
− | try {
| |
− | document.getElementById('decline_success').style.display = '';
| |
− | document.getElementById('decline_failure').style.display = 'none';
| |
− | document.getElementById('decline_result').innerHTML = decline(
| |
− | form.noun.value,
| |
− | form.case_.value,
| |
− | form.number.value);
| |
− | } catch(error) {
| |
− | document.getElementById('decline_failure').style.display = '';
| |
− | document.getElementById('decline_success').style.display = 'none';
| |
− | document.getElementById('decline_error').innerHTML = error.message;
| |
− | }
| |
− | }
| |
− |
| |
− | function decline(noun, case_, number) {
| |
− | var m;
| |
− | noun = noun.replace(/^\s+|\s+$/g, '');
| |
− |
| |
− | if (!noun) {
| |
− | throw new Error("You must specify a noun.");
| |
− | }
| |
− |
| |
− | if (m = /^(.*)(a|am|ae|as|arum|is)$/.exec(noun)) {
| |
− | return m[1]+{
| |
− | singular: {
| |
− | nominative: 'a',
| |
− | vocative: 'a',
| |
− | accusative: 'am',
| |
− | genitive: 'ae',
| |
− | dative: 'ae',
| |
− | ablative: 'a',
| |
− | },
| |
− | plural: {
| |
− | nominative: 'ae',
| |
− | vocative: 'ae',
| |
− | accusative: 'as',
| |
− | genitive: 'arum',
| |
− | dative: 'is',
| |
− | ablative: 'is',
| |
− | }
| |
− | }[number][case_];
| |
− | } else {
| |
− | throw new Error("That doesn't look like a first declension noun.");
| |
− | }
| |
− | }
| |
− | </script>
| |
| </html> | | </html> |
Latest revision as of 16:47, 23 February 2012
Result:
Error: