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
| var abc = ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","\u20ac","\u0192","\u0160","\u017d","\u0161","\u0153","\u017e","\u0178","\u00a1","\u00a2","\u00a3","\u00a4","\u00a5","\u00a7","\u00c0","\u00c1","\u00c2","\u00c3","\u00c4","\u00c5","\u00c6","\u00c7","\u00c8","\u00c9","\u00ca","\u00cb","\u00cc","\u00cd","\u00ce","\u00cf","\u00d0","\u00d1","\u00d2","\u00d3","\u00d4","\u00d5","\u00d6","\u00d7","\u00d8","\u00d9","\u00da","\u00db","\u00dc","\u00dd","\u00de","\u00df","\u00e0","\u00e1","\u00e2","\u00e3","\u00e4","\u00e5","\u00e6","\u00e7","\u00e8","\u00e9","\u00ea","\u00eb","\u00ec","\u00ed","\u00ee","\u00ef","\u00f0","\u00f1","\u00f2","\u00f3","\u00f4","\u00f5","\u00f6","\u00f9","\u00fa","\u00fb","\u00fc","\u00fd","\u00fe"];
$('.words A').hover(function(event){
event.stopPropagation();
map($(this).html());
//var t=$(this);
//if (!t.attr('title')) $.getJSON('https://web.archive.org/web/20150315004736/http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=������%2B'+t.html()+'&callback=?', function(data){
// t.attr('title', data.responseData.results[0].content);
//});
},function(event){
event.stopPropagation();
$('.letter_input').removeClass('highlight');
$('.add').val('').removeClass('add');
}).click(function(){
var array = localStorage['balda'] ? JSON.parse(localStorage['balda']) : {};
var a = $(this);
array[a.text()] = a.toggleClass('hidden').hasClass('hidden');
localStorage['balda'] = JSON.stringify(array);
$('#balda_form').submit();
return false;
});
if (!!window.localStorage){
delete localStorage['balda']; // прячем слова удаленные юзером
var hide_words = localStorage['balda'] ? JSON.parse(localStorage['balda']) : {};
for (var key in hide_words) if (hide_words[key]) $("#w"+key).addClass('hidden');
$('.close').click(function(){
var a = $(this).prev();
hide_words[a.text()] = a.toggleClass('hidden').hasClass('hidden');
localStorage['balda'] = JSON.stringify(hide_words);
});
}
$('input').focus(function(){
$(this).select(); // select on focus
$(this).select().mouseup(function (e) {
e.preventDefault(); // fix for chrome
$(this).unbind('mouseup');
});
}).keyup(function(event){
if (event.which == 9) return; // tab
if (event.which == 8 || event.which == 37) $(this).prev('input:first').focus(); // left
else if (event.which == 38) $('#'+abc[abc.indexOf($(this).attr('id'))-5]).focus(); // up
else if (event.which == 39 || event.which == 32) $(this).next('input:first').focus(); // right
else if (event.which == 40) $('#'+abc[abc.indexOf($(this).attr('id'))+5]).focus(); // down
else if (event.which >= 48 && event.which <= 90) $(this).next('input:first').focus();
});
function map(word){
$('.add').val('').removeClass('add');
$('.number').remove();
var wordArr = [word];
if(!Array.prototype.indexOf)
Array.prototype.indexOf = function(searchElement, fromIndex){
for(var i = fromIndex||0, length = this.length; i<length; i++)
if(this[i] === searchElement) return i;
return -1
};
for (st=0;st<wordArr.length;st++){ // перебор комбинаций написания слова
var prefix = [];
prefix[0] = [];
// ищем ячейки с первой буквой слова
for (var i=0;i<25;i++){
if ($('#'+abc[i]).val()=='') var pvalue = '_';
else var pvalue = $('#'+abc[i]).val();
if (pvalue==wordArr[st][0]) prefix[0][prefix[0].length] = abc[i];
}
for (var a=1;a<wordArr[st].length;a++){ // перебор букв с 1 по последнюю в слове
prefix[a] = [];
for (i=0;i<prefix[a-1].length;i++){ // перебор ячеек-1 от текущей
var endprefix = prefix[a-1][i][prefix[a-1][i].length-1]; // ячейка-1
var point = abc.indexOf(endprefix); // порядковый номер ячейки
var sosedi = [];
if ((point-5)>-1) sosedi.push(point-5); // top
if ((point+1) % 5) sosedi.push(point+1); // right
if ((point+5) < 25) sosedi.push(point+5); // down
if ((point-1)>-1 && point % 5) sosedi.push(point-1);
for (ii=0;ii<sosedi.length;ii++){
if ($('#'+abc[sosedi[ii]]).val()=='') var pvalue = '_'; else var pvalue = $('#'+abc[sosedi[ii]]).val();
var nopref = 0;
for (var iii=0;iii<prefix[a-1][i].length;iii++) {
if (prefix[a-1][i][iii] == abc[sosedi[ii]]) nopref = 1;
}
if (wordArr[st][a]==pvalue && nopref==0){
prefix[a][prefix[a].length] = prefix[a-1][i]+abc[sosedi[ii]];
if (a==word.length-1){ // ����� ������ �����
var road = prefix[a][0];
for (var i =0;i<road.length;i++) {
$('#'+road[i]).addClass('highlight').before("<b class='number'>"+(i+1)+"</b>");
if ($('#'+road[i]).val()==''){
$('#'+road[i]).val(word[i]).addClass('add');
}
}
return;
}
}
}
}
}
}
} |