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
|
2017-07-28 08:19:06 +02:00
|
|
|
|
2019-12-18 04:27:39 +01:00
|
|
|
let maxTime = 0;
|
2019-12-18 07:12:39 +01:00
|
|
|
$(function() {
|
2017-07-28 08:19:06 +02:00
|
|
|
$("#ansbut").focus();
|
|
|
|
updateTime();
|
2019-12-18 07:12:39 +01:00
|
|
|
setInterval(function() {
|
2017-07-28 08:19:06 +02:00
|
|
|
time += 1;
|
2019-12-18 07:12:39 +01:00
|
|
|
updateTime();
|
2017-07-28 08:19:06 +02:00
|
|
|
}, 1000);
|
|
|
|
});
|
|
|
|
|
2019-12-18 07:12:39 +01:00
|
|
|
let updateTime = function() {
|
2019-12-18 04:27:39 +01:00
|
|
|
let 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);
|
2019-12-18 04:27:39 +01:00
|
|
|
const m = Math.floor(time / 60);
|
|
|
|
const s = time % 60;
|
|
|
|
let sStr = s.toString();
|
2017-07-28 08:19:06 +02:00
|
|
|
if (s < 10) {
|
2019-12-18 04:27:39 +01:00
|
|
|
sStr = "0" + s;
|
2017-07-28 08:19:06 +02:00
|
|
|
}
|
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>");
|
2017-07-28 08:19:06 +02:00
|
|
|
} else {
|
2019-12-18 04:27:39 +01:00
|
|
|
timeNode.text(m + ":" + sStr);
|
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() {
|
2019-12-18 04:27:39 +01:00
|
|
|
let node = document.activeElement as HTMLElement;
|
2018-09-24 06:16:08 +02:00
|
|
|
if (!node) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
return node.dataset.ease;
|
|
|
|
}
|