-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path50states1.html
210 lines (174 loc) · 5.53 KB
/
50states1.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
<!DOCTYPE html>
<html>
<head>
<title>5 minutes for 50 states</title>
<style>
#st {
background-color: #FF998F;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius:6px;
color: #fff;
font-family: 'Oswald';
font-size: 20px;
text-decoration: none;
cursor: pointer;
border:none;
margin-top: 25px;
}
#st:hover {
border: none;
color: black;
box-shadow: 0px 0px 1px #777;
}
body {
color: #1B4027;
font-family: Rockwell;
background: #C2C2D6;
text-align: center;
}
#rest {
margin-top: 20px;
}
#instructions{
font-size: 40px;
margin-top: 60px;
}
#stat {
margin-top: 30px;
font-size: 40px;
color: #990000;
}
.bor {
width: 300px;
height: 40px;
border: 1px solid #3366FF;
border-left: 4px solid #3366FF;
font-size: 35px;
}
tr {
text-align: left;
}
font.finish {
margin-top: 500px;
margin-left: 500px;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type='text/javascript'>
function loadPage() {
$("#instructions").html("5:00");
document.getElementById("myTextId").disabled = true;
$("#countLeft").html("Remaining: " + count);
minutes=5;
seconds=1;
}
states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming']
count = states.length;
fin = "";
function clicked() {
elem = upper(document.getElementById("myTextId").value);
var ind = -1;
for (var i = 0; i < states.length; i++){
if (elem == upper(states[i])) {
ind = i;
break;
}
}
console.log(ind);
if (ind != -1) {
var table = document.getElementById("tab1");
console.log('here');
if (count > 30) {
table.deleteRow(0);
var row = table.insertRow(0);
}
else if (count > 15) {
table.deleteRow(1);
var row = table.insertRow(1);
}
else {
table.deleteRow(2);
var row = table.insertRow(2);
}
if (count == 30 || count == 15) {
fin = "";
}
fin += states[ind] + " ";
var cell1 = row.insertCell(0);
cell1.innerHTML = fin;
states.splice(ind, 1);
count--;
document.getElementById('myTextId').value = "";
}
$("#countLeft").html("Remaining: " + count);
if (states.length == 0) {
winner();
}
}
function upper(string)
{
return string.toUpperCase();
}
function winner() {
document.write('<body bgcolor="#C2C2D6"></body>')
document.writeln('<font size="180" color="green" class="finish">WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! WINNER!! </font>');
document.writeln('<button type="button" onclick="reset()" accesskey="t"><u>T</u>ry again!</button>');
}
function loser() {
document.write('<body bgcolor="#C2C2D6"></body>')
document.writeln('<font size="80" color="red" class="finish">Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser Loser </font>');
document.writeln('<button type="button" onclick="reset()" accesskey="t"><u>T</u>ry again!</button>');
}
function reset() {
location.reload();
}
function display(){
$('#st').attr('disabled', 'disabled');
document.getElementById("myTextId").disabled = false;
document.getElementById('myTextId').focus();
if (minutes == 0 && seconds == 00){
loser();
}
if (seconds == 0){
seconds=60
minutes-=1
}
if (seconds <= 10) {
seconds-=1
$("#instructions").html(minutes+":0"+seconds);
setTimeout("display()",1000)
}
else {
seconds-=1
$("#instructions").html(minutes+":"+seconds);
setTimeout("display()",1000)
}
}
</script>
</head>
<body onload="loadPage()">
<div id="stat">
Try to name all 50 states under five minutes!
</div>
<div id="instructions">
</div>
<div id="rest">
<div id="countLeft">
</div>
<div id="enter">
<input type="text" id="myTextId" onkeyup="clicked()" oninput="clicked()" class="bor">
</div>
<button type="button" onclick="display()" id="st" accesskey="s"><u>S</u>tart timer!</button>
<br>
<br>
<br>
<br>
<table id="tab1" align="left">
<tr></tr>
<tr></tr>
<tr></tr>
</table>
</div>
</body>
</html>