File: reviewer-bottom.js

package info (click to toggle)
anki 2.1.8%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,976 kB
  • sloc: python: 26,992; xml: 67; sh: 49; makefile: 45
file content (51 lines) | stat: -rw-r--r-- 1,047 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
var time; // set in python code

var maxTime = 0;
$(function () {
    $("#ansbut").focus();
    updateTime();
    setInterval(function () {
        time += 1;
        updateTime()
    }, 1000);
});

var updateTime = function () {
    var timeNode = $("#time");
    if (!maxTime) {
        timeNode.text("");
        return;
    }
    time = Math.min(maxTime, time);
    var m = Math.floor(time / 60);
    var s = time % 60;
    if (s < 10) {
        s = "0" + s;
    }
    if (maxTime === time) {
        timeNode.html("<font color=red>" + m + ":" + s + "</font>");
    } else {
        timeNode.text(m + ":" + s);
    }
};

function showQuestion(txt, maxTime_) {
    // much faster than jquery's .html()
    $("#middle")[0].innerHTML = txt;
    $("#ansbut").focus();
    time = 0;
    maxTime = maxTime_;
}

function showAnswer(txt) {
    $("#middle")[0].innerHTML = txt;
    $("#defease").focus();
}

function selectedAnswerButton() {
    var node = document.activeElement;
    if (!node) {
        return;
    }
    return node.dataset.ease;
}