-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
123 lines (101 loc) · 3.04 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Fizz Buzz Test</title>
<style>
body {
--green: rgb(0, 255, 0);
background-color: #000;
color: var(--green);
font-family: 'Courier New', Courier, monospace;
font-size: 36px;
font-weight: bold;
line-height: .75;
text-align: center;
padding: 100px;
}
@keyframes fadein {
0% { opacity: 0; }
100% { opacity: 1; }
}
@keyframes fadeout {
0% { opacity: 1; }
100% { opacity: 0; }
}
.line {
margin-bottom: 5px;
}
.msg {
position: relative;
}
/* flashing background */
.msg::before {
--padding-h: -25px;
--padding-v: -2px;
animation-duration: 200ms;
animation-iteration-count: 1;
animation-name: fadeout;
background-color: var(--green);
border-radius: 25px;
box-shadow: 0 0 20px var(--green);
content: '';
display: block;
opacity: 0;
position: absolute;
z-index: -1;
top: var(--padding-v);
right: var(--padding-h);
bottom: var(--padding-v);
left: var(--padding-h);
}
.msgtext {
animation-duration: 1s;
animation-iteration-count: 1;
animation-name: fadein;
animation-timing-function: ease-in;
}
</style>
</head>
<body>
<div id="app"></div>
<script>
let i = 1
const max = 100
const time = 150
const word1 = 'Fizz'
const word2 = 'Buzz'
let app = window.document.querySelector('#app')
let interval = setInterval(_ => {
let line = window.document.createElement('div')
let msgel = window.document.createElement('span')
let msgtext = window.document.createElement('span')
const isMultipleOf3 = i % 3 === 0
const isMultipleOf5 = i % 5 === 0
if (isMultipleOf3 && isMultipleOf5)
msg = word1 + word2
else if (isMultipleOf3)
msg = word1
else if (isMultipleOf5)
msg = word2
else
msg = i
line.appendChild(msgel)
msgel.appendChild(msgtext)
line.classList.add('line')
msgel.classList.add('msg')
msgtext.classList.add('msgtext')
msgtext.innerText = msg
app.appendChild(line)
const options = time >= 125 ? { behavior: 'smooth' } : null
line.scrollIntoView(options)
i++
if (i > max) {
clearInterval(interval)
}
}, time)
</script>
</body>
</html>