2017-07-28 08:19:06 +02:00
|
|
|
var ankiPlatform = "desktop";
|
|
|
|
var typeans;
|
2017-07-29 06:24:45 +02:00
|
|
|
var currentAns = "_answer1";
|
|
|
|
var nextAns = "_answer2";
|
|
|
|
var fadeTime = 200;
|
|
|
|
|
|
|
|
function _switchAnswerTarget() {
|
|
|
|
if (currentAns === "_answer1") {
|
|
|
|
currentAns = "_answer2";
|
|
|
|
nextAns = "_answer1";
|
|
|
|
} else {
|
|
|
|
currentAns = "_answer1";
|
|
|
|
nextAns = "_answer2";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function _makeVisible(jquery) {
|
|
|
|
return jquery.css("visibility", "visible").css("opacity", "1");
|
|
|
|
}
|
|
|
|
|
|
|
|
function _makeHidden(jquery) {
|
|
|
|
// must alter visibility as well so hidden elements are not clickable
|
|
|
|
return jquery.css("visibility", "hidden").css("opacity", "0");
|
|
|
|
}
|
|
|
|
|
|
|
|
function _showQuestion(q, a, bodyclass) {
|
|
|
|
document.body.className = bodyclass;
|
|
|
|
|
|
|
|
// update question text
|
|
|
|
_makeHidden($("#_question")).html(q);
|
|
|
|
|
|
|
|
// preload answer
|
|
|
|
_makeHidden($("#"+nextAns)).html(a);
|
|
|
|
|
|
|
|
// fade out previous answer
|
|
|
|
$("#"+currentAns).fadeTo(fadeTime, 0, function () {
|
|
|
|
// hide fully
|
|
|
|
_makeHidden($("#"+currentAns));
|
|
|
|
// and reveal question when processing is done
|
|
|
|
MathJax.Hub.Queue(function () {
|
2017-07-31 08:34:30 +02:00
|
|
|
$("#_question").css("visibility", "visible").fadeTo(
|
|
|
|
fadeTime, 1, function () {
|
|
|
|
// focus typing area if visible
|
|
|
|
typeans = document.getElementById("typeans");
|
|
|
|
if (typeans) {
|
|
|
|
typeans.focus();
|
|
|
|
}
|
|
|
|
});
|
2017-07-29 06:24:45 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// return to top of window
|
|
|
|
window.scrollTo(0, 0);
|
|
|
|
|
2017-07-28 08:19:06 +02:00
|
|
|
// don't allow drags of images, which cause them to be deleted
|
|
|
|
$("img").attr("draggable", false);
|
2017-07-29 06:24:45 +02:00
|
|
|
|
|
|
|
// render mathjax
|
2017-07-28 08:19:06 +02:00
|
|
|
MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
|
2017-07-28 08:48:49 +02:00
|
|
|
}
|
2017-07-28 08:19:06 +02:00
|
|
|
|
2017-07-29 06:24:45 +02:00
|
|
|
function _showAnswer(nextQuestion){
|
|
|
|
// hide question; show answer
|
|
|
|
_makeHidden($("#_question"));
|
|
|
|
_makeVisible($("#"+nextAns));
|
|
|
|
|
|
|
|
// scroll to answer?
|
|
|
|
var e = $("#answer");
|
|
|
|
if (e[0]) {
|
|
|
|
e[0].scrollIntoView();
|
|
|
|
}
|
|
|
|
|
|
|
|
_switchAnswerTarget();
|
|
|
|
}
|
|
|
|
|
2017-07-28 08:19:06 +02:00
|
|
|
function _toggleStar(show) {
|
|
|
|
if (show) {
|
|
|
|
$(".marked").show();
|
|
|
|
} else {
|
|
|
|
$(".marked").hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function _typeAnsPress() {
|
|
|
|
if (window.event.keyCode === 13) {
|
|
|
|
pycmd("ans");
|
|
|
|
}
|
|
|
|
}
|