Skip to content

Instantly share code, notes, and snippets.

@arueckle
Last active January 30, 2020 20:01
Show Gist options
  • Save arueckle/ee75416b30f5b4e7c7d5d815036ec08b to your computer and use it in GitHub Desktop.
Save arueckle/ee75416b30f5b4e7c7d5d815036ec08b to your computer and use it in GitHub Desktop.
Code snippet to insert in the front template of an Anki-Maobi card for mobile support via input box (to be used with the iPhone/Android handwriting keyboard)
<!-- MOBILE FALLBACK -->
<div id="maobi-mobile-fallback" style="display:none">
<input type="text" id="maobi-mobile-fallback-input">
<span id="maobi-mobile-fallback-correct-answer" style="display:none">👍</span>
</div>
<script>
setTimeout(function(){
if(window.HanziWriter == undefined){
document.getElementById('maobi-mobile-fallback').style.display = 'block';
var correctElem = document.getElementById('maobi-mobile-fallback-correct-answer');
var inputField = document.getElementById('maobi-mobile-fallback-input');
inputField.addEventListener('input', function(){
correctElem.style.display = this.value != '{{Hanzi}}' ? 'none' : 'inline';
});
inputField.addEventListener('ontouchend', function(e){
inputField.focus();
e.preventDefault();
});
setTimeout(function(){inputField.focus();}, 500);
}
}, 50);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment