mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-03-11 22:23:32 +08:00
added custom words button
This commit is contained in:
parent
702d18c6f6
commit
5597e1138a
2 changed files with 16 additions and 4 deletions
|
@ -131,6 +131,7 @@
|
|||
<div class="button active" wordCount="50" tabindex="2">50</div>
|
||||
<div class="button" wordCount="100" tabindex="2">100</div>
|
||||
<div class="button" wordCount="200" tabindex="2">200</div>
|
||||
<div class="button" wordCount="custom" tabindex="2"><i class="fas fa-tools"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="group time hidden">
|
||||
|
@ -140,7 +141,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 class="button" timeConfig="custom" tabindex="2"><i class="fas fa-tools"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="group customText hidden">
|
||||
|
|
|
@ -657,9 +657,13 @@ function changeCustomText() {
|
|||
}
|
||||
|
||||
function changeWordCount(wordCount) {
|
||||
wordCount = parseInt(wordCount);
|
||||
changeMode("words");
|
||||
config.words = parseInt(wordCount);
|
||||
config.words = wordCount;
|
||||
$("#top .config .wordCount .button").removeClass("active");
|
||||
if(![10,25,50,100,200].includes(wordCount)){
|
||||
wordCount = "custom";
|
||||
}
|
||||
$("#top .config .wordCount .button[wordCount='" + wordCount + "']").addClass(
|
||||
"active"
|
||||
);
|
||||
|
@ -861,8 +865,15 @@ $(document).on("click", "#top .logo", (e) => {
|
|||
});
|
||||
|
||||
$(document).on("click", "#top .config .wordCount .button", (e) => {
|
||||
wrd = e.currentTarget.innerHTML;
|
||||
changeWordCount(wrd);
|
||||
wrd = $(e.currentTarget).attr('wordCount');
|
||||
if(wrd == "custom"){
|
||||
let newWrd = prompt('Custom word amount');
|
||||
if(newWrd !== null && !isNaN(newWrd) && newWrd > 0){
|
||||
changeWordCount(newWrd);
|
||||
}
|
||||
}else{
|
||||
changeWordCount(wrd);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("click", "#top .config .time .button", (e) => {
|
||||
|
|
Loading…
Reference in a new issue