anki/qt/aqt/data/web/js/reviewer-bottom.ts

54 lines
1.2 KiB
TypeScript
Raw Normal View History

2019-02-05 04:59:03 +01:00
/* Copyright: Ankitects Pty Ltd and contributors
* License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */
2019-12-18 04:27:39 +01:00
var time: number; // set in python code
2019-12-18 04:27:39 +01:00
let maxTime = 0;
2020-06-24 13:54:38 +02:00
$(function () {
$("#ansbut").focus();
updateTime();
2020-06-24 13:54:38 +02:00
setInterval(function () {
time += 1;
2019-12-18 07:12:39 +01:00
updateTime();
}, 1000);
});
2020-06-24 13:54:38 +02:00
let updateTime = function () {
2019-12-18 04:27:39 +01:00
let timeNode = $("#time");
if (!maxTime) {
2017-07-28 08:48:49 +02:00
timeNode.text("");
return;
}
time = Math.min(maxTime, time);
2019-12-18 04:27:39 +01:00
const m = Math.floor(time / 60);
const s = time % 60;
let sStr = s.toString();
if (s < 10) {
2019-12-18 04:27:39 +01:00
sStr = "0" + s;
}
2017-07-28 08:48:49 +02:00
if (maxTime === time) {
2019-12-18 04:27:39 +01:00
timeNode.html("<font color=red>" + m + ":" + sStr + "</font>");
} else {
2019-12-18 04:27:39 +01:00
timeNode.text(m + ":" + sStr);
}
2017-07-28 08:48:49 +02:00
};
function showQuestion(txt, maxTime_) {
// much faster than jquery's .html()
$("#middle")[0].innerHTML = txt;
time = 0;
maxTime = maxTime_;
}
function showAnswer(txt) {
$("#middle")[0].innerHTML = txt;
}
function selectedAnswerButton() {
2019-12-18 04:27:39 +01:00
let node = document.activeElement as HTMLElement;
if (!node) {
return;
}
return node.dataset.ease;
}