diff --git a/aqt/browser.py b/aqt/browser.py
index c12d166c7..0c24a81aa 100644
--- a/aqt/browser.py
+++ b/aqt/browser.py
@@ -1445,9 +1445,7 @@ class BrowserToolbar(Toolbar):
right += borderImg("mark", "star16", mark)
right += borderImg("pause", "pause16", pause)
self.web.stdHtml(self._body % (
- " "+
- "%s"%_("On Selected:"),
- #' '*20, #Browser ▾',
+ "",
self._centerLinks(),
right), self._css, focus=False)
diff --git a/aqt/deckbrowser.py b/aqt/deckbrowser.py
index 4623711c5..9c226ebbd 100644
--- a/aqt/deckbrowser.py
+++ b/aqt/deckbrowser.py
@@ -43,15 +43,12 @@ class DeckBrowser(object):
##########################################################################
_css = """
-.sub { color: #555; }
a.deck { color: #000; text-decoration: none; font-size: 12px; }
-.num { text-align: right; padding: 0 5 0 5; }
+a.deck:hover { text-decoration: underline; }
td.opts { white-space: nowrap; }
td.deck { width: 90% }
-a { font-size: 80%; }
.extra { font-size: 90%; }
-.due { vertical-align: text-bottom; }
-body { margin: 1em; }
+body { margin: 1em; -webkit-user-select: none; }
"""
_body = """
diff --git a/aqt/main.py b/aqt/main.py
index 3c4ca6b7a..18f266e93 100755
--- a/aqt/main.py
+++ b/aqt/main.py
@@ -291,7 +291,6 @@ body {
background: #f3f3f3;
margin: 2em;
}
-a:hover { background-color: #aaa; }
h1 { margin-bottom: 0.2em; }
hr { margin:5 0 5 0; border:0; height:1px; background-color:#ccc; }
"""
diff --git a/aqt/reviewer.py b/aqt/reviewer.py
index ed0c65d86..6a6b28657 100644
--- a/aqt/reviewer.py
+++ b/aqt/reviewer.py
@@ -2,7 +2,7 @@
# Copyright: Damien Elmes
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-import time, os, stat, shutil, difflib, simplejson
+import time, os, stat, shutil, difflib, simplejson, re
import unicodedata as ucd
from aqt.qt import *
from anki.utils import fmtTimeSpan, stripHTML
@@ -33,6 +33,8 @@ class Reviewer(object):
else:
self.nextCard()
self.keep = False
+ self.bottom.web.setFixedHeight(60)
+ self.bottom.web.setLinkHandler(self._linkHandler)
def lastCard(self):
if self._answeredIds:
@@ -55,7 +57,6 @@ class Reviewer(object):
clearAudioQueue()
if c:
#self.updateMarkAction()
- self.state = "question"
self._initWeb()
else:
self.mw.moveToState("overview")
@@ -82,19 +83,11 @@ var hideq;
var ans;
var typeans;
function _updateQA (q) {
- location.hash = "";
- $("#qa").html(q[0]);
- $("#qa:first").css("height", "100%%");
- //$("#easebuts").html(q[1]).addClass("inv");
- //$("#ansbut").show();
+ $("#qa").html(q);
typeans = document.getElementById("typeans");
if (typeans) {
typeans.focus();
}
- // user hook
- if (typeof(onQuestion) === "function") {
- onQuestion();
- }
};
function _showans (a) {
$("#qa").html(a);
@@ -110,10 +103,6 @@ function _showans (a) {
}
//$("#ansbut").hide();
$("#defease").focus();
- // user hook
- if (typeof(onAnswer) === "function") {
- onAnswer();
- }
};
function _processTyped (res) {
$("#typeans").replaceWith(res);
@@ -135,32 +124,31 @@ $(".ansbut").focus();
"""
def _initWeb(self):
- self.web.stdHtml(self._revHtml % dict(
- showans=_("Show Answer")), self._styles(),
- bodyID="card",
- loadCB=lambda x: self._showQuestion())
+ self.web.stdHtml(self._revHtml, self._styles(),
+ bodyID="card", loadCB=lambda x: self._showQuestion())
- # Showing the question (and preparing answer)
+ # Showing the question
##########################################################################
+ def _mungeQA(self, buf):
+ return self.mw.col.media.escapeImages(
+ self.prepareTypeAns(mungeQA(buf)))
+
def _showQuestion(self):
- # fixme: timeboxing
- # fixme: timer
self.state = "question"
c = self.card
# mod the card so it shows up in the recently modified list
- self.card.flush()
+ c.flush()
+ # grab the question and play audio
q = c.q()
- a = c.a()
if self.mw.pm.profile['autoplay']:
playFromText(q)
# render
- esc = self.mw.col.media.escapeImages
- q=esc(mungeQA(q)) + self.typeAnsInput()
- a=esc(mungeQA(a))
- self.web.eval("_updateQA(%s);" % simplejson.dumps(
- (q, self._answerButtons())))
+ q = self._mungeQA(q)
+ self.web.eval("_updateQA(%s);" % simplejson.dumps(q))
runHook('showQuestion')
+ # and refresh bottom bar
+ self._showAnswerButton()
# Showing the answer
##########################################################################
@@ -254,6 +242,7 @@ $(".ansbut").focus();
def _linkHandler(self, url):
if url == "ans":
+ print "show ans"
self._showAnswer()
elif url.startswith("ease"):
self._answerCard(int(url[4:]))
@@ -350,22 +339,28 @@ div#filler {
failedCharColour = "#FF0000"
passedCharColour = "#00FF00"
- def typeAns(self):
- "None if answer typing disabled."
- print "typeAns()"
- return False
- self.card.template()['typeAns']
-
- def typeAnsInput(self):
- if not self.typeAns():
- return ""
- return """
+ def prepareTypeAns(self, buf):
+ self.typeField = None
+ pat = "\[\[type:(.+?)\]\]"
+ m = re.search(pat, buf)
+ if not m:
+ return buf
+ fld = m.group(1)
+ print "got", fld
+ fobj = None
+ for f in self.card.model()['flds']:
+ if f['name'] == fld:
+ fobj = f
+ break
+ if not fobj:
+ return re.sub(pat, _("Type answer: unknown field %s") % fld, buf)
+ self.typeField = fobj
+ return re.sub(pat, """
-""" % (
- self.getFont())
+""" % (fobj['font'], fobj['size']), buf)
def processTypedAns(self, given):
ord = self.typeAns()
@@ -440,6 +435,49 @@ div#filler {
lastEqual = ""
return ret + self.ok(lastEqual)
+ # Bottom bar
+ ##########################################################################
+
+ _bottomCSS = """
+body {
+background: -webkit-gradient(linear, left top, left bottom,
+from(#fff), to(#ddd));
+border-bottom: 0;
+border-top: 1px solid #aaa;
+margin: 0;
+padding: 5px;
+}
+td { font-weight: bold; font-size: 12px; }
+.hitem { padding: 0; }
+"""
+ _bottomQuestion = """
+
+
+0 + 0 + 0 |
+
+
+ |
+0:00 |
+
+
+
+
+"""
+
+ def _showAnswerButton(self):
+ self.bottom.web.stdHtml(
+ self._bottomQuestion % _("Show Answer"),
+ self.bottom._css + self._bottomCSS)
+
# Status bar
##########################################################################
diff --git a/aqt/toolbar.py b/aqt/toolbar.py
index 0f1bc21be..bf6e3aa1c 100644
--- a/aqt/toolbar.py
+++ b/aqt/toolbar.py
@@ -91,13 +91,12 @@ margin:0;
background: -webkit-gradient(linear, left top, left bottom,
from(#ddd), to(#fff));
font-weight: bold;
-margin-bottom: 1px;
-border-bottom: 1px solid #aaa;
}
body {
margin: 0; padding: 0;
-webkit-user-select: none;
+border-bottom: 1px solid #aaa;
}
* { -webkit-user-drag: none; }
@@ -119,9 +118,9 @@ background: -webkit-gradient(linear, left top, left bottom,
from(#fff), to(#ddd));
border-bottom: 0;
border-top: 1px solid #aaa;
-font-weight: normal;
margin-bottom: 6px;
}
+td { font-size: 12px; }
"""
_centerBody = """