-
Notifications
You must be signed in to change notification settings - Fork 0
/
testLab.html
251 lines (243 loc) · 5.93 KB
/
testLab.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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<html>
<head>
<title>State Capitals</title>
</head>
<body onclick="bodyClicked()">
<h1>State Capitals</h1>
<table cellpadding="15" style="float:left">
<tr>
<td id='title' colspan="2">
<p id='stateDisplay'>You have 5 minutes to name<br>
the capitals of all 50 states.<br />
Click the button to start.<br>The name of a state will be
<br/>displayed here.</p>
<p id=''>
</td>
</tr>
<tr>
<td colspan="2"><input type=text name='input' oninput="submit();" id='input'></td>
</tr>
<tr>
<td>
<button type=button accesskey='E' id='button' onclick="functio()"><u>E</u>nter</button>
</td>
<td>
<button type=button accessKey='S' id='skiper' onclick="skip();"><u>S</u>kip</button>
</td>
</tr>
<tr>
<td colspan="2">
<div id='clock' style="font-size:50px;" align=center>TIMER</div>
</td>
</tr>
<tr>
<td id='skipped'>Number Skipped: 0 </td>
</tr>
<tr>
<td id='guessed'>Number Guessed: 0</td>
</tr>
</table>
<p style="float:left" id='displayBox'></p>
<div style="clear:both"></div>
<script>
function bodyClicked(evt) {
evt = evt || window.evt;
alert (evt.target.nodeName);
// identify smallest element click was over
}
function startup()
{
document.getElementById('input').disabled=true;
window.m="5";
window.s="0";
window.skipped=0;
window.guessed=0;
var second=checkTime(window.s);
var minute=window.m;
document.getElementById('clock').innerHTML=minute+":"+second;
window.stateNames=['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'];
window.capitals=['Montgomery', 'Juneau', 'Phoenix',
'Little Rock', 'Sacramento', 'Denver', 'Hartford', 'Dover',
'Tallahassee', 'Atlanta', 'Honolulu', 'Boise', 'Springfield',
'Indianapolis', 'Des Moines', 'Topeka', 'Frankfort ', 'Baton Rouge ',
'Augusta', 'Annapolis', 'Boston', 'Lansing', 'St. Paul', 'Jackson',
'Jefferson City', 'Helena', 'Lincoln', 'Carson City',
'Concord', 'Trenton', 'Santa Fe', 'Albany',
'Raleigh', 'Bismark', 'Columbus', 'Oklahoma City',
'Salem', 'Harrisburg', 'Providence', 'Columbia',
'Pierre', 'Nashville', 'Austin', 'Salt Lake City',
'Montpelier', 'Richmond', 'Olympia', 'Charleston', 'Madison', 'Cheyenne', ];
window.numbers=[''];
window.state='';
window.capital='';
window.fin=[''];
}
function skip()
{
if(window.fin.length<=50)
{
window.skipped=parseInt(window.skipped)+1;
document.getElementById('skipped').innerHTML= "Number Skipped: " + window.skipped;
window.fin.push(window.state+" : "+window.capital);
updateDisplay();
statePick();
document.getElementById('input').value="";
}
else
{
alert("quiz is over")
}
}
function updateDisplay()
{
var strng=''
window.fin=window.fin.sort();
for(var x =0; x<window.fin.length; x+=1)
{
if(x%2==0)
{
strng=strng+window.fin[x]+" <br>";
}
else
{
strng=strng+window.fin[x]+"   
         
         
   ";
}
}
document.getElementById('displayBox').innerHTML=strng;
}
function tick()
{
if(parseInt(window.s)==0)
{
window.m=parseInt(window.m)-1;
window.s="59";
}
else
{
window.s= parseInt(window.s)-1;
}
var second=checkTime(window.s);
var minute=window.m;
elem('clock').innerHTML=minute+":"+second;
if(parseInt(window.m)==0 && parseInt(window.s)==0)
{
alert("TIMES UP")
}
else if( parseInt(window.m)>=0){
if(parseInt(window.s)>=0)
{
window.setTimeout(function(){tick()}, 1000);
}
}
}
function checkTime(i) {
if (i<10) {i = "0" + i}; // add zero in front of numbers < 10
return i;
}
function makeString(s)
{
st= document.getElementById('displayBox').innerHTML;
if (window.numbers.length%2==0)
{
st=st+", "+s;
}
else
{
st=st+"<br >"+s;
}
}
function submit()
{
var word = document.getElementById('input').value;
if(window.capital.toUpperCase() == word.toUpperCase())
{
window.guessed=parseInt(window.guessed)+1;
document.getElementById('guessed').innerHTML="Number Guessed: "+window.guessed;
document.getElementById('input').value="";
updateDisplay(window.state+" : "+window.capital);
if(window.numbers.length==50)
{
alert("YOU WIN!")
}
else
{
statePick();
}
}
if(window.capital=='St. Paul')
{
if("ST PAUL"==word.toUpperCase() || "SAINT PAUL"==word.toUpperCase())
{
window.guessed=parseInt(window.guessed)+1;
document.getElementById('guessed').innerHTML="Number Guessed: "+window.guessed;
document.getElementById('input').value="";
window.fin.push(window.state+" : "+window.capital);
updateDisplay();
if(window.fin.length==50)
{
alert("YOU WIN!")
}
else
{
statePick();
}
}
}
}
function functio()
{
statePick();
var elem = document.getElementById('input');
elem.disabled=false;
document.getElementById('input').focus();
tick();
}
function disabl()
{
var elem = document.getElementById('input');
if(elem.disabled==true)
{
elem.disabled=false;
}
if(elem.disabled==false)
{
elem.disbled==true;
}
}
function elem(id)
{
return document.getElementById(id);
}
function statePick()
{
var numb=Math.round(Math.random()*49);
if(window.numbers.indexOf(numb)==-1)
{
window.state=window.stateNames[numb];
window.capital=window.capitals[numb];
document.getElementById('stateDisplay').innerHTML=window.state;
window.numbers.push(numb);
}
else if(window.numbers.length<=50)
{
statePick();
}
}
</script>
</body>
</html>