Skip to content

Commit 5597e11

Browse files
committed
added custom words button
1 parent 702d18c commit 5597e11

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

public/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
<div class="button active" wordCount="50" tabindex="2">50</div>
132132
<div class="button" wordCount="100" tabindex="2">100</div>
133133
<div class="button" wordCount="200" tabindex="2">200</div>
134+
<div class="button" wordCount="custom" tabindex="2"><i class="fas fa-tools"></i></div>
134135
</div>
135136
</div>
136137
<div class="group time hidden">
@@ -140,7 +141,7 @@
140141
<div class="button active" timeConfig="30" tabindex="2">30</div>
141142
<div class="button" timeConfig="60" tabindex="2">60</div>
142143
<div class="button" timeConfig="120" tabindex="2">120</div>
143-
<div class="button" timeConfig="custom" tabindex="2"><i class="far fa-clock"></i></div>
144+
<div class="button" timeConfig="custom" tabindex="2"><i class="fas fa-tools"></i></div>
144145
</div>
145146
</div>
146147
<div class="group customText hidden">

public/js/script.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -657,9 +657,13 @@ function changeCustomText() {
657657
}
658658

659659
function changeWordCount(wordCount) {
660+
wordCount = parseInt(wordCount);
660661
changeMode("words");
661-
config.words = parseInt(wordCount);
662+
config.words = wordCount;
662663
$("#top .config .wordCount .button").removeClass("active");
664+
if(![10,25,50,100,200].includes(wordCount)){
665+
wordCount = "custom";
666+
}
663667
$("#top .config .wordCount .button[wordCount='" + wordCount + "']").addClass(
664668
"active"
665669
);
@@ -861,8 +865,15 @@ $(document).on("click", "#top .logo", (e) => {
861865
});
862866

863867
$(document).on("click", "#top .config .wordCount .button", (e) => {
864-
wrd = e.currentTarget.innerHTML;
865-
changeWordCount(wrd);
868+
wrd = $(e.currentTarget).attr('wordCount');
869+
if(wrd == "custom"){
870+
let newWrd = prompt('Custom word amount');
871+
if(newWrd !== null && !isNaN(newWrd) && newWrd > 0){
872+
changeWordCount(newWrd);
873+
}
874+
}else{
875+
changeWordCount(wrd);
876+
}
866877
});
867878

868879
$(document).on("click", "#top .config .time .button", (e) => {

0 commit comments

Comments
 (0)