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 */
|
|
|
|
|
2017-07-28 08:19:06 +02:00
|
|
|
var time; // set in python code
|
|
|
|
|
|
|
|
var maxTime = 0;
|
|
|
|
$(function () {
|
|
|
|
$("#ansbut").focus();
|
|
|
|
updateTime();
|
|
|
|
setInterval(function () {
|
|
|
|
time += 1;
|
|
|
|
updateTime()
|
|
|
|
}, 1000);
|
|
|
|
});
|
|
|
|
|
|
|
|
var updateTime = function () {
|
2017-07-28 08:48:49 +02:00
|
|
|
var timeNode = $("#time");
|
2017-07-28 08:19:06 +02:00
|
|
|
if (!maxTime) {
|
2017-07-28 08:48:49 +02:00
|
|
|
timeNode.text("");
|
2017-07-28 08:19:06 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
time = Math.min(maxTime, time);
|
|
|
|
var m = Math.floor(time / 60);
|
|
|
|
var s = time % 60;
|
|
|
|
if (s < 10) {
|
|
|
|
s = "0" + s;
|
|
|
|
}
|
2017-07-28 08:48:49 +02:00
|
|
|
if (maxTime === time) {
|
|
|
|
timeNode.html("<font color=red>" + m + ":" + s + "</font>");
|
2017-07-28 08:19:06 +02:00
|
|
|
} else {
|
2017-07-28 08:48:49 +02:00
|
|
|
timeNode.text(m + ":" + s);
|
2017-07-28 08:19:06 +02:00
|
|
|
}
|
2017-07-28 08:48:49 +02:00
|
|
|
};
|
2017-07-28 08:19:06 +02:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
2018-09-24 06:16:08 +02:00
|
|
|
|
|
|
|
function selectedAnswerButton() {
|
|
|
|
var node = document.activeElement;
|
|
|
|
if (!node) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
return node.dataset.ease;
|
|
|
|
}
|