Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 571f59e

Browse files
committed
fix stylelint and eslint errors
1 parent 5b13821 commit 571f59e

File tree

2 files changed

+92
-91
lines changed

2 files changed

+92
-91
lines changed

Source-Code/ChoicePicker/script.js

Lines changed: 55 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,60 @@
1-
const tagsEl = document.getElementById('tags')
2-
const textarea = document.getElementById('textarea')
1+
const tagsEl = document.getElementById('tags');
2+
const textarea = document.getElementById('textarea');
33

4-
textarea.focus()
4+
textarea.focus();
55

66
const createTags = (input) => {
7-
const tags = input.split(',').filter(tag=> tag.trim()!=='').map(tag => tag.trim())
8-
tagsEl.innerHTML = ''
9-
tags.forEach(tag => {
10-
const tagEl = document.createElement('span')
11-
tagEl.classList.add( 'tag')
12-
tagEl.innerText = tag
13-
tagsEl.appendChild(tagEl)
14-
15-
});
16-
}
17-
18-
const pickRandomTag = ()=>{
19-
const tags = document.querySelectorAll('.tag')
20-
return tags[Math.floor(Math.random()* tags.length)]
21-
}
22-
23-
const highlightTag = (tag)=>{
24-
tag.classList.add('highlight')
25-
}
26-
27-
const unHighlightTag = (tag)=>{
28-
tag.classList.remove('highlight')
29-
}
7+
const tags = input.split(',').filter((tag) => tag.trim() !== '').map((tag) => tag.trim());
8+
tagsEl.innerHTML = '';
9+
tags.forEach((tag) => {
10+
const tagEl = document.createElement('span');
11+
tagEl.classList.add('tag');
12+
tagEl.innerText = tag;
13+
tagsEl.appendChild(tagEl);
14+
});
15+
};
16+
17+
const pickRandomTag = () => {
18+
const tags = document.querySelectorAll('.tag');
19+
return tags[Math.floor(Math.random() * tags.length)];
20+
};
21+
22+
const highlightTag = (tag) => {
23+
tag.classList.add('highlight');
24+
};
25+
26+
const unHighlightTag = (tag) => {
27+
tag.classList.remove('highlight');
28+
};
3029

3130
const randomSelect = () => {
32-
const times = 30
33-
const interval = setInterval(()=>{
34-
const randomTag = pickRandomTag()
35-
highlightTag(randomTag)
36-
37-
setTimeout(()=>{
38-
unHighlightTag(randomTag)
39-
}, 100)
40-
}, 100)
41-
42-
setTimeout(()=>{
43-
clearInterval(interval)
44-
45-
setTimeout(()=>{
46-
const randomTag = pickRandomTag()
47-
48-
highlightTag(randomTag)
49-
}, 100)
50-
}, times * 100)
51-
}
52-
53-
textarea.addEventListener('keyup', (e) =>{
54-
createTags(e.target.value)
55-
if(e.key === 'Enter'){
56-
setTimeout(() => {
57-
e.target.value = ''
58-
}, 10)
59-
randomSelect()
60-
}
61-
})
31+
const times = 30;
32+
const interval = setInterval(() => {
33+
const randomTag = pickRandomTag();
34+
highlightTag(randomTag);
35+
36+
setTimeout(() => {
37+
unHighlightTag(randomTag);
38+
}, 100);
39+
}, 100);
40+
41+
setTimeout(() => {
42+
clearInterval(interval);
43+
44+
setTimeout(() => {
45+
const randomTag = pickRandomTag();
46+
47+
highlightTag(randomTag);
48+
}, 100);
49+
}, times * 100);
50+
};
51+
52+
textarea.addEventListener('keyup', (e) => {
53+
createTags(e.target.value);
54+
if (e.key === 'Enter') {
55+
setTimeout(() => {
56+
e.target.value = '';
57+
}, 10);
58+
randomSelect();
59+
}
60+
});

Source-Code/ChoicePicker/style.css

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,50 @@
1-
*{
2-
box-sizing: border-box;
1+
* {
2+
box-sizing: border-box;
33
}
44

5-
body{
6-
background-color: blueviolet;
7-
font-family: 'Roboto', sans-serif;
8-
display: flex;
9-
flex-direction: column;
10-
align-items: center;
11-
justify-content: center;
12-
height: 100vh;
13-
overflow: hidden;
14-
margin: 0;
5+
body {
6+
background-color: blueviolet;
7+
font-family: 'Roboto', sans-serif;
8+
display: flex;
9+
flex-direction: column;
10+
align-items: center;
11+
justify-content: center;
12+
height: 100vh;
13+
overflow: hidden;
14+
margin: 0;
1515
}
16-
h3{
17-
color: white;
18-
margin: 10px 0 20px;
19-
text-align: center;
16+
17+
h3 {
18+
color: white;
19+
margin: 10px 0 20px;
20+
text-align: center;
2021
}
21-
.container{
22-
width: 500px
22+
23+
.container {
24+
width: 500px;
2325
}
2426

2527
textarea {
26-
border: none;
27-
display: block;
28-
width: 100%;
29-
height: 100px;
30-
font-family: inherit;
31-
padding: 10px;
32-
font-size: 16px;
33-
margin: 0 0 20px;
28+
border: none;
29+
display: block;
30+
width: 100%;
31+
height: 100px;
32+
font-family: inherit;
33+
padding: 10px;
34+
font-size: 16px;
35+
margin: 0 0 20px;
3436
}
3537

3638
.tag {
37-
background-color: #f0932b;
38-
color: white;
39-
border-radius: 50px;
40-
padding: 10px 20px;
41-
margin: 0 5px 10px 0;
42-
font-size: 14px;
43-
display: inline-block;
39+
background-color: #f0932b;
40+
color: white;
41+
border-radius: 50px;
42+
padding: 10px 20px;
43+
margin: 0 5px 10px 0;
44+
font-size: 14px;
45+
display: inline-block;
4446
}
4547

4648
.tag.highlight {
47-
background-color: plum;
48-
}
49+
background-color: plum;
50+
}

0 commit comments

Comments
 (0)