-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
228 lines (198 loc) · 6.2 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<!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>Randon Number Generator</title>
<style>
body{
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
box-sizing: border-box;
font-family: Arial, Helvetica, sans-serif;
flex-direction: column;
padding: 0px;
margin: 0px;
background: #272727;
}
#input{
max-width: 800px;
width: 90%;
padding: 8px;
overflow: auto;
box-sizing: border-box;
padding-top: 80px;
}
h1{
font-size: 5em;
font-weight: 800;
display: inline;
background: linear-gradient(50deg, rgb(230, 148, 0), rgb(208, 34, 85));
font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
line-height: 1;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
#lowerBound, #upperBound{
color: blue;
border: none;
-webkit-appearance: none;
appearance: none;
font-size: inherit;
font-weight: inherit;
font-family: inherit;
line-height: inherit;
width: 200px;
-webkit-text-fill-color: white;
background: transparent;
}
#button{
width: 100%;
padding: 24px;
background: linear-gradient(50deg, rgb(230, 148, 0), rgb(208, 34, 85));
margin: 8px 0px;
border-radius: 8px;
font-size: 2em;
text-align: center;
color: white;
font-weight: 800;
box-sizing: border-box;
cursor: pointer;
}
#generated{
width: 100vw;
height: 100vh;
position: fixed;
display: none;
color: black;
font-size: 10em;
font-weight: 600;
align-items: center;
justify-content: center;
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
background: rgba(255,255,255,0.8);
}
#history{
color: white;
}
#header{
width: 100%;
position: fixed;
top: 0px;
padding: 16px;
box-sizing: border-box;
height: 80px;
}
#header img{
height: 100%;
}
#footer{
text-align: center;
}
.footerst{
color: white;
font-weight: 900;
}
.contact{
color: white;
font-weight: 400;
font-size: small;
}
#eventAd{
margin: 16px;
padding: 16px;
border: 1px solid;
border-radius: 8px;
color: rgba(255,255,255,0.5);
}
#eventAd * {
margin: 0
}
</style>
</head>
<body>
<div id="header">
<img src="https://ctrl-alt-tec.hackclub.com/img/LOGO-INLINE.png" alt="">
<img src="good.png">
</div>
<div id="eventAd">
</div>
<div id="input">
<h1>Give me a random number between <input type="number" id="lowerBound" placeholder="0"> and <input type="number" id="upperBound" placeholder="0">...
</h1>
<div id="button">GENERATE</div>
</div>
<div id="generated">9</div>
<div id="history">
<!--Aquí se van a ver los números que ya salieron :D-->
</div>
<div id="footer">
<p class="footerst">Made with <span style="color:rgb(230, 148, 0); font-size: larger; font-weight: 800;">♥</span> by Ctrl Alt Tec ( and Mango 🥭)</p>
<p class="contact">Good luck! If there's a problem with the generator, please send us an email to <a class="contact" href="mailto:[email protected]?Subject=Hello" target="_top">[email protected]</a></p>
</div>
<script>
// Aquí se almacenarán los números randoms.
let nums = []; //
// Generar un numero aleatorio
document.querySelector("#button").addEventListener("click", function(){
let lowerBound = Number(document.querySelector("#lowerBound").value);
let upperBound = Number(document.querySelector("#upperBound").value) + 1; //:D nailed it
let ind = upperBound-lowerBound;
if(nums.length<ind){
let rand = Math.floor(Math.random() * (upperBound-1)) + lowerBound;
while (nums.includes(rand) && nums.length <= ind) {
rand = Math.floor(Math.random() * (upperBound-1)) + lowerBound;
}
nums.push(rand);
showHistory()
document.querySelector("#generated").innerHTML = rand;
document.querySelector("#generated").style.display="flex"
} else {
if(confirm("All numbers have been generated.\nRefresh?")){
window.location.reload();
}
}
});
// Ocultar el número aleatorio al hacer click
document.querySelector("#generated").addEventListener("click", function(){
document.querySelector("#generated").style.display="none"
});
function showHistory(){
let historyCont = document.querySelector("#history");
//Vaciar
historyCont.innerHTML = JSON.stringify(nums);
}
fetch('https://ctrl-alt-tec.hackclub.com/event/event.json').then(data=>data.json()).then(data=>{
console.log(data)
let eventTitle = document.createElement("h2");
eventTitle.innerText = data.title;
let eventSubtitle = document.createElement("h3");
eventSubtitle.innerText = data.subtitle;
let eventDetails = document.createElement('div');
eventDetails.innerText = `${data.date}, ${data.time}`;
document.querySelector("#eventAd").append(eventTitle, eventSubtitle, eventDetails)
document.querySelector("#eventAd").addEventListener('click', ()=>{
window.location.href = "https://ctrl-alt-tec.hackclub.com/event"
})
})
/* old news:
document.querySelector("#button2").addEventListener("click", function(){
let rand = Math.floor(Math.random() * upperBound) + lowerBound;
while(nums[rand] == true){
let rand = Math.floor(Math.random() * upperBound) + lowerBound;
}
nums[rand] = true;
document.querySelector("#generated").innerHTML = rand;
document.querySelector("#generated").style.display="flex"
})
document.querySelector("#generated").addEventListener("click", function(){
document.querySelector("#generated").style.display="none"
})
*/
</script>
</body>
</html>