global reviewer override, fix fading in previewer/clayout

you can use the debug console to define custom html/css/js to be added
to the bottom of the reviewer on all note types, so to increase the fade
time on the question you'd use

mw.col.conf["reviewExtra"]="<script>qFade=500;</script>"
mw.col.setMod()

also make sure the fading for question/answer is used correctly in
previewer, and use answer fading in clayout to speed it up
This commit is contained in:
Damien Elmes 2017-08-10 21:39:04 +10:00
parent 85d4511766
commit 55b782581d
3 changed files with 13 additions and 7 deletions

View file

@ -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
######################################################################

View file

@ -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()

View file

@ -117,16 +117,19 @@ class Reviewer:
# Initializing the webview
##########################################################################
_revHtml = """
def revHtml(self):
extra = self.mw.col.conf.get("reviewExtra", "")
return f"""
<img src="qrc:/icons/rating.png" id=star class=marked>
<div id=qa></div>
{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",