diff --git a/aqt/reviewer.py b/aqt/reviewer.py
index 644d95a93..5a1306ec1 100644
--- a/aqt/reviewer.py
+++ b/aqt/reviewer.py
@@ -119,11 +119,7 @@ class Reviewer:
_revHtml = """
-
+
"""
def _initWeb(self):
@@ -168,11 +164,10 @@ The front of this card is empty. Please run Tools>Empty Cards.""")
playFromText(q)
# render & update bottom
q = self._mungeQA(q)
- a = self._mungeQA(a)
bodyclass = "card card%d" % (c.ord+1)
- self.web.eval("_showQuestion(%s, %s, '%s');" % (json.dumps(q), json.dumps(a), bodyclass))
+ self.web.eval("_showQuestion(%s,'%s');" % (json.dumps(q), bodyclass))
self._toggleStar()
self._showAnswerButton()
# if we have a type answer field, focus main web
@@ -204,11 +199,12 @@ The front of this card is empty. Please run Tools>Empty Cards.""")
self.state = "answer"
c = self.card
a = c.a()
+ a = self._mungeQA(a)
# play audio?
if self.autoplay(c):
playFromText(a)
# render and update bottom
- self.web.eval("_showAnswer(%s);" % json.dumps(''))
+ self.web.eval("_showAnswer(%s);" % json.dumps(a))
self._showEaseButtons()
# user hook
runHook('showAnswer')
diff --git a/web/reviewer.css b/web/reviewer.css
index 03430b51e..de11ceb83 100644
--- a/web/reviewer.css
+++ b/web/reviewer.css
@@ -6,5 +6,3 @@ img { max-width: 95%; max-height: 95%; }
.typeGood { background: #0f0; }
.typeBad { background: #f00; }
.typeMissed { background: #ccc; }
-#qa { position: relative; }
-.qaelem { position: absolute; top: 0; left: 0; right: 0; bottom: 0; }
diff --git a/web/reviewer.js b/web/reviewer.js
index 466ebf69c..e20a40e7f 100644
--- a/web/reviewer.js
+++ b/web/reviewer.js
@@ -1,76 +1,54 @@
var ankiPlatform = "desktop";
var typeans;
-var currentAns = "_answer1";
-var nextAns = "_answer2";
-var fadeTime = 200;
+var fadeTime = 100;
-function _switchAnswerTarget() {
- if (currentAns === "_answer1") {
- currentAns = "_answer2";
- nextAns = "_answer1";
- } else {
- currentAns = "_answer1";
- nextAns = "_answer2";
- }
-}
+function _updateQA(html, onupdate, onshown) {
+ // fade out current text
+ var qa = $("#qa");
+ qa.fadeTo(fadeTime, 0, function() {
+ // update text
+ qa.html(html);
+ onupdate(qa);
-function _makeVisible(jquery) {
- return jquery.css("visibility", "visible").css("opacity", "1");
-}
+ // don't allow drags of images, which cause them to be deleted
+ $("img").attr("draggable", false);
-function _makeHidden(jquery) {
- // must alter visibility as well so hidden elements are not clickable
- return jquery.css("visibility", "hidden").css("opacity", "0");
-}
+ // render mathjax
+ MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
-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
+ // and reveal when processing is done
MathJax.Hub.Queue(function () {
- $("#_question").css("visibility", "visible").fadeTo(
- fadeTime, 1, function () {
- // focus typing area if visible
- typeans = document.getElementById("typeans");
- if (typeans) {
- typeans.focus();
- }
- });
+ qa.fadeTo(fadeTime, 1, function () {
+ onshown(qa);
+ });
});
});
-
- // return to top of window
- window.scrollTo(0, 0);
-
- // don't allow drags of images, which cause them to be deleted
- $("img").attr("draggable", false);
-
- // render mathjax
- MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
}
-function _showAnswer(nextQuestion){
- // hide question; show answer
- _makeHidden($("#_question"));
- _makeVisible($("#"+nextAns));
+function _showQuestion(q, bodyclass) {
+ _updateQA(q, function(obj) {
+ // return to top of window
+ window.scrollTo(0, 0);
- // scroll to answer?
- var e = $("#answer");
- if (e[0]) {
- e[0].scrollIntoView();
- }
+ document.body.className = bodyclass;
+ }, function(obj) {
+ // focus typing area if visible
+ typeans = document.getElementById("typeans");
+ if (typeans) {
+ typeans.focus();
+ }
+ });
+}
- _switchAnswerTarget();
+function _showAnswer(a) {
+ _updateQA(a, function(obj) {
+ // scroll to answer?
+ var e = $("#answer");
+ if (e[0]) {
+ e[0].scrollIntoView();
+ }
+ }, function(obj) {
+ });
}
function _toggleStar(show) {