-
Notifications
You must be signed in to change notification settings - Fork 0
/
Crossword.html
384 lines (369 loc) · 15.7 KB
/
Crossword.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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
<!DOCTYPE html>
<html>
<head>
<title>Cross word Puzzle</title>
<style>
#cross{
text-align: center;
width:30px;
height:30px;
margin: 0;
padding: 0;
border-collapse: collapse;
border: 1px solid white;
}
#buttons{
width:30%;
float: right;
}
tr{
margin: 0;
padding: 0;
border-collapse: collapse;
}
td{
height: 30px;
width: 30px;
}
#leftBox{
float: left;
}
#rightBox{
float: left;
clear:left;
}
.butt{
height:50px;
width: 107px;
}
#puzzel{
text-align: center;
margin: 0;
padding: 0;
border-collapse: collapse;
border: 1px solid black;
}
.inputBox{
width: 40px;
height:40px;
border: 1px solid black;
text-align: center;
}
.circle{
width: 40px;
height: 40px;
border-radius: 100%;
border: 1px solid black;
text-align: center;
}
#hintsTable{
width: 480px;
float: left;
clear: left;
}
@keyframes animationName {
from {margin-left:-30%;}
}
.word{color:#ff0000;}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
//Globals
var currentTextInput;
var puzzelArrayData;
//Loads the Crossword
function initializeScreen(){
var puzzelTable = document.getElementById("puzzel");
puzzelArrayData = preparePuzzelArray();
for ( var i = 0; i < puzzelArrayData.length ; i++ ) {
var row = puzzelTable.insertRow(-1);
var rowData = puzzelArrayData[i];
for(var j = 0 ; j < rowData.length ; j++){
var cell = row.insertCell(-1);
if(i == 6 && j==3){
var txtID = String('txt' + '_' + i + '_' + j);
cell.innerHTML = '<input type="text" class="circle" maxlength="1" style="text-transform: lowercase" ' + 'id="' + txtID + '" onfocus="textInputFocus(' + "'" + txtID + "'"+ ')">';
}
else if(i == 6 && j==4){
var txtID = String('txt' + '_' + i + '_' + j);
cell.innerHTML = '<input type="text" class="circle" maxlength="1" style="text-transform: lowercase" ' + 'id="' + txtID + '" onfocus="textInputFocus(' + "'" + txtID + "'"+ ')">';
}
else if(i == 6 && j==5){
var txtID = String('txt' + '_' + i + '_' + j);
cell.innerHTML = '<input type="text" class="circle" maxlength="1" style="text-transform: lowercase" ' + 'id="' + txtID + '" onfocus="textInputFocus(' + "'" + txtID + "'"+ ')">';
}
else if(i == 6 && j==6){
var txtID = String('txt' + '_' + i + '_' + j);
cell.innerHTML = '<input type="text" class="circle" maxlength="1" style="text-transform: lowercase" ' + 'id="' + txtID + '" onfocus="textInputFocus(' + "'" + txtID + "'"+ ')">';
}
else if(i == 6 && j==7){
var txtID = String('txt' + '_' + i + '_' + j);
cell.innerHTML = '<input type="text" class="circle" maxlength="1" style="text-transform: lowercase" ' + 'id="' + txtID + '" onfocus="textInputFocus(' + "'" + txtID + "'"+ ')">';
}
else if(i == 7 && j==7){
var txtID = String('txt' + '_' + i + '_' + j);
cell.innerHTML = '<input type="text" class="circle" maxlength="1" style="text-transform: lowercase" ' + 'id="' + txtID + '" onfocus="textInputFocus(' + "'" + txtID + "'"+ ')">';
}
else if(i == 8 && j==7){
var txtID = String('txt' + '_' + i + '_' + j);
cell.innerHTML = '<input type="text" class="circle" maxlength="1" style="text-transform: lowercase" ' + 'id="' + txtID + '" onfocus="textInputFocus(' + "'" + txtID + "'"+ ')">';
}
else if(i == 9 && j==7){
var txtID = String('txt' + '_' + i + '_' + j);
cell.innerHTML = '<input type="text" class="circle" maxlength="1" style="text-transform: lowercase" ' + 'id="' + txtID + '" onfocus="textInputFocus(' + "'" + txtID + "'"+ ')">';
}
else if(i == 10 && j==7){
var txtID = String('txt' + '_' + i + '_' + j);
cell.innerHTML = '<input type="text" class="circle" maxlength="1" style="text-transform: lowercase" ' + 'id="' + txtID + '" onfocus="textInputFocus(' + "'" + txtID + "'"+ ')">';
}
else if(i == 10 && j==6){
var txtID = String('txt' + '_' + i + '_' + j);
cell.innerHTML = '<input type="text" class="circle" maxlength="1" style="text-transform: lowercase" ' + 'id="' + txtID + '" onfocus="textInputFocus(' + "'" + txtID + "'"+ ')">';
}
else if(i == 10 && j==5){
var txtID = String('txt' + '_' + i + '_' + j);
cell.innerHTML = '<input type="text" class="circle" maxlength="1" style="text-transform: lowercase" ' + 'id="' + txtID + '" onfocus="textInputFocus(' + "'" + txtID + "'"+ ')">';
}
else if(i == 1 && j==9){
var txtID = String('txt' + '_' + i + '_' + j);
cell.innerHTML = '<input type="text" class="circle" maxlength="1" style="text-transform: lowercase" ' + 'id="' + txtID + '" onfocus="textInputFocus(' + "'" + txtID + "'"+ ')">';
}
else if(i == 1 && j==10){
var txtID = String('txt' + '_' + i + '_' + j);
cell.innerHTML = '<input type="text" class="circle" maxlength="1" style="text-transform: lowercase" ' + 'id="' + txtID + '" onfocus="textInputFocus(' + "'" + txtID + "'"+ ')">';
}
else if(i == 1 && j==11){
var txtID = String('txt' + '_' + i + '_' + j);
cell.innerHTML = '<input type="text" class="circle" maxlength="1" style="text-transform: lowercase" ' + 'id="' + txtID + '" onfocus="textInputFocus(' + "'" + txtID + "'"+ ')">';
}
else if(i == 1 && j==12){
var txtID = String('txt' + '_' + i + '_' + j);
cell.innerHTML = '<input type="text" class="circle" maxlength="1" style="text-transform: lowercase" ' + 'id="' + txtID + '" onfocus="textInputFocus(' + "'" + txtID + "'"+ ')">';
}
else if(i == 1 && j==13){
var txtID = String('txt' + '_' + i + '_' + j);
cell.innerHTML = '<input type="text" class="circle" maxlength="1" style="text-transform: lowercase" ' + 'id="' + txtID + '" onfocus="textInputFocus(' + "'" + txtID + "'"+ ')">';
}
else if(i == 1 && j==14){
var txtID = String('txt' + '_' + i + '_' + j);
cell.innerHTML = '<input type="text" class="circle" maxlength="1" style="text-transform: lowercase" ' + 'id="' + txtID + '" onfocus="textInputFocus(' + "'" + txtID + "'"+ ')">';
}
else if(i == 9 && j==3){
var txtID = String('txt' + '_' + i + '_' + j);
cell.innerHTML = '<input type="text" class="circle" maxlength="1" style="text-transform: lowercase" ' + 'id="' + txtID + '" onfocus="textInputFocus(' + "'" + txtID + "'"+ ')">';
}
else if(i == 10 && j==3){
var txtID = String('txt' + '_' + i + '_' + j);
cell.innerHTML = '<input type="text" class="circle" maxlength="1" style="text-transform: lowercase" ' + 'id="' + txtID + '" onfocus="textInputFocus(' + "'" + txtID + "'"+ ')">';
}
else if(i == 11 && j==3){
var txtID = String('txt' + '_' + i + '_' + j);
cell.innerHTML = '<input type="text" class="circle" maxlength="1" style="text-transform: lowercase" ' + 'id="' + txtID + '" onfocus="textInputFocus(' + "'" + txtID + "'"+ ')">';
}
else if(i == 12 && j==3){
var txtID = String('txt' + '_' + i + '_' + j);
cell.innerHTML = '<input type="text" class="circle" maxlength="1" style="text-transform: lowercase" ' + 'id="' + txtID + '" onfocus="textInputFocus(' + "'" + txtID + "'"+ ')">';
}
else if(rowData[j] != 0){
var txtID = String('txt' + '_' + i + '_' + j);
cell.innerHTML = '<input type="text" class="inputBox" maxlength="1" style="text-transform: lowercase" ' + 'id="' + txtID + '" onfocus="textInputFocus(' + "'" + txtID + "'"+ ')">';
}else{
cell.style.backgroundColor = "black";
}
}
}
addHint();
}
//Adds the hint numbers
function addHint(){
document.getElementById("txt_0_0").placeholder = "1";
document.getElementById("txt_0_1").placeholder = "2";
document.getElementById("txt_0_2").placeholder = "3";
document.getElementById("txt_0_3").placeholder = "4";
document.getElementById("txt_0_4").placeholder = "5";
document.getElementById("txt_0_5").placeholder = "6";
document.getElementById("txt_1_0").placeholder = "2";
document.getElementById("txt_2_0").placeholder = "3";
document.getElementById("txt_3_0").placeholder = "4";
document.getElementById("txt_0_11").placeholder = "7";
document.getElementById("txt_0_13").placeholder = "8";
document.getElementById("txt_1_9").placeholder = "5";
document.getElementById("txt_2_7").placeholder = "6";
document.getElementById("txt_4_9").placeholder = "7";
document.getElementById("txt_6_3").placeholder = "8";
document.getElementById("txt_6_7").placeholder = "9";
document.getElementById("txt_6_13").placeholder = "10";
document.getElementById("txt_8_9").placeholder = "9";
document.getElementById("txt_8_14").placeholder = "11";
document.getElementById("txt_9_3").placeholder = "12";
document.getElementById("txt_9_5").placeholder = "13";
document.getElementById("txt_10_0").placeholder = "10";
document.getElementById("txt_11_0").placeholder = "11";
document.getElementById("txt_12_0").placeholder = "12";
document.getElementById("txt_13_0").placeholder = "13";
document.getElementById("txt_14_0").placeholder = "14";
document.getElementById("txt_10_1").placeholder = "14";
document.getElementById("txt_10_2").placeholder = "15";
document.getElementById("txt_12_5").placeholder = "16";
document.getElementById("txt_10_6").placeholder = "16";
document.getElementById("txt_11_5").placeholder = "15";
document.getElementById("txt_11_12").placeholder = "17";
document.getElementById("txt_12_9").placeholder = "18";
document.getElementById("txt_13_9").placeholder = "19";
document.getElementById("txt_14_9").placeholder = "20";
document.getElementById("txt_12_10").placeholder = "19";
document.getElementById("txt_12_11").placeholder = "20";
document.getElementById("txt_11_13").placeholder = "21";
}
//Stores ID of the selected cell into currentTextInput
function textInputFocus(txtID123){
currentTextInput = txtID123;
}
//Returns Array
function preparePuzzelArray(){
var items = [ ['A', 'P', 'A', 'C', 'H', 'E', 0, 0, 0, 0,0,'U',0,'R',0],
['P', 'O', 'S', 'H', 'E', 'R', 0, 0, 0, 'R','U','S','T','I','C'],
['P', 'O', 'K', 'I', 'N', 'G', 0, 'C', 'U', 'E',0,'A',0,'S',0],
['S', 'H', 'A', 'M', 'S', 0, 0, 0, 0, 'C',0,'G',0,'K',0],
[0, 0, 0, 'E', 0, 0, 0, 0, 0, 'A','V','E','O',0,0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 'S',0,0,0,0,0],
[0, 0, 0, 'B', 'I', 'R', 'T', 'H', 'S', 'T','O','N','E','S',0],
[0, 0, 0, 0, 0, 0, 0, 'A', 0, 0,0,0,0,'O',0],
[0, 0, 0, 0, 0, 0, 0, 'P', 0, 'P','S','E','U','D','O'],
[0, 0, 0, 'M', 0, 'I', 0, 'P', 0, 0,0,0,0,'A','F'],
['G', 'R', 'E', 'E', 'N', 'D', 'A', 'Y', 0, 0,0,0,0,0,'F'],
['E', 'O', 'R', 'L', 0, 'Y', 'M', 'C', 'A', 0,0,0,'T','H','E'],
['C', 'U', 'R', 'D', 0, 'L', 'I', 'A', 0, 'C','A','R','E','E','N'],
['K', 'E', 'E', 0, 0, 'L', 0, 'M', 0, 'A','B','U','S','E','S'],
['O', 'S', 'D', 0, 0, 0, 0, 'P', 0, 'N','E','T','T','L','E']
];
return items;
}
//Clear All Button
function clearAllClicked(){
currentTextInput = '';
var puzzelTable = document.getElementById("puzzel");
puzzelTable.innerHTML = '';
initializeScreen();
}
//Check button
function checkClicked(){
for ( var i = 0; i < puzzelArrayData.length ; i++ ) {
var rowData = puzzelArrayData[i];
for(var j = 0 ; j < rowData.length ; j++){
if(rowData[j] != 0){
var selectedInputTextElement = document.getElementById('txt' + '_' + i + '_' + j);
if(selectedInputTextElement.value != puzzelArrayData[i][j]){
selectedInputTextElement.style.backgroundColor = 'red';
}else{
selectedInputTextElement.style.backgroundColor = 'white';
}
}
}
}
}
//Clue Button
function clueClicked(){
if (currentTextInput != null){
var temp1 = currentTextInput;
var token = temp1.split("_");
var row = token[1];
var column = token[2];
document.getElementById(temp1).value = puzzelArrayData[row][column];
//checkClicked();
}
}
//Solve Button
function solveClicked(){
if (currentTextInput != null){
var temp1 = currentTextInput;
var token = temp1.split("_");
var row = token[1];
var column = token[2];
// Print elements on top
for(j = row; j >= 0; j--){
if(puzzelArrayData[j][column] != 0){
document.getElementById('txt' + '_' + j + '_' + column).value = puzzelArrayData[j][column];
}else break;
}
// Print elements on right
for(i = column; i< puzzelArrayData[row].length; i++){
if(puzzelArrayData[row][i] != 0){
document.getElementById('txt' + '_' + row + '_' + i).value = puzzelArrayData[row][i];
}else break;
}
// Print elements below
for(m = row; m< puzzelArrayData.length; m++){
if(puzzelArrayData[m][column] != 0){
document.getElementById('txt' + '_' + m + '_' + column).value = puzzelArrayData[m][column];
}else break;
}
// Print elements on left
for(k = column; k >= 0; k--){
if(puzzelArrayData[row][k] != 0){
document.getElementById('txt' + '_' + row + '_' + k).value = puzzelArrayData[row][k];
}else break;
}
// Done!
}
}
///$(document).ready(function(){
// $("#start").click(function(){
// $("div").animate({left: '100px'}, 5000);
//$("div").animate({fontSize: '3em'}, 5000);
// });
//});
</script>
</head>
<body onload="initializeScreen()">
<p> Rules: </p>
<p> 1) Click the Clue button to reveal one alphabet if you need help. </p>
<p>2) Click the Solve button to reveal the entire word if you desperately need help. </p>
<p>3) Click the Check button to check your answers. Errors will be marked in red. </p>
<p>4) <b> Absolutely DO NOT click the Finish button unless you check your answers and fix your errors. </b> </p>
<p>5) It's your birthday, so get started! </p>
<div id="leftBox">
<table id="puzzel">
</table>
</div>
<div id="rightBox">
<table>
<tr><td><input class="butt" type="submit" value="Clear All" onclick="clearAllClicked()"></td>
<td><input class="butt" type="submit" value="Check" onclick="checkClicked()"></td>
<td><input class="butt" type="submit" value="Solve" onclick="solveClicked()"></td>
<td><input class="butt" type="submit" value="Clue" onclick="clueClicked()"></td>
<td><input class="butt" type="submit" value="Finish" onclick="$('#image1').show()"></td></tr>
</table>
</div>
<table id="hintsTable">
<tr>
<td><strong>Across:</strong></td><td><strong>Down:</strong></td>
</tr>
<tr>
<td>1. Indian in many an old Western</td><td>1. i-Tune store purchases</td></tr>
<tr>
<td>2. More ritzy</td><td>2. Winnie-the-___</td></tr>
<tr>
<td>3. Making fun</td><td>3. "___ _ silly question"</td></tr>
<tr> <td> 4. Put-ons </td> <td> 4. Interject or butt in </td></tr>
<tr><td> 5. Picturesque </td><td> 5. Female chicken </td></tr>
<tr><td> 6. Signal to an actor or performer </td><td> 6. Unit of work </td></tr>
<tr><td> 7. Subcompact car model from Chevrolet </td><td> 7. Grammarians' concern </td></tr>
<tr><td> 8.Aquamarine, Sardonyx, and Tanzanite </td><td> 8. Shot in the dark </td></tr>
<tr><td> 9. Sham </td><td> 9. Heart of the Klamath </tr></td>
<tr><td> 10. "Wake me up when September ends" band </td><td> 10. Sock thief </tr></td>
<tr><td> 11. ___ the young. LOTR character </td><td> 11. An illegal act </tr></td>
<tr><td> 12. Sour dairy product containing casein </td><td> 12. Pinochle and the dix. See 5 across for your second clue. </td></tr>
<tr><td> 13. Arcade game manufacturer from 1973 to 1978 </td><td> 13. Descriptive work in poetry dealing with a rustic life </td></tr>
<tr><td> 14. Device that utilizes the standard of storing data sets as objects, abbr. </td><td> 14. Old, debauched people </td></tr>
<tr><td> 15. This organization's logo contains three triangles reflecting "body, mind, and spirit" </td><td> 15. Made a sin </td></tr>
<tr><td> 16. __ Marie Johnson</td><td> 16. "How stupid ___ __!" </td></tr>
<tr><td> 17. Definite article </td><td> 17. Lab procedure </td></tr>
<tr><td> 18. What speeding cars do around turns </td><td> 18. Bottle alternative </td></tr>
<tr><td> 19. Mistreats </td><td> 19. Lincoln family, familiar </td></tr>
<tr><td> 20. Stinging plant </td><td> 20. Groove in a road </td></tr>
<tr><td> </td><td> 21. Dog trainer's "Follow!" </td></tr>
</table>
<img id="image1" src="https://varsha2509.github.io/Crosswords/Bday!.png" style="display:none;" width="600" height="600"/>
</body>
</html>