-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.js
347 lines (315 loc) · 11.3 KB
/
search.js
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
function openSlideMenu(){
document.getElementById("slide-menu").style.width = '250px';
/*document.getElementById("main-content").style.Left = '250px';*/
}
function closeSlideMenu(){
document.getElementById("slide-menu").style.width = '0px';
/*document.getElementById("main-content").style.marginLeft = '0px';*/
}
function check(val){
changeDisplay("Берилий Be",4,val,"Be");
changeDisplay("Магнезий Mg",12,val,"Mg");
changeDisplay("Калций Ca",20,val,"Ca");
changeDisplay("Стронций Sr",38,val,"Sr");
changeDisplay("Барий Ba",56,val,"Ba");
changeDisplay("Бор B",5,val,"B");
changeDisplay("Алуминий Al",13,val,"Al");
changeDisplay("Галий Ga",31,val,"Ga");
changeDisplay("Индий In",49,val,"In");
changeDisplay("Талий Ti",81,val,"Ti");
changeDisplay("Въглерод C",6,val,"C");
changeDisplay("Силиций Si",14,val,"Si");
changeDisplay("Германий Ge",32,val,"Ge");
changeDisplay("Калай Sn",50,val,"Sn");
changeDisplay("Олово Pb",82,val,"Pb");
changeDisplay("Азот N",7,val,"N");
changeDisplay("Фосфор P",15,val,"P");
changeDisplay("Арсен As",33,val,"As");
changeDisplay("Антимон Sb",51,val,"Sb");
changeDisplay("Бисмут Bi",83,val,"Bi");
changeDisplay("Кислород O",8,val,"O");
changeDisplay("Сяра S",16,val,"S");
changeDisplay("Селен Se",34,val,"Se");
changeDisplay("Телур Te",52,val,"Te");
changeDisplay("Флуор F",9,val,"F");
changeDisplay("Хлор Cl",17,val,"Cl");
changeDisplay("Бром Br",35,val,"Br");
changeDisplay("Йод I",53,val,"I");
}
/*function changeDisplay2(el,s,id) {
if (s==""){document.getElementById(id).style.display = "none";
return;
}
s = s.toLowerCase();
el=el.toLowerCase();
var n = el.search(s);
document.getElementById("test").innerHTML = n;
document.getElementById(id).style.display = "block";
if(n>-1){
document.getElementById(id).style.display = "block";
}else{
document.getElementById(id).style.display = "none";
}
}*/
function changeDisplay(el,p,s,id) {
if (s==""){document.getElementById(id).style.display = "none";
return;
}
s = s.toLowerCase();
el=el.toLowerCase();
var n = el.search(s);
/*document.getElementById("test").innerHTML = n;*/
/*document.getElementById(id).style.display = "block";*/
if(n>-1||p==parseInt(s)){
document.getElementById(id).style.display = "block";
}else{
document.getElementById(id).style.display = "none";
}
}
function closeSearch(){
document.getElementById("Be").style.display = "none";
document.getElementById("Mg").style.display = "none";
document.getElementById("Ca").style.display = "none";
document.getElementById("Sr").style.display = "none";
document.getElementById("Ba").style.display = "none";
document.getElementById("B").style.display = "none";
document.getElementById("Al").style.display = "none";
document.getElementById("Ga").style.display = "none";
document.getElementById("In").style.display = "none";
document.getElementById("Ti").style.display = "none";
document.getElementById("C").style.display = "none";
document.getElementById("Si").style.display = "none";
document.getElementById("Ge").style.display = "none";
document.getElementById("Sn").style.display = "none";
document.getElementById("Pb").style.display = "none";
document.getElementById("N").style.display = "none";
document.getElementById("P").style.display = "none";
document.getElementById("As").style.display = "none";
document.getElementById("Sb").style.display = "none";
document.getElementById("Bi").style.display = "none";
document.getElementById("O").style.display = "none";
document.getElementById("S").style.display = "none";
document.getElementById("Se").style.display = "none";
document.getElementById("Te").style.display = "none";
document.getElementById("F").style.display = "none";
document.getElementById("Cl").style.display = "none";
document.getElementById("Br").style.display = "none";
document.getElementById("I").style.display = "none";
}
function checkGame(){
var elmnt = document.getElementById("scroll");
var x = elmnt.scrollLeft;
var img=document.getElementById("q");
var a1=document.getElementById("a1");
var a2=document.getElementById("a2");
/*document.getElementById ("demo").style.visibility ="visible";*/
if (x>430&&x<460) {
document.getElementById ("demo").innerHTML ="Кой е този елемент?";
document.getElementById ("demo").style.color ="blue";
return;
}
if (a1.getAttribute("data-pos")==q.getAttribute("data-pos"))
{
/*document.getElementById ("demo").innerHTML=a1.getAttribute("data-pos");*/
if (x<892/2) {
document.getElementById ("demo").innerHTML ="Ура! Да живее трудът!";
document.getElementById ("demo").style.color ="green";
}
else {
document.getElementById ("demo").innerHTML ="Грешка ;(";
document.getElementById ("demo").style.color ="red";
}
/*document.getElementById ("demo").innerHTML =x;*/
return;
}
else {
if (x>892/2) {
document.getElementById ("demo").innerHTML ="Ура! Да живее трудът!";
document.getElementById ("demo").style.color ="green";
}
else {
document.getElementById ("demo").innerHTML ="Грешка ;(";
document.getElementById ("demo").style.color ="red";
}
/*document.getElementById ("demo").innerHTML =x;*/
return;
}
}
function shufflePics(){
var p=[
"assets/IIA/Ba_Picture.jpg",
"assets/IIA/Be_Picture.jpg",
"assets/IIA/Ca_Picture.jpg",
"assets/IIA/Mg_Picture.jpg",
"assets/IIA/Sr_Picture.jpg",
"assets/IIIA/Al_Picture.jpg",
"assets/IIIA/B_Picture.jpg",
"assets/IIIA/Ga_Picture.jpg",
"assets/IIIA/In_Picture.jpg",
"assets/IIIA/Tl_game.png",
"assets/IVA/C_Picture.jpg",
"assets/IVA/Ge_Picture.jpg",
"assets/IVA/Si_Picture.jpg",
"assets/IVA/Sn_Picture.jpg",
"assets/VA/As_Picture.jpg",
"assets/VA/N_Picture.jpg",
"assets/VA/P_Picture.png",
"assets/VA/Sb_Picture.jpg",
"assets/VIA/O_Picture.jpg",
"assets/VIA/S_Picture.jpg",
"assets/VIA/Se_Picture.jpg",
"assets/VIA/Te_Picture.jpg",
"assets/VIIA/Br_Picture.png",
"assets/VIIA/Cl_Picture.jpg",
"assets/VIIA/F_Picture.jpg",
"assets/VIIA/I_Picture.jpg",
"assets/IVA/Bi_Picture.jpg",
"assets/VA/Pb_Picture.jpg",
];
var n=[
"Барий","Берилий","Калций","Магнезий","Стронций","Алуминий","Бор","Галий","Индий","Талий","Въглерод","Германий","Силиций","Калай","Арсен","Азот","Фосфор","Антимон","Кислород","Сяра","Селен","Телур","Бром","Хлор","Флуор","Йод","Бисмут","Олово"
];
document.getElementById("scroll").scrollLeft=446;
var r=Math.floor(Math.random()*27);
var rndPos=Math.floor(Math.random()*2);
if (rndPos>0) {
document.getElementById("a1").innerHTML =n[r];
document.getElementById("a1").setAttribute("data-pos",r);
var secP;
do {
secP=Math.floor(Math.random()*27);
}
while (secP==r);
document.getElementById("a2").innerHTML =n[secP];
document.getElementById("a2").setAttribute("data-pos",secP);
}
else {
document.getElementById("a2").innerHTML =n[r];
document.getElementById("a2").setAttribute("data-pos",r);
var secP;
do {
secP=Math.floor(Math.random()*27);
}
while (secP==r);
document.getElementById("a1").innerHTML =n[secP];
document.getElementById("a1").setAttribute("data-pos",secP);
}
document.getElementById("q").setAttribute("data-pos",r);
return p[r];
}
var selected=-1;
var el=document.getElementsByClassName("element");
var boxes=document.getElementsByClassName("box");
var num = document.getElementsByClassName("number");
var n=[4,5,6,7,8,9,12,13,14,15,16,17,20,31,32,33,34,35,38,49,50,51,52,53,56,81,82,83];
function Load(){
var names=["Берилий","Бор","Въглерод","Азот","Кислород","Флуор","Магнезий","Алуминий","Силиций","Фосфор","Сяра","Хлор","Калций","Галий","Германий","Арсен","Селен","Бром","Стронций","Индий","Калай","Антимон","Телур","Йод","Барий","Талий","Олово","Бисмут"];
/*var num=document.getElementByClassName("box");*/
for (var i = 0; i < num.length; i++) {
do {
rand=Math.floor(Math.random()*n.length);
} while (
rand==el[0].getAttribute("data-n")
||rand==el[1].getAttribute("data-n")
||rand==el[2].getAttribute("data-n")
||rand==el[3].getAttribute("data-n")
||rand==el[4].getAttribute("data-n")
);
num[i].innerHTML=n[rand];
el[i].innerHTML=names[rand];
/*num[i].setAttribute('data-n',rand);*/
el[i].setAttribute('data-n',rand);
}
var a;
var b;
var c;
var an;
var bn;
for (var i = 0; i < 10; i++) {
a=Math.floor(Math.random()*el.length);
b=Math.floor(Math.random()*el.length);
c=el[a].innerHTML;
an=el[a].getAttribute("data-n");
bn=el[b].getAttribute("data-n");
el[a].innerHTML=el[b].innerHTML;
el[a].setAttribute("data-n",bn);
el[b].setAttribute("data-n",an);
el[b].innerHTML=c;
}
}
function Buf(sel){
if (sel==selected) {
el[selected].style.color="blue";
el[selected].style.border="2px solid black";
selected=-1;
return;
}
if (selected>-1) {
el[selected].style.color="blue";
el[selected].style.border="2px solid black";
}
selected=sel;
el[selected].style.color="grey";
el[selected].style.border="2px solid grey";
}
function Put(sel){
if (selected==-1){
boxes[sel].setAttribute("data-n",-1);
boxes[sel].style.color="transparent";
boxes[sel].innerHTML="def";
return;
}
for (var i = 0; i < el.length; i++) {
if (el[selected].innerHTML==boxes[i].innerHTML&&i!=sel) {
alert('Вече е използван!');
return;
}
}
if (selected>-1) {
boxes[sel].innerHTML=el[selected].innerHTML;
var b=el[selected].getAttribute("data-n");
boxes[sel].setAttribute("data-n",b);
boxes[sel].style.color="black";
Buf(selected);
}
}
function checkGame2(){
var er=0;
for (var i = 0; i < boxes.length; i++) {
if(n[boxes[i].getAttribute("data-n")]==num[i].innerHTML){
boxes[i].style.background="#66ff66";
}
else{
boxes[i].style.background="red";
boxes[i].style.color="transparent";
boxes[i].innerHTML="Елемент";
er=er+1;
}
}
if (er>0) {
document.getElementById("message").innerHTML="Имаш " + er + " грешки";
document.getElementById("message").style.color="red";
}
else{
document.getElementById("message").style.color="green";
document.getElementById("message").innerHTML="Отлично!";
}
}
/*function Rem(sel){
if(boxes[sel].style.color!="transparent"{
boxes[sel].style.color="transparent";
boxes[sel].innerHTML="df";
}
}*/
var looper;
var degrees = 0;
function rotateAnimation(el,speed){
var elem = document.getElementById(el);
elem.style.transform = "rotate("+degrees+"deg)";
looper = setTimeout('rotateAnimation(\''+el+'\','+speed+')',speed);
degrees++;
if(degrees > 359){
degrees = 1;
}
document.getElementById("status").innerHTML = "rotate("+degrees+"deg)";
}