Created
March 25, 2021 03:02
-
-
Save warriorg/d6261779e5a1a14fe36be990537c128a to your computer and use it in GitHub Desktop.
anki cloze template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="card"> | |
{{#Example}} | |
<div id="context">{{Example}}</div> | |
<div id="word">{{Word}}</div> | |
{{/Example}} | |
{{^Example}} | |
<div style="text-align: center"> | |
<div>{{Word}}</div> | |
<div>{{IPA}}</div> | |
</div> | |
{{/Example}} | |
<div>{{Audio}}{{Sound_Example}}</div> | |
</div> | |
<script type="text/javascript"> | |
//如果卡面变量是正面,就运行镂空帮助函数 | |
if (window.cardside == "front"){ | |
makeCloze(); | |
} | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
function makeCloze(){ | |
var obj = document.getElementById('context'); | |
var word = document.getElementById('word'); | |
if (obj) { | |
var regExp = new RegExp(word.innerText, "gi"); | |
obj.innerText = obj.innerText.replace(regExp, "___"); | |
} | |
if (word) { | |
word.textContent = '' | |
} | |
} | |
window.cardside = "front" | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment