mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 06:52:21 -04:00
reuse the bottom webview too; avoid .html()
This commit is contained in:
parent
ada11b246b
commit
ff514103ed
2 changed files with 30 additions and 14 deletions
|
@ -412,7 +412,7 @@ class Editor(object):
|
||||||
self.note = note
|
self.note = note
|
||||||
# change timer
|
# change timer
|
||||||
if self.note:
|
if self.note:
|
||||||
self.web.setHtml(_html % (getBase(self.mw.col), anki.js.all,
|
self.web.setHtml(_html % (getBase(self.mw.col), anki.js.jquery,
|
||||||
(isMac or isWin) and 1 or 0,
|
(isMac or isWin) and 1 or 0,
|
||||||
_("Show Duplicates")),
|
_("Show Duplicates")),
|
||||||
loadCB=self._loadFinished)
|
loadCB=self._loadFinished)
|
||||||
|
|
|
@ -93,7 +93,7 @@ class Reviewer(object):
|
||||||
var ankiPlatform = "desktop";
|
var ankiPlatform = "desktop";
|
||||||
var typeans;
|
var typeans;
|
||||||
function _updateQA (q, answerMode) {
|
function _updateQA (q, answerMode) {
|
||||||
$("#qa").html(q);
|
$("#qa")[0].innerHTML = q;
|
||||||
typeans = document.getElementById("typeans");
|
typeans = document.getElementById("typeans");
|
||||||
if (typeans) {
|
if (typeans) {
|
||||||
typeans.focus();
|
typeans.focus();
|
||||||
|
@ -117,10 +117,17 @@ function _typeAnsPress() {
|
||||||
|
|
||||||
def _initWeb(self):
|
def _initWeb(self):
|
||||||
self._reps = 0
|
self._reps = 0
|
||||||
|
self._bottomReady = False
|
||||||
base = getBase(self.mw.col)
|
base = getBase(self.mw.col)
|
||||||
|
# main window
|
||||||
self.web.stdHtml(self._revHtml, self._styles(),
|
self.web.stdHtml(self._revHtml, self._styles(),
|
||||||
bodyClass="card", loadCB=lambda x: self._showQuestion(),
|
bodyClass="card", loadCB=lambda x: self._showQuestion(),
|
||||||
head=base)
|
head=base)
|
||||||
|
# show answer / ease buttons
|
||||||
|
self.bottom.web.stdHtml(
|
||||||
|
self._bottomHTML(),
|
||||||
|
self.bottom._css + self._bottomCSS,
|
||||||
|
loadCB=lambda x: self._showAnswerButton())
|
||||||
|
|
||||||
# Showing the question
|
# Showing the question
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
@ -141,8 +148,8 @@ function _typeAnsPress() {
|
||||||
q = self._mungeQA(q)
|
q = self._mungeQA(q)
|
||||||
self.web.eval("_updateQA(%s);" % simplejson.dumps(q))
|
self.web.eval("_updateQA(%s);" % simplejson.dumps(q))
|
||||||
t = time.time()
|
t = time.time()
|
||||||
|
if self._bottomReady:
|
||||||
self._showAnswerButton()
|
self._showAnswerButton()
|
||||||
print (time.time() - t)*1000
|
|
||||||
# if we have a type answer field, focus main web
|
# if we have a type answer field, focus main web
|
||||||
if self.typeCorrect:
|
if self.typeCorrect:
|
||||||
self.mw.web.setFocus()
|
self.mw.web.setFocus()
|
||||||
|
@ -393,7 +400,7 @@ td { font-weight: bold; font-size: 12px; }
|
||||||
.spacer2 { height: 16px; }
|
.spacer2 { height: 16px; }
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _bottomHTML(self, middle):
|
def _bottomHTML(self):
|
||||||
if not self.card.deckConf().get('timer'):
|
if not self.card.deckConf().get('timer'):
|
||||||
maxTime = 0
|
maxTime = 0
|
||||||
else:
|
else:
|
||||||
|
@ -404,8 +411,7 @@ td { font-weight: bold; font-size: 12px; }
|
||||||
<td align=left width=50 valign=top class=stat>
|
<td align=left width=50 valign=top class=stat>
|
||||||
<br>
|
<br>
|
||||||
<button onclick="py.link('edit');">%(edit)s</button></td>
|
<button onclick="py.link('edit');">%(edit)s</button></td>
|
||||||
<td align=center valign=top>
|
<td align=center valign=top id=middle>
|
||||||
%(middle)s
|
|
||||||
</td>
|
</td>
|
||||||
<td width=50 align=right valign=top class=stat><span id=time class=stattxt>
|
<td width=50 align=right valign=top class=stat><span id=time class=stattxt>
|
||||||
</span><br>
|
</span><br>
|
||||||
|
@ -434,12 +440,25 @@ var updateTime = function () {
|
||||||
var e = $("#time").text(time);
|
var e = $("#time").text(time);
|
||||||
e.text(m + ":" + s);
|
e.text(m + ":" + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showQuestion(txt) {
|
||||||
|
// much faster than jquery's .html()
|
||||||
|
$("#middle")[0].innerHTML = txt;
|
||||||
|
$("#ansbut").focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
function showAnswer(txt) {
|
||||||
|
$("#middle")[0].innerHTML = txt;
|
||||||
|
$("#defease").focus();
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
""" % dict(middle=middle, rem=self._remaining(), edit=_("Edit"),
|
""" % dict(rem=self._remaining(), edit=_("Edit"),
|
||||||
more=_("More"), time=self.card.timeTaken()/1000,
|
more=_("More"), time=self.card.timeTaken()/1000,
|
||||||
maxTime=maxTime)
|
maxTime=maxTime)
|
||||||
|
|
||||||
def _showAnswerButton(self):
|
def _showAnswerButton(self):
|
||||||
|
self._bottomReady = True
|
||||||
self.bottom.web.setFocus()
|
self.bottom.web.setFocus()
|
||||||
middle = '''
|
middle = '''
|
||||||
<span class=stattxt>%s</span><br>
|
<span class=stattxt>%s</span><br>
|
||||||
|
@ -447,15 +466,12 @@ var updateTime = function () {
|
||||||
self._remaining(), _("Show Answer"))
|
self._remaining(), _("Show Answer"))
|
||||||
# wrap it in a table so it has the same top margin as the ease buttons
|
# wrap it in a table so it has the same top margin as the ease buttons
|
||||||
middle = "<table cellpadding=0><tr><td class=stat2 align=center>%s</td></tr></table>" % middle
|
middle = "<table cellpadding=0><tr><td class=stat2 align=center>%s</td></tr></table>" % middle
|
||||||
self.bottom.web.stdHtml(
|
self.bottom.web.eval("showQuestion(%s);" % simplejson.dumps(middle))
|
||||||
self._bottomHTML(middle),
|
|
||||||
self.bottom._css + self._bottomCSS)
|
|
||||||
|
|
||||||
def _showEaseButtons(self):
|
def _showEaseButtons(self):
|
||||||
self.bottom.web.setFocus()
|
self.bottom.web.setFocus()
|
||||||
self.bottom.web.stdHtml(
|
middle = self._answerButtons()
|
||||||
self._bottomHTML(self._answerButtons()),
|
self.bottom.web.eval("showAnswer(%s);" % simplejson.dumps(middle))
|
||||||
self.bottom._css + self._bottomCSS)
|
|
||||||
|
|
||||||
def _remaining(self):
|
def _remaining(self):
|
||||||
if not self.mw.col.conf['dueCounts']:
|
if not self.mw.col.conf['dueCounts']:
|
||||||
|
|
Loading…
Reference in a new issue