-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
366 lines (295 loc) · 8.76 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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
<HEAD>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"><!--
/*
* Program - Guessing Game
* File Name - script.js
* Author - orvi
/* declaring an array to hold the country names */
var country = new Array(180);
/* initializing the array */
country[0] = "AFGHANISTAN";
country[1] = "AFRICA";
country[2] = "ALBANIA";
country[3] = "ALGERIA";
country[4] = "AMERICA";
country[5] = "ANDORRA";
country[6] = "ANGOLA";
country[7] = "ANTARCTICA";
country[8] = "ARGENTINA";
country[9] = "ARMENIA";
country[10] = "AUSTRALIA";
country[11] = "AUSTRIA";
country[12] = "AZERBAIJAN";
country[13] = "BAHAMAS";
country[14] = "BAHRAIN";
country[15] = "BANGLADESH";
country[16] = "BARBADOS";
country[17] = "BELARUS";
country[18] = "BELGIUM";
country[19] = "BELIZE";
country[20] = "BENIN";
country[21] = "BHUTAN";
country[22] = "BOLIVIA";
country[23] = "BOSNIA HERZEGOVINA";
country[24] = "BOTSWANA";
country[25] = "BRAZIL";
country[26] = "BRUNEI";
country[27] = "BULGARIA";
country[28] = "BURKINA";
country[29] = "BURUNDI";
country[30] = "CAMBODIA";
country[31] = "CAMEROON";
country[32] = "CANADA";
country[33] = "CAPE VERDE ISLANDS";
country[34] = "CHAD";
country[35] = "CHILE";
country[36] = "CHINA";
country[37] = "COLOMBIA";
country[38] = "COMOROS";
country[39] = "CONGO";
country[40] = "COSTA RICA";
country[41] = "CROATIA";
country[42] = "CUBA";
country[43] = "CYPRUS";
country[44] = "CZECH REPUBLIC";
country[45] = "DENMARK";
country[46] = "DJIBOUTI";
country[47] = "DOMINICAN REPUBLIC";
country[48] = "ECUADOR";
country[49] = "EGYPT";
country[50] = "EL SALVADOR";
country[51] = "ERITREA";
country[52] = "ESTONIA";
country[53] = "ETHIOPIA";
country[54] = "EUROPE";
country[55] = "FIJI";
country[56] = "FINLAND";
country[57] = "FRANCE";
country[58] = "GABON";
country[59] = "GAMBIA";
country[60] = "GEORGIA";
country[61] = "GERMANY";
country[62] = "GHANA";
country[63] = "GREECE";
country[64] ="GRENADA";
country[65] = "GUATEMALA";
country[66] = "GUINEA";
country[67] = "HAITI";
country[68] = "HOLLAND";
country[69] = "HONDURAS";
country[70] = "HONG KONG";
country[71] = "HUNGARY";
country[72] = "ICELAND";
country[73] = "INDIA";
country[74] = "INDONESIA";
country[75] = "IRAN";
country[76] = "IRAQ";
country[77] = "ISRAEL";
country[78] = "ITALY";
country[79] = "JAMAICA";
country[80] = "JAPAN";
country[81] = "JORDAN";
country[82] = "KAZAKHSTAN";
country[83] = "KENYA";
country[84] = "KIRGYZSTAN";
country[85] = "KIRIBATI";
country[86] = "KOREA";
country[87] = "KUWAIT";
country[88] = "LAOS";
country[89] = "LATVIA";
country[90] = "LEBANON";
country[91] = "LESOTHO";
country[92] = "LIBERIA";
country[93] = "LIBYA";
country[94] = "LIECHTENSTEIN";
country[95] = "LITHUANIA";
country[96] = "LUXEMBOURG";
country[97] = "MADAGASCAR";
country[98] = "MALAWI";
country[99] = "MALAYSIA";
country[100] = "MALDIVES";
country[101] = "MALI";
country[102] = "MALTA";
country[103] = "MAURITANIA";
country[104] = "MAURITIUS";
country[105] = "MEXICO";
country[106] = "MOLDOVA";
country[107] = "MONACO";
country[108] = "MONGOLIA";
country[109] = "MONTSERRAT";
country[110] = "MOROCCO";
country[111] = "MOZAMBIQUE";
country[112] = "MYANMAR";
country[113] = "NAMIBIA";
country[114] = "NAURU";
country[115] = "NEPAL";
country[116] = "NETHERLANDS";
country[117] = "NEW ZEALAND";
country[118] = "NICARAGUA";
country[119] = "NIGERIA";
country[120] = "NORWAY";
country[121] = "OMAN";
country[122] = "PAKISTAN";
country[123] = "PANAMA";
country[124] = "PAPUA NEW GUINEA";
country[125] = "PARAGUAY";
country[126] = "PERU";
country[127] = "PHILIPPINES";
country[128] = "POLAND";
country[129] = "PORTUGAL";
country[130] = "QATAR";
country[131] = "ROMANIA";
country[132] = "RUSSIA";
country[133] = "RWANDA";
country[134] = "SAN MARINO";
country[135] = "SAUDI ARABIA";
country[136] = "SENEGAL";
country[137] = "SEYCHELLES";
country[138] = "SIERRA LEONE";
country[139] = "SINGAPORE";
country[140] = "SLOVAKIA";
country[141] = "SLOVENIA";
country[142] = "SOLOMON ISLANDS";
country[143] = "SOMALIA";
country[144] = "SOUTH AFRICA";
country[145] = "SPAIN";
country[146] = "SRI LANKA";
country[147] = "SUDAN";
country[148] = "SURINAM";
country[149] = "SWAZILAND";
country[150] = "SWEDEN";
country[151] = "SWITZERLAND";
country[152] = "SYRIA";
country[153] = "TAIWAN";
country[154] = "TAJIKITAN";
country[155] = "TANZANIA";
country[156] = "THAILAND";
country[157] = "TOGO";
country[158] = "TONGA";
country[159] = "TRINIDAD";
country[160] = "TUNISIA";
country[161] = "TURKEY";
country[162] = "TURKMENISTAN";
country[163] = "TUVALU";
country[164] = "UGANDA";
country[165] = "UKRAINE";
country[166] = "UNITED ARAB EMIRATES";
country[167] = "URUGUAY";
country[168] = "UZBEKISTAN";
country[169] = "VANUATU";
country[170] = "VATICAN CITY";
country[171] = "VENEZUELA";
country[172] = "VIETNAM";
country[173] = "WEST INDIES";
country[174] = "WESTERN SAMOA";
country[175] = "YEMEN REPUBLIC";
country[176] = "YUGOSLAVIA";
country[177] = "ZAIRE";
country[178] = "ZAMBIA";
country[179] = "ZIMBABWE";
/* generates a random integer between 0 to 179 */
var sr = Math.floor(Math.random() * 180);
/* stores the country name */
var temp = country[sr];
/* declaring and initializing tries */
var tries = 0;
/* the main function */
function guessit()
{
var guess = document.form1.guess1.value;
tries++;
window.status = "Tries : " + tries + " ";
switch(tries)
{
case 1:
document.form1.hint.value = "First Hint : The country name starts with " + temp.charAt(0);
break;
case 2:
document.form1.hint.value = "Second Hint : The country name ends with " + temp.charAt(temp.length - 1);
break;
case 3:
document.form1.hint.value = "Last Hint : The country name has " + temp.length + " characters";
break;
default:
document.form1.hint.value = "No hints are available";
}
if(guess.toUpperCase() == temp) /* if guess equals to temp */
{
if(window.confirm("Absolutely Right ! Yes the country was " + temp + "\nDo you want to play again?"))
window.location.reload(); /* reloads the page for a new game */
}
else
{
if(tries == 5) /* game over */
{
if(window.confirm("Sorry ! Your chances over. The country was " + temp + "\nDo you want to play again?"))
{
window.location.reload(); /* reloads the page for a new game */
document.form1.hint.value = "Enter your guess below and click on Guess!";
}
}
}
}
/* end of guessit() function! */
//--></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"><!--
function catchKeyCode() //calls when the user press the RETURN key
{
if(event.keyCode == 13)
guessit();
}
function stat()
{
window.status = "Tries : " + tries + " ";
}
function clearBox()
{
document.form1.guess1.value = "";
}
function newGame()
{
if(window.confirm("Do you want to start a new game?"))
{
window.location.reload(); /* reloads the page for a new game */
document.form1.hint.value = "Enter your guess below and click on Guess!";
}
}
//--></SCRIPT>
<STYLE TYPE="text/css"><!--
.tab { border: solid 1 #000000; }
.td1 { font-family: Helvetica, sans-serif, Verdana, Arial; font-size: 15; font-weight: bold; background-color: #FF9900; color: #FFFFFF; border: 0; }
.txt1 { font-family: Helvetica, sans-serif, Verdana, Arial; font-size: 12; font-weight: bold; background-color: #FF9900; color: #FFFFFF; border: 0; }
.txt2 { font-family: Helvetica, sans-serif, Verdana, Arial; font-size: 15; font-weight: bold; border: thin groove 1 #000000; border: solid 1 #000000; }
.btn { font-family: Helvetica, sans-serif, Verdana, Arial; font-size: 17; background-color: #0099FF; color: #FFFFFF; border: solid 1 #FFFFFF; cursor: hand; }
//--></STYLE>
</HEAD>
<BODY onLoad=stat() onKeyPress=catchKeyCode()>
<FORM NAME=form1>
<TABLE CLASS=tab BORDER=0 BGCOLOR=#FF9900 CELLPADDING=20 CELLSPACING=15>
<TR>
<TD CLASS=td1>
<INPUT TYPE=text SIZE=36 NAME=hint VALUE="Enter your guess below and click on Guess!" READONLY CLASS=txt1>
</TD>
</TR>
<TR>
<TD CLASS=td1>
<INPUT TYPE=text NAME=guess1 SIZE=50 CLASS=txt2 TITLE="Enter your guess here.">
</TD>
</TR>
<TR>
<TD CALSS=td1 ALIGN=left>
<INPUT TYPE=button VALUE=Guess! onClick=guessit() CLASS=btn TITLE="Click here to get a hint or check your guess.">
</TD>
</TR>
<TR>
<TD CALSS=td1 ALIGN=left>
<INPUT TYPE=button VALUE=Clear onClick=clearBox() CLASS=btn TITLE="Click here to clear the text box.">
</TD>
</TR>
<TR>
<TD CALSS=td1 ALIGN=left>
<INPUT TYPE=button VALUE=New onClick=newGame() CLASS=btn TITLE="Click here to start a new game.">
</TD>
</TR>
</TABLE>
</FORM>