Skip to content

Commit 9690765

Browse files
committed
feat: day 13
1 parent 83c852b commit 9690765

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

013-random choice picker/index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
</head>
99
<body>
1010
<div class="container">
11+
<!-- Improve the Instructions -->
1112
<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!
1415
</h3>
1516
<textarea placeholder="Enter choices here..." id="textarea"></textarea>
1617
</div>

013-random choice picker/script.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ const tagsElements = document.getElementById("tags");
22
const textarea = document.getElementById("textarea");
33

44
const createTags = (input) => {
5-
const tags = input
5+
// Prevent Duplicate Choices
6+
const tagsArray = input
67
.split(",")
78
.filter((tag) => tag.trim() !== "")
89
.map((tag) => tag.trim());
10+
const tags = [...new Set(tagsArray)];
911
tagsElements.innerHTML = "";
1012
tags.forEach((tag) => {
1113
const tagElement = document.createElement("span");
@@ -25,22 +27,24 @@ const highlightTag = (tag) => tag.classList.add("highlight");
2527
const unHighlightTag = (tag) => tag.classList.remove("highlight");
2628

2729
const randomSelect = () => {
28-
const times = 30;
30+
// Adjust Animation Speed
31+
const times = 15;
32+
const animationSpeed = 200;
2933
const interval = setInterval(() => {
3034
const randomTag = pickRandomTag();
3135
highlightTag(randomTag);
3236
setTimeout(() => {
3337
unHighlightTag(randomTag);
34-
}, 100);
35-
}, 100);
38+
}, animationSpeed);
39+
}, animationSpeed);
3640

3741
setTimeout(() => {
3842
clearInterval(interval);
3943
setTimeout(() => {
4044
const randomTag = pickRandomTag();
4145
highlightTag(randomTag);
42-
}, 100);
43-
}, times * 100);
46+
}, animationSpeed);
47+
}, times * animationSpeed);
4448
};
4549

4650
textarea.focus();

013-random choice picker/style.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ textarea:focus {
4242
}
4343

4444
.tag {
45-
background-color: #f0932b;
45+
/* Customize the Tag Colors */
46+
background-color: #353535;
4647
color: #fff;
4748
border-radius: 50px;
4849
padding: 10px 20px;
@@ -52,5 +53,5 @@ textarea:focus {
5253
}
5354

5455
.tag.highlight {
55-
background-color: #273c75;
56+
background-color: #6f2dbd;
5657
}

0 commit comments

Comments
 (0)