forked from apatterson1/team-i-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
45 lines (40 loc) · 1.66 KB
/
index.js
File metadata and controls
45 lines (40 loc) · 1.66 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
$(function() {
//16 cards in total, 4x4 id: c1-c16
var flipped="";
var score = 0;
for(var i = 1; i<=16; i++){
$("#card-" + i).flip({
trigger: 'manual'
});
$("#card-" + i).on("click", function(event){
$(this).flip(true);
var cardType = $(this).attr("data");
if (!flipped){
// this means if no card has been flipped
flipped = cardType;
//this takes the value
} else{
if (flipped == cardType){
$("[data="+ cardType + "]").unbind("click");
score = score + 125;
if(score == 1000) {
$( ".container" ).remove();
alert("YOU HAVE WON THE UNIVERSE!!!!!!");
$("body").append("<img id='winning' width = '200px;' src = 'http://i.giphy.com/k7nUblXRPCsc8.gif'/>");
$("body").append("<img id='winning' src = 'https://i.imgur.com/rfFWukr.gif'/>");
$("body").append("<img id='winning' src = 'http://i.giphy.com/OTOXNsMqmoNEI.gif'/>");
$("body").append("<img id='winning' src = 'http://i.giphy.com/3rgXBFFa1uk6ChdJVm.gif'/>");
}
$("#score").text(score);
flipped = "";
} else {
setTimeout(function(){
$(this).flip(false);
$("[data=" + flipped + "]").flip(false);
flipped = "";
}.bind(this), 1000);
}
}
});
}
});