let total = 0;
let average = 0;
$(document).ready(function() {
let tryNbr = 1;
let timeDiff = null;
let startSession = $(".startSession");
let titleInfo = $(".title-info");
let introP = $(".intro p");
let highlightBlue = $(".highlight-blue");
let totalTries = $('#totalTries');
let clicked = 0;
$(".average-title").hide();
startSession.click(function(e) {
e.stopPropagation();
e.preventDefault();
titleInfo.html("Wait for the green...");
introP.hide();
startSession.hide();
waitGreenTime();
});
function waitGreenTime() {
$(".average-title").hide();
highlightBlue.off();
highlightBlue.css("cursor", "pointer");
highlightBlue.animate({
height: "600",
});
let waitGreen = Math.floor(Math.random() * 4 + 2);
console.log("Green will be shown in: " + waitGreen + "s");
highlightBlue.click(function() {
tooSoon();
});
setTimeout(showGreen, waitGreen * 1000)
}
function showGreen() {
highlightBlue.off();
titleInfo.hide();
highlightBlue.css("background-color", "green");
startTime = new Date();
highlightBlue.click(function() {
endTime = new Date();
timeDiff = endTime - startTime;
console.log(timeDiff);
results(timeDiff);
});
}
function results(timeDiff) {
highlightBlue.off();
titleInfo.html("Your reaction time: " + timeDiff + "ms");
titleInfo.show();
introP.html("To see your previous stats check the table down below.").show();;
startSession.show();
highlightBlue.animate({
height: "327",
});
highlightBlue.css({
"background-color": "#131620",
"cursor": "default"
});
摇曳的蔷薇
FFIVE
相关分类