This repository has been archived by the owner on Jul 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
623 lines (554 loc) · 18.6 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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
<!doctype html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Кроссворд "Графическая информация и компьютер"</title>
<meta name="generator" content="EclipseCrossword" />
<link href="https://fonts.googleapis.com/css2?family=Balsamiq+Sans&display=swap" rel="stylesheet">
<style>
*{
font-family: 'Balsamiq Sans', cursive;
text-align:center;
}
body, h1, h2, h3, h4, h5, h6
{
/*font-family: "Segoe UI", "Franklin Gothic Medium", "Arial", sans-serif;*/
}
h1, h2, h3, h4, h5, h6
{
color: #5d6a86;
}
body
{
cursor: default;
font-size: small;
}
table{
margin:0 auto;
}
div{
margin:0 auto;
}
.ecw-answerbox
{
color: black;
background-color: #FFFAF0;
border-color: #808080;
border-style: solid;
border-width: 1px;
display: block;
padding: .75em;
width: 240pt;
}
.ecw-box
{
border-style: solid;
border-width: 1pt;
cursor: pointer;
font-size: .12in;
font-weight: bold;
height: .18in;
overflow: hidden;
text-align: center;
width: .18in;
}
.ecw-boxcheated_sel
{
background-color: #FFF1D7;
border-color: #C00000;
color: #2080D0;
}
.ecw-boxcheated_unsel
{
background-color: #ffffff;
border-color: #606060;
color: #2080D0;
}
.ecw-boxerror_sel
{
background-color: #FFF1D7;
border-color: #C00000;
color: #BF0000;
}
.ecw-boxerror_unsel
{
background-color: #FFF0F0;
border-color: #606060;
color: #BF0000;
}
.ecw-boxnormal_sel
{
background-color: #FFF1D7;
border-color: #C00000;
color: #000000;
}
.ecw-boxnormal_unsel
{
background-color: #ffffff;
border-color: #606060;
color: #000000;
}
.ecw-button
{
width: 64pt;
}
.ecw-cluebox
{
border-bottom-width: 1px;
border-color: #c0c0c0;
border-left-width: 0px;
border-right-width: 0px;
border-style: solid;
border-top-width: 1px;
margin-top: 1em;
padding-bottom: .5em;
padding-left: 0pt;
padding-right: 0pt;
padding-top: .5em;
}
.ecw-crosswordarea
{
display:none;
background-color: #D0D8E0;
border-color: #808080;
border-style: solid;
border-width: 2px;
padding: .5em;
font-family: "Segoe UI", "Verdana", "Arial", sans-serif;
font-size: small;
}
.ecw-copyright
{
margin-bottom: 1em;
font-size: x-small;
font-family: "Segoe UI", "Franklin Gothic Medium", "Arial", sans-serif;
}
.ecw-input
{
font-family: "Segoe UI", "Verdana", "Arial", sans-serif;
}
.ecw-wordlabel
{
text-transform: uppercase;
margin: 0;
}
.ecw-wordinfo
{
font-size: 8pt;
color: #808080;
}
.ecw-worderror
{
color: #c00000;
font-weight: bold;
display: none;
margin-top: 1em;
}
#checkbutton{
background-color:#FFFAF0;
border-radius:3vh;
border:solid #808080;
border-width:1px;
}
</style>
</head>
<body>
<h1>Кроссворд "Графическая информация и компьютер"</h1>
<h3 style="margin-top: -1em;">Виталий Сухоплечев</h3>
<div id="waitmessage" class="ecw-answerbox">
Loading...
</div>
<table cellpadding="0" cellspacing="0" border="0"><tr>
<td class="ecw-crosswordarea">
<script>
CrosswordWidth = 15;
CrosswordHeight = 14;
Words = 10;
WordLength = new Array(10, 9, 13, 6, 7, 13, 7, 9, 7, 3);
Word = new Array("ВЕКТОРНОГО", "РАСТРОВЫЕ", "РЕТУШИРОВАНИЕ", "КОЛЛАЖ", "ПИКСЕЛЬ", "МОДЕЛИРОВАНИЕ", "ГРАФИКА", "ПРИМИТИВЫ", "НАУЧНОЕ", "КОД");
Clue = new Array("Графические файлы ... типа имеют относительно небольшие размеры.",
"Такие графические редакторы называют программамми \"картинного стиля\".",
"Используя ... можно убрать с изображения повреждения, а также лишние детали.",
"С помощью растрового редактора можно создать ..., в котором объединяются фрагменты различных изображений.",
"Элемент рисунка.",
"Создание трёхмерного объекта.",
"Компьютерная ... - раздел информатики, занимающийся проблемами создания и обработки на компьютере графических изображений.",
"Графические ... - совокупность простых элементов: прямых линий, дуг, окружностей, эллипсов, прямоугольников, закрасок и др..",
"Самое первое направление графики.",
"Информация о цвете пикселя.");
AnswerHash = new Array(21334, 48426, 15925, 51196, 46165, 5599, 92889, 89303, 42612, 71333);
WordX = new Array(1, 0, 2, 4, 7, 8, 13, 2, 11, 5);
WordY = new Array(1, 3, 6, 9, 11, 0, 2, 5, 5, 8);
LastHorizontalWord = 4;
OnlyCheckOnce = false;
</script>
<script>
var BadChars = "`~!@^*()_={[}]\|:;\"',<.>/?";
var TableAcrossWord, TableDownWord;
var CurrentWord, PrevWordHorizontal, x, y, i, j;
var CrosswordFinished, Initialized;
// Check the user's browser and then initialize the puzzle.
if (document.getElementById("waitmessage") != null)
{
document.getElementById("waitmessage").innerHTML = "Please wait while the crossword is loaded...";
// Current game variables
CurrentWord = -1;
PrevWordHorizontal = false;
// Create the cell-to-word arrays.
TableAcrossWord = new Array(CrosswordWidth);
for (var x = 0; x < CrosswordWidth; x++) TableAcrossWord[x] = new Array(CrosswordHeight);
TableDownWord = new Array(CrosswordWidth);
for (var x = 0; x < CrosswordWidth; x++) TableDownWord[x] = new Array(CrosswordHeight);
for (var y = 0; y < CrosswordHeight; y++)
for (var x = 0; x < CrosswordWidth; x++)
{
TableAcrossWord[x][y] = -1;
TableDownWord[x][y] = -1;
}
// First, add the horizontal words to the puzzle.
for (var i = 0; i <= LastHorizontalWord; i++)
{
x = WordX[i];
y = WordY[i];
for (var j = 0; j < WordLength[i]; j++)
{
TableAcrossWord[x + j][y] = i;
}
}
// Second, add the vertical words to the puzzle.
for (var i = LastHorizontalWord + 1; i < Words; i++)
{
x = WordX[i];
y = WordY[i];
for (var j = 0; j < WordLength[i]; j++)
{
TableDownWord[x][y + j] = i;
}
}
// Now, insert the row HTML into the table.
for (var y = 0; y < CrosswordHeight; y++)
{
document.writeln("<tr>");
for (var x = 0; x < CrosswordWidth; x++)
{
if (TableAcrossWord[x][y] >= 0 || TableDownWord[x][y] >= 0)
document.write("<td id=\"c" + PadNumber(x) + PadNumber(y) + "\" class=\"ecw-box ecw-boxnormal_unsel\" onclick=\"SelectThisWord(event);\"> </td>");
else
document.write("<td></td>");
}
document.writeln("</tr>");
}
// Finally, show the crossword and hide the wait message.
Initialized = true;
document.getElementById("waitmessage").style.display = "none";
document.getElementById("crossword").style.display = "block";
}
// ----------
// Event handlers
// Raised when a key is pressed in the word entry box.
function WordEntryKeyPress(event)
{
if (CrosswordFinished) return;
// Treat an Enter keypress as an OK click.
if (CurrentWord >= 0 && event.keyCode == 13) OKClick();
}
// ----------
// Helper functions
// Called when we're ready to start the crossword.
function BeginCrossword()
{
if (Initialized)
{
document.getElementById("welcomemessage").style.display = "";
document.getElementById("checkbutton").style.display = "";
}
}
// Returns true if the string passed in contains any characters prone to evil.
function ContainsBadChars(theirWord)
{
for (var i = 0; i < theirWord.length; i++)
if (BadChars.indexOf(theirWord.charAt(i)) >= 0) return true;
return false;
}
// Pads a number out to three characters.
function PadNumber(number)
{
if (number < 10)
return "00" + number;
else if (number < 100)
return "0" + number;
else
return "" + number;
}
// Returns the table cell at a particular pair of coordinates.
function CellAt(x, y)
{
return document.getElementById("c" + PadNumber(x) + PadNumber(y));
}
// Deselects the current word, if there's a word selected. DOES not change the value of CurrentWord.
function DeselectCurrentWord()
{
if (CurrentWord < 0) return;
var x, y, i;
document.getElementById("answerbox").style.display = "none";
ChangeCurrentWordSelectedStyle(false);
CurrentWord = -1;
}
// Changes the style of the cells in the current word.
function ChangeWordStyle(WordNumber, NewStyle)
{
if (WordNumber< 0) return;
var x = WordX[WordNumber];
var y = WordY[WordNumber];
if (WordNumber<= LastHorizontalWord)
for (i = 0; i < WordLength[WordNumber]; i++)
CellAt(x + i, y).className = NewStyle;
else
for (i = 0; i < WordLength[WordNumber]; i++)
CellAt(x, y + i).className = NewStyle;
}
// Changes the style of the cells in the current word between the selected/unselected form.
function ChangeCurrentWordSelectedStyle(IsSelected)
{
if (CurrentWord < 0) return;
var x = WordX[CurrentWord];
var y = WordY[CurrentWord];
if (CurrentWord <= LastHorizontalWord)
for (i = 0; i < WordLength[CurrentWord]; i++)
CellAt(x + i, y).className = CellAt(x + i, y).className.replace(IsSelected ? "_unsel" : "_sel", IsSelected ? "_sel" : "_unsel");
else
for (i = 0; i < WordLength[CurrentWord]; i++)
CellAt(x, y + i).className = CellAt(x, y + i).className.replace(IsSelected ? "_unsel" : "_sel", IsSelected ? "_sel" : "_unsel");
}
// Selects the new word by parsing the name of the TD element referenced by the
// event object, and then applying styles as necessary.
function SelectThisWord(event)
{
if (CrosswordFinished) return;
var x, y, i, TheirWord, TableCell;
// Deselect the previous word if one was selected.
document.getElementById("welcomemessage").style.display = "none";
if (CurrentWord >= 0) OKClick();
DeselectCurrentWord();
// Determine the coordinates of the cell they clicked, and then the word that
// they clicked.
var target = (event.srcElement ? event.srcElement: event.target);
x = parseInt(target.id.substring(1, 4), 10);
y = parseInt(target.id.substring(4, 7), 10);
// If they clicked an intersection, choose the type of word that was NOT selected last time.
if (TableAcrossWord[x][y] >= 0 && TableDownWord[x][y] >= 0)
CurrentWord = PrevWordHorizontal ? TableDownWord[x][y] : TableAcrossWord[x][y];
else if (TableAcrossWord[x][y] >= 0)
CurrentWord = TableAcrossWord[x][y];
else if (TableDownWord[x][y] >= 0)
CurrentWord = TableDownWord[x][y];
PrevWordHorizontal = (CurrentWord <= LastHorizontalWord);
// Now, change the style of the cells in this word.
ChangeCurrentWordSelectedStyle(true);
// Then, prepare the answer box.
x = WordX[CurrentWord];
y = WordY[CurrentWord];
TheirWord = "";
var TheirWordLength = 0;
for (i = 0; i < WordLength[CurrentWord]; i++)
{
// Find the appropriate table cell.
if (CurrentWord <= LastHorizontalWord)
TableCell = CellAt(x + i, y);
else
TableCell = CellAt(x, y + i);
// Add its contents to the word we're building.
if (TableCell.innerHTML != null && TableCell.innerHTML.length > 0 && TableCell.innerHTML != " " && TableCell.innerHTML.toLowerCase() != " ")
{
TheirWord += TableCell.innerHTML.toUpperCase();
TheirWordLength++;
}
else
{
TheirWord += "•";
}
}
document.getElementById("wordlabel").innerHTML = TheirWord;
document.getElementById("wordinfo").innerHTML = ((CurrentWord <= LastHorizontalWord) ? "По горизонтали, " : "По вертикали, ") + WordLength[CurrentWord] + " букв(-ы).";
document.getElementById("wordclue").innerHTML = Clue[CurrentWord];
document.getElementById("worderror").style.display = "none";
if (TheirWordLength == WordLength[CurrentWord])
document.getElementById("wordentry").value = TheirWord;
else
document.getElementById("wordentry").value = "";
// Finally, show the answer box.
document.getElementById("answerbox").style.display = "block";
try
{
document.getElementById("wordentry").focus();
document.getElementById("wordentry").select();
}
catch (e)
{
}
}
// Called when the user clicks the OK link.
function OKClick()
{
var TheirWord, x, y, i, TableCell;
if (CrosswordFinished) return;
if (document.getElementById("okbutton").disabled) return;
// First, validate the entry.
TheirWord = document.getElementById("wordentry").value.toUpperCase();
if (TheirWord.length == 0)
{
DeselectCurrentWord();
return;
}
if (ContainsBadChars(TheirWord))
{
document.getElementById("worderror").innerHTML = "Только буквы!.";
document.getElementById("worderror").style.display = "block";
return;
}
if (TheirWord.length < WordLength[CurrentWord])
{
document.getElementById("worderror").innerHTML = "Мало букв. Слово состоит из " + WordLength[CurrentWord] + " букв(-ы).";
document.getElementById("worderror").style.display = "block";
return;
}
if (TheirWord.length > WordLength[CurrentWord])
{
document.getElementById("worderror").innerHTML = "Много букв. Слово состоит из " + WordLength[CurrentWord] + " букв(-ы).";
document.getElementById("worderror").style.display = "block";
return;
}
// If we made it this far, they typed an acceptable word, so add these letters to the puzzle and hide the entry box.
x = WordX[CurrentWord];
y = WordY[CurrentWord];
for (i = 0; i < TheirWord.length; i++)
{
TableCell = CellAt(x + (CurrentWord <= LastHorizontalWord ? i : 0), y + (CurrentWord > LastHorizontalWord ? i : 0));
TableCell.innerHTML = TheirWord.substring(i, i + 1);
}
DeselectCurrentWord();
}
// Called when the "check puzzle" link is clicked.
function CheckClick()
{
var i, j, x, y, UserEntry, ErrorsFound = 0, EmptyFound = 0, TableCell;
if (CrosswordFinished) return;
DeselectCurrentWord();
for (y = 0; y < CrosswordHeight; y++)
for (x = 0; x < CrosswordWidth; x++)
if (TableAcrossWord[x][y] >= 0 || TableDownWord[x][y] >= 0)
{
TableCell = CellAt(x, y);
if (TableCell.className == "ecw-box ecw-boxerror_unsel") TableCell.className = "ecw-box ecw-boxnormal_unsel";
}
for (i = 0; i < Words; i++)
{
// Get the user's entry for this word.
UserEntry = "";
for (j = 0; j < WordLength[i]; j++)
{
if (i <= LastHorizontalWord)
TableCell = CellAt(WordX[i] + j, WordY[i]);
else
TableCell = CellAt(WordX[i], WordY[i] + j);
if (TableCell.innerHTML.length > 0 && TableCell.innerHTML.toLowerCase() != " ")
{
UserEntry += TableCell.innerHTML.toUpperCase();
}
else
{
UserEntry = "";
EmptyFound++;
break;
}
}
// If this word doesn't match, it's an error.
if (HashWord(UserEntry) != AnswerHash[i] && UserEntry.length > 0)
{
ErrorsFound++;
ChangeWordStyle(i, "ecw-box ecw-boxerror_unsel");
}
}
// If they can only check once, disable things prematurely.
if ( OnlyCheckOnce )
{
CrosswordFinished = true;
document.getElementById("checkbutton").style.display = "none";
}
// If errors were found, just exit now.
if (ErrorsFound > 0 && EmptyFound > 0)
document.getElementById("welcomemessage").innerHTML = ErrorsFound + (ErrorsFound > 1 ? " errors" : " error") + " and " + EmptyFound + (EmptyFound > 1 ? " incomplete words were" : " incomplete word was") + " found.";
else if (ErrorsFound > 0)
document.getElementById("welcomemessage").innerHTML = ErrorsFound + (ErrorsFound > 1 ? " errors were" : " error was") + " found.";
else if (EmptyFound > 0)
document.getElementById("welcomemessage").innerHTML = "Нет ошибок, но " + EmptyFound + (EmptyFound > 1 ? " слов осталось разгадать" : " слово осталось разгодать") + " .";
if (ErrorsFound + EmptyFound > 0)
{
document.getElementById("welcomemessage").style.display = "";
return;
}
// They finished the puzzle!
CrosswordFinished = true;
document.getElementById("checkbutton").style.display = "none";
document.getElementById("congratulations").style.display = "block";
document.getElementById("welcomemessage").style.display = "none";
}
// Called when the "cheat" link is clicked.
function CheatClick()
{
if (CrosswordFinished) return;
var OldWord = CurrentWord;
document.getElementById("wordentry").value = Word[CurrentWord];
OKClick();
ChangeWordStyle(OldWord, "ecw-box ecw-boxcheated_unsel");
}
// Returns a one-way hash for a word.
function HashWord(Word)
{
var x = (Word.charCodeAt(0) * 719) % 1138;
var Hash = 837;
var i;
for (i = 1; i <= Word.length; i++)
Hash = (Hash * i + 5 + (Word.charCodeAt(i - 1) - 64) * x) % 98503;
return Hash;
}
</script>
</table></td>
<td valign="top" style="padding-left: 1em;">
<!--<div class="ecw-copyright">
<a href="http://www.eclipsecrossword.com/" target="_blank" style="font-weight: bold;">EclipseCrossword</a> © 2000-2010
</div>-->
<div id="welcomemessage" class="ecw-answerbox" style="display:none;">
<h3>Добро пожаловать</h3>
<p>Кликните на кроссворд для старта.</p>
</div>
<div id="answerbox" class="ecw-answerbox" style="display:none;">
<h3 id="wordlabel" class="ecw-wordlabel"> </h3>
<div id="wordinfo" class="ecw-wordinfo"> </div>
<div id="wordclue" class="ecw-cluebox"> </div>
<div style="margin-top: 1em;">
<input class="ecw-input" id="wordentry" type="text" size="24" style="font-weight: bold; text-transform:uppercase;" onkeypress="WordEntryKeyPress(event)" onchange="WordEntryKeyPress(event)" autocomplete="off" />
</div>
<div id="worderror" class="ecw-worderror"></div>
<table border="0" cellspacing="0" cellpadding="0" width="100%" style="margin-top:1em;"><tbody><tr><td>
</td><td align="right">
<button id="okbutton" type="button" class="ecw-input ecw-button" onclick="OKClick();" style="font-weight: bold;">
OK</button>
<button id="cancelbutton" type="button" class="ecw-input ecw-button" onclick="DeselectCurrentWord();">
Cancel</button>
</td></tr></tbody></table>
</div>
<div id="congratulations" class="ecw-answerbox" style="display:none;">
<h3>Поздравляю!</h3>
<p>Вы полностью разгадали кроссворд.</p>
</div>
</td></tr></table>
<div style="margin-top: 1em;">
<button id="checkbutton" type="button" onclick="CheckClick();" style="display: none;">
Проверить ошибки</button>
</div>
<script>
BeginCrossword();
</script>
</body>
</html>