The background for my question (You don't have to know this):
In my case, I would like to add a conjugation / declension table to every card, in order to also learn the grammar for that word.
However, I don't want to type in every single cell of this table with another note field; I would like to make Anki do that automatically (so automatic declension implementing the grammar rules, fetching the word in parts to decline it).
Unfortunately, for every conjugation / declension class, this works different. Additionally, I don't want to create a new note type for every conjugation / declension class.
The perfect solution would be, if I just type in a number (standing for one specific conjugation / declension class) in one of the fields, Anki / javascript reads this number, and displays the forms of this declension class written in HTML / hides the other declension classes' HTML.
Thanks for your answer in advance! I hope, someone can finally answer me....
<div id="card"></div> <!-- Displayed Output -->
<div id="field" style="display: none;">{{field}}</div> <!-- Anki text field, hidden -->
<script>
var cardOutput = document.getElementById("field").innerHTML; //innerHTML returns a string with HTML markup (eg. <div>, <br>, etc); innerText returns text only
//Modify cardOutput here
document.getElementById("card").innerHTML = cardOutput; //Set displayed output as cardOutput with HTML markup
</script>Tips
1. It is possible to directly read Anki's text fields with HTML markup in the Add Card > Top tool bar > Other... (Down Arrow) > Edit HTML
a. Images are accessed using the <img> tag (eg. <img src="paste-xxxx.png" />)
b. HTML tags used to manage {{cloze:field}} requires reading it via javascript (read the field as innerText and output that to your card) basically the method Anki transforms the field into cloze HTML is not directly accessible outside of the card's HTML document
You can
have it even easier without a hidden field. Just output to the target field directly, read the data,
modify it, and overwrite. Something like this:
<div id="card">{{text:field}}</div>
<script>
var cardOutput = document.getElementById("card").innerHTML;
//Modify cardOutput
here
document.getElementById("card").innerHTML = cardOutput;
</script>
--
You received this message because you are subscribed to a topic in the Google Groups "AnkiDroid" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/anki-android/ji9TN9YvvRk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to anki-android...@googlegroups.com.
To post to this group, send email to anki-a...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/anki-android/2d37ddf0-c442-47ea-9e73-c3c1ae55ffc1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.