-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
30 lines (27 loc) 路 1.27 KB
/
Copy pathscript.js
File metadata and controls
30 lines (27 loc) 路 1.27 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
const emojis = ["馃槏","馃槏","鉂わ笍","鉂わ笍","馃槑","馃槑","馃槨","馃槨","馃槶","馃槶","馃憤","馃憤","馃樀","馃樀","馃ぉ","馃ぉ"];
var shuf_emojis = emojis.sort(() => (Math.random() > .5) ? 2 : -1);
for (let i=0; i<emojis.length; i++){
let box = document.createElement('div')
box.className = 'item';
box.innerHTML = shuf_emojis[i]
box.onclick = function(){
this.classList.add('boxOpen')
setTimeout(function(){
if(document.querySelectorAll('.boxOpen').length > 1){
if(document.querySelectorAll('.boxOpen')[0].innerHTML == document.querySelectorAll('.boxOpen'[1]).innerHTML){
document.querySelectorAll('.boxOpen')[0].classList.add('bocMatch')
document.querySelectorAll('.boxOpen')[1].classList.add('boxMatch')
document.querySelectorAll('.boxOpen')[1].classList.remove('boxOpen')
document.querySelectorAll('.boxOpen')[0].classList.remove('boxOpen')
if(document.querySelectorAll('.boxMatch').length == emojis.length){
alert('win')
}
} else{
document.querySelectorAll('.boxOpen')[1].classList.remove('boxOpen')
document.querySelectorAll('.boxOpen')[0].classList.remove('boxOpen')
}
}
},500)
}
document.querySelector('.game').appendChild(box);
}