-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
127 lines (119 loc) · 4.64 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
<!DOCTYPE html>
<html>
<head>
<title>Game</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:800" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1.0" charset="utf-8">
<style>
@media screen and (max-aspect-ratio: 1/1) {
* {
background-color: lightgreen;
}
}
@media screen and (max-width: 480px){
* {
font-size: 12vw;
}
}
* {
font-weight: bold;
text-transform: uppercase;
font-family: 'Open Sans', sans-serif;
padding: 0;
margin: 0;
text-align: center;
font-size: 7vh;
user-select: none;
color: white;
outline: none;
border: none;
justify-content: center;
align-items: center;
}
body {
background-color: #FF1744;
}
#hud {
display: flex;
height: 90vh;
}
#input {
background-color: transparent;
display: none;
}
#play:hover {
opacity: 0.5;
cursor: pointer;
transition: opacity 0.5s;
}
#victory {
display: none;
}
</style>
</head>
<body>
<div id="hud">
<p id="play" onclick="play()">Play</p>
<div>
<p id="number"></p>
<p id="name"></p>
<input id="input" maxlength="24" onkeyup="check()" type="text"></input>
</div>
<p id="victory">You won</p>
</div>
<script>
var a = ["Hydrogen", "Helium", "Lithium", "Beryllium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine", "Neon", "Sodium", "Magnesium", "Aluminum", "Silicon", "Phosphorus", "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium", "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel", "Copper", "Zinc", "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine", "Krypton", "Rubidium", "Strontium", "Yttrium", "Zirconium", "Niobium", "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver", "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon", "Cesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium", "Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium", "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium", "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinum", "Gold", "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon", "Francium", "Radium", "Actinium", "Thorium", "Protactinium", "Uranium", "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium", "Berkelium", "Einsteinium", "Fermium", "Mendelevium", "Nobelium", "Lawrencium", "Rutherfordium", "Dubnium", "Seaborgium", "Bohrium", "Hassium", "Meitnerium", "Darmstadtium", "Roentgenium", "Copernicium", "Nihonium", "Flerovium", "Moscovium", "Livermorium", "Tennessine", "Oganesson"];
var s = 1;
var n = 0;
var g = 0;
function play() {
document.getElementById("play").style.display = "none";
simon();
}
function simon() {
document.getElementById("name").innerHTML = a[n];
document.getElementById("number").innerHTML = n + 1;
if(s === n) {
n = 0;
test();
} else {
n++;
setTimeout(simon,1000);
}
}
function test() {
document.getElementById("number").innerHTML = g + 1;
document.getElementById("name").style.display = "none";
document.getElementById("input").value = "";
document.getElementById("input").style.display = "inherit";
document.getElementById("input").focus();
}
function check() {
var ans = a[g].toLowerCase();
var usr = document.getElementById("input").value;
usr = usr.toLowerCase();
if(ans === usr) {
if(s === g + 1) {
if(s === a.length) {
document.getElementById("number").style.display = "none";
document.getElementById("name").style.display = "none";
document.getElementById("input").style.display = "none";
document.getElementById("victory").style.display = "inherit";
} else {
s++;
document.getElementById("input").style.display = "none";
document.getElementById("name").style.display = "inherit";
g = 0;
simon();
return;
}
} else {
g++;
test();
return;
}
}
}
</script>
</body>
</html>