File tree Expand file tree Collapse file tree 3 files changed +16
-10
lines changed Expand file tree Collapse file tree 3 files changed +16
-10
lines changed Original file line number Diff line number Diff line change 8
8
</ head >
9
9
< body >
10
10
< div class ="container ">
11
+ <!-- Improve the Instructions -->
11
12
< h3 >
12
- Enter all of the choices divided by a comma (',' ).< br />
13
- Press enter when you're done
13
+ Can't decide? Enter your options below, separated by commas (", " ).< br />
14
+ Press Enter and let us pick for you!
14
15
</ h3 >
15
16
< textarea placeholder ="Enter choices here... " id ="textarea "> </ textarea >
16
17
</ div >
Original file line number Diff line number Diff line change @@ -2,10 +2,12 @@ const tagsElements = document.getElementById("tags");
2
2
const textarea = document . getElementById ( "textarea" ) ;
3
3
4
4
const createTags = ( input ) => {
5
- const tags = input
5
+ // Prevent Duplicate Choices
6
+ const tagsArray = input
6
7
. split ( "," )
7
8
. filter ( ( tag ) => tag . trim ( ) !== "" )
8
9
. map ( ( tag ) => tag . trim ( ) ) ;
10
+ const tags = [ ...new Set ( tagsArray ) ] ;
9
11
tagsElements . innerHTML = "" ;
10
12
tags . forEach ( ( tag ) => {
11
13
const tagElement = document . createElement ( "span" ) ;
@@ -25,22 +27,24 @@ const highlightTag = (tag) => tag.classList.add("highlight");
25
27
const unHighlightTag = ( tag ) => tag . classList . remove ( "highlight" ) ;
26
28
27
29
const randomSelect = ( ) => {
28
- const times = 30 ;
30
+ // Adjust Animation Speed
31
+ const times = 15 ;
32
+ const animationSpeed = 200 ;
29
33
const interval = setInterval ( ( ) => {
30
34
const randomTag = pickRandomTag ( ) ;
31
35
highlightTag ( randomTag ) ;
32
36
setTimeout ( ( ) => {
33
37
unHighlightTag ( randomTag ) ;
34
- } , 100 ) ;
35
- } , 100 ) ;
38
+ } , animationSpeed ) ;
39
+ } , animationSpeed ) ;
36
40
37
41
setTimeout ( ( ) => {
38
42
clearInterval ( interval ) ;
39
43
setTimeout ( ( ) => {
40
44
const randomTag = pickRandomTag ( ) ;
41
45
highlightTag ( randomTag ) ;
42
- } , 100 ) ;
43
- } , times * 100 ) ;
46
+ } , animationSpeed ) ;
47
+ } , times * animationSpeed ) ;
44
48
} ;
45
49
46
50
textarea . focus ( ) ;
Original file line number Diff line number Diff line change @@ -42,7 +42,8 @@ textarea:focus {
42
42
}
43
43
44
44
.tag {
45
- background-color : # f0932b ;
45
+ /* Customize the Tag Colors */
46
+ background-color : # 353535 ;
46
47
color : # fff ;
47
48
border-radius : 50px ;
48
49
padding : 10px 20px ;
@@ -52,5 +53,5 @@ textarea:focus {
52
53
}
53
54
54
55
.tag .highlight {
55
- background-color : # 273c75 ;
56
+ background-color : # 6f2dbd ;
56
57
}
You can’t perform that action at this time.
0 commit comments