This repository has been archived by the owner on Oct 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
73 lines (71 loc) · 2.5 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Randomize</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<style>
body {
height: 100vh;
}
.card {
width: 300px;
}
#generator {
font-size: 60px;
}
.loader {
display: none;
margin: 0 auto;
}
.active {
display: block;
}
</style>
</head>
<body class="d-flex align-items-center justify-content-center">
<div class="card">
<div class="card-body p-0">
<div class="card-header">
<h3 class="text-center">Coffee Game ☕</h3>
</div>
<div class="card-body">
<p class="card-text">Who's gonna make coffee today?</p>
<form class="d-flex" id="form">
<input type="number" id="max" class="form-control mr-2" placeholder="Set max" autocomplete="off">
<button type="submit" class="btn btn-primary">Generate</button>
</form>
</div>
</div>
<div class="text-center">
<div class="spinner-border text-primary mb-2 loader" role="status">
<span class="sr-only">Loading...</span>
</div>
<p id="generator"></p>
</div>
<div class="card-footer text-center text-muted mt-2">
<p class="card-text">PixelPerfect Team</p>
</div>
</div>
<script>
const generator = document.getElementById('generator')
const maxNumInput = document.getElementById('max')
const form = document.getElementById('form')
const loader = document.querySelector('.loader')
form.addEventListener('submit', event => {
event.preventDefault()
generator.textContent = ''
loader.classList.add('active')
setTimeout(() => {
loader.classList.remove('active')
generator.textContent = getRandomNum(maxNumInput.value || 20)
}, 2400)
})
function getRandomNum(max) {
return Math.floor(Math.random() * max + 1)
}
</script>
</body>
</html>