Skip to content

Commit

Permalink
added custom words button
Browse files Browse the repository at this point in the history
  • Loading branch information
Miodec committed May 24, 2020
1 parent 702d18c commit 5597e11
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -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">
Expand Down
17 changes: 14 additions & 3 deletions public/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);
Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit 5597e11

Please sign in to comment.