-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaScript.js
More file actions
71 lines (65 loc) · 1.52 KB
/
JavaScript.js
File metadata and controls
71 lines (65 loc) · 1.52 KB
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
var targ;
var prev;
var p;
var find=0;
var sum=0;
var count = 0;
function start() {
for (var i = 0; i <2; i++)
{
for (var j = 1; j < 10; j++)
{
var x = document.createElement("div");
x.setAttribute("data-game", "set" + j);
x.setAttribute("data-find", "of");
document.getElementById("warp").appendChild(x);
}
}
}
function check()
{
if (event.target == event.currentTarget)
return;
if (count==2|| event.target.getAttribute("data-find" == "on"))
return;
p = event.target;
if (p == prev)
return;
p.classList.add(p.getAttribute("data-game"))
if (count == 0)
{
prev = p;
count = 1;
}
else
{
count = 2;
window.setTimeout("close()", 1000);
}
}
function close()
{
if (prev.getAttribute("data-game") == p.getAttribute("data-game")) {
find += 1;
sum += 10;
document.getElementById("score").innerHTML = sum;
prev.style.opacity = "0.5";
p.style.opacity = "0.5";
if (sum == 90) {
document.getElementById("score").innerHTML = "you win!";
end();
}
}
else
{
prev.classList.remove(prev.getAttribute("data-game"));
p.classList.remove(p.getAttribute("data-game"));
}
count = 0;
prev = p = null;
}
function end()
{
document.getElementById("end1").style.display = "grid";
document.getElementsByClassName("finish")[0].style.display = "grid";
}