added a custom time button

This commit is contained in:
unknown 2020-05-22 19:23:15 +01:00
parent e4551b4138
commit 8ccd81d542
2 changed files with 14 additions and 2 deletions

View file

@ -137,6 +137,7 @@
<div class="button active" timeConfig="30" tabindex="2">30</div>
<div class="button" timeConfig="60" tabindex="2">60</div>
<div class="button" timeConfig="120" tabindex="2">120</div>
<div class="button" timeConfig="custom" tabindex="2"><i class="far fa-clock"></i></div>
</div>
</div>
<div class="group customText hidden">

View file

@ -645,9 +645,13 @@ function changeWordCount(wordCount) {
}
function changeTimeConfig(time) {
time = parseInt(time);
changeMode("time");
config.time = time;
$("#top .config .time .button").removeClass("active");
if(![15,30,60,120].includes(time)){
time = "custom";
}
$("#top .config .time .button[timeConfig='" + time + "']").addClass("active");
restartTest();
saveConfigToCookie();
@ -839,8 +843,15 @@ $(document).on("click", "#top .config .wordCount .button", (e) => {
});
$(document).on("click", "#top .config .time .button", (e) => {
time = e.currentTarget.innerHTML;
changeTimeConfig(time);
time = $(e.currentTarget).attr('timeConfig');
if(time == "custom"){
let newTime = prompt('Custom time in seconds');
if(newTime !== null && !isNaN(newTime) && newTime > 0){
changeTimeConfig(newTime);
}
}else{
changeTimeConfig(time);
}
});
$(document).on("click", "#top .config .customText .button", (e) => {