mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-11-10 22:22:21 +08:00
added a custom time button
This commit is contained in:
parent
e4551b4138
commit
8ccd81d542
2 changed files with 14 additions and 2 deletions
|
|
@ -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">
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue