mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
show indicator on marked cards; fix type answer bug
This commit is contained in:
parent
830d8ead25
commit
608d2c77ba
2 changed files with 27 additions and 3 deletions
|
@ -22,6 +22,7 @@ class Reviewer(object):
|
||||||
self.cardQueue = []
|
self.cardQueue = []
|
||||||
self.hadCardQueue = False
|
self.hadCardQueue = False
|
||||||
self._answeredIds = []
|
self._answeredIds = []
|
||||||
|
self.typeCorrect = None # web init happens before this is set
|
||||||
self.state = None
|
self.state = None
|
||||||
self.bottom = aqt.toolbar.BottomBar(mw, mw.bottomWeb)
|
self.bottom = aqt.toolbar.BottomBar(mw, mw.bottomWeb)
|
||||||
addHook("leech", self.onLeech)
|
addHook("leech", self.onLeech)
|
||||||
|
@ -95,6 +96,7 @@ class Reviewer(object):
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
_revHtml = """
|
_revHtml = """
|
||||||
|
<img src="qrc:/icons/rating.png" class=marked>
|
||||||
<div id=qa></div>
|
<div id=qa></div>
|
||||||
<script>
|
<script>
|
||||||
var ankiPlatform = "desktop";
|
var ankiPlatform = "desktop";
|
||||||
|
@ -109,6 +111,15 @@ function _updateQA (q, answerMode) {
|
||||||
window.location = "#answer";
|
window.location = "#answer";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function _toggleStar (show) {
|
||||||
|
if (show) {
|
||||||
|
$(".marked").show();
|
||||||
|
} else {
|
||||||
|
$(".marked").hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function _getTypedText () {
|
function _getTypedText () {
|
||||||
if (typeans) {
|
if (typeans) {
|
||||||
py.link("typeans:"+typeans.value);
|
py.link("typeans:"+typeans.value);
|
||||||
|
@ -155,7 +166,8 @@ function _typeAnsPress() {
|
||||||
playFromText(q)
|
playFromText(q)
|
||||||
# render & update bottom
|
# render & update bottom
|
||||||
q = self._mungeQA(q)
|
q = self._mungeQA(q)
|
||||||
self.web.eval("_updateQA(%s);" % simplejson.dumps(q))
|
self.web.eval("_updateQA(%s, false);" % simplejson.dumps(q))
|
||||||
|
self._toggleStar()
|
||||||
if self._bottomReady:
|
if self._bottomReady:
|
||||||
self._showAnswerButton()
|
self._showAnswerButton()
|
||||||
# if we have a type answer field, focus main web
|
# if we have a type answer field, focus main web
|
||||||
|
@ -168,6 +180,10 @@ function _typeAnsPress() {
|
||||||
return self.mw.col.decks.confForDid(
|
return self.mw.col.decks.confForDid(
|
||||||
self.card.odid or self.card.did)['autoplay']
|
self.card.odid or self.card.did)['autoplay']
|
||||||
|
|
||||||
|
def _toggleStar(self):
|
||||||
|
self.web.eval("_toggleStar(%s);" % simplejson.dumps(
|
||||||
|
self.card.note().hasTag("marked")))
|
||||||
|
|
||||||
# Showing the answer
|
# Showing the answer
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
@ -222,7 +238,7 @@ function _typeAnsPress() {
|
||||||
elif key == "r":
|
elif key == "r":
|
||||||
self.replayAudio()
|
self.replayAudio()
|
||||||
elif key == "*":
|
elif key == "*":
|
||||||
self.mw.onMark()
|
self.onMark()
|
||||||
elif key == "-":
|
elif key == "-":
|
||||||
self.mw.onBuryNote()
|
self.mw.onBuryNote()
|
||||||
elif key == "=":
|
elif key == "=":
|
||||||
|
@ -256,6 +272,7 @@ function _typeAnsPress() {
|
||||||
hr { background-color:#ccc; margin: 1em; }
|
hr { background-color:#ccc; margin: 1em; }
|
||||||
body { margin:1.5em; }
|
body { margin:1.5em; }
|
||||||
img { max-width: 95%; max-height: 95%; }
|
img { max-width: 95%; max-height: 95%; }
|
||||||
|
.marked { position:absolute; right: 7; top: 7; display: none; }
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _styles(self):
|
def _styles(self):
|
||||||
|
@ -576,7 +593,7 @@ function showAnswer(txt) {
|
||||||
def showContextMenu(self):
|
def showContextMenu(self):
|
||||||
opts = [
|
opts = [
|
||||||
[_("Replay Audio"), "r", self.replayAudio],
|
[_("Replay Audio"), "r", self.replayAudio],
|
||||||
[_("Mark Note"), "*", self.mw.onMark],
|
[_("Mark Note"), "*", self.onMark],
|
||||||
[_("Bury Note"), "-", self.mw.onBuryNote],
|
[_("Bury Note"), "-", self.mw.onBuryNote],
|
||||||
[_("Suspend Note"), "=", self.mw.onSuspend],
|
[_("Suspend Note"), "=", self.mw.onSuspend],
|
||||||
[_("Delete Note"), "Delete", self.mw.onDelete],
|
[_("Delete Note"), "Delete", self.mw.onDelete],
|
||||||
|
@ -593,3 +610,10 @@ function showAnswer(txt) {
|
||||||
self.mw.onDeckConf(self.mw.col.decks.get(
|
self.mw.onDeckConf(self.mw.col.decks.get(
|
||||||
self.card.odid or self.card.did))
|
self.card.odid or self.card.did))
|
||||||
|
|
||||||
|
def onMark(self):
|
||||||
|
f = self.card.note()
|
||||||
|
if f.hasTag("marked"):
|
||||||
|
f.delTag("marked")
|
||||||
|
else:
|
||||||
|
f.addTag("marked")
|
||||||
|
self._toggleStar()
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1 KiB |
Loading…
Reference in a new issue