diff --git a/aqt/browser.py b/aqt/browser.py index 6fd359b7d..da71887d9 100644 --- a/aqt/browser.py +++ b/aqt/browser.py @@ -1118,7 +1118,7 @@ where id in %s""" % ids2str(sf)) jsinc = ["jquery.js","browsersel.js", "mathjax/conf.js", "mathjax/MathJax.js", "reviewer.js"] - self._previewWeb.stdHtml(self.mw.reviewer._revHtml, + self._previewWeb.stdHtml(self.mw.reviewer.revHtml(), css=["reviewer.css"], head=base, js=jsinc) @@ -1146,6 +1146,7 @@ where id in %s""" % ids2str(sf)) return c = self.card self._updatePreviewButtons() + func = "_showQuestion" if not c or not self.singleCard: txt = _("(please select 1 card)") bodyclass = "" @@ -1155,6 +1156,7 @@ where id in %s""" % ids2str(sf)) # need to force reload even if answer txt = c.q(reload=True) if self._previewState == "answer": + func = "_showAnswer" txt = c.a() txt = re.sub("\[\[type:[^]]+\]\]", "", txt) @@ -1167,7 +1169,7 @@ where id in %s""" % ids2str(sf)) txt = mungeQA(self.col, txt) self._previewWeb.eval( - "_showQuestion(%s,'%s');" % (json.dumps(txt), bodyclass)) + f"{func}({json.dumps(txt)},'{bodyclass}');") # Card deletion ###################################################################### diff --git a/aqt/clayout.py b/aqt/clayout.py index c75bd907b..24a991fed 100644 --- a/aqt/clayout.py +++ b/aqt/clayout.py @@ -174,10 +174,10 @@ class CardLayout(QDialog): jsinc = ["jquery.js","browsersel.js", "mathjax/conf.js", "mathjax/MathJax.js", "reviewer.js"] - pform.frontWeb.stdHtml(self.mw.reviewer._revHtml, + pform.frontWeb.stdHtml(self.mw.reviewer.revHtml(), css=["reviewer.css"], head=base, js=jsinc) - pform.backWeb.stdHtml(self.mw.reviewer._revHtml, + pform.backWeb.stdHtml(self.mw.reviewer.revHtml(), css=["reviewer.css"], head=base, js=jsinc) @@ -290,7 +290,8 @@ Please create a new card type first.""")) q = ti(mungeQA(self.mw.col, c.q(reload=True))) a = ti(mungeQA(self.mw.col, c.a()), type='a') - self.pform.frontWeb.eval("_showQuestion(%s,'%s');" % (json.dumps(q), bodyclass)) + # use _showAnswer to avoid the longer delay + self.pform.frontWeb.eval("_showAnswer(%s,'%s');" % (json.dumps(q), bodyclass)) self.pform.backWeb.eval("_showAnswer(%s, '%s');" % (json.dumps(a), bodyclass)) clearAudioQueue() diff --git a/aqt/reviewer.py b/aqt/reviewer.py index fd7811d19..f341dda1f 100644 --- a/aqt/reviewer.py +++ b/aqt/reviewer.py @@ -117,16 +117,19 @@ class Reviewer: # Initializing the webview ########################################################################## - _revHtml = """ + def revHtml(self): + extra = self.mw.col.conf.get("reviewExtra", "") + return f"""
+{extra} """ def _initWeb(self): self._reps = 0 base = self.mw.baseHTML() # main window - self.web.stdHtml(self._revHtml, + self.web.stdHtml(self.revHtml(), head=base, css=["reviewer.css"], js=["jquery.js",