-
Notifications
You must be signed in to change notification settings - Fork 0
/
Like.js
57 lines (48 loc) · 1.84 KB
/
Like.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
let block = document.querySelector('.heart');
let heart = document.getElementById('h');
let count = document.getElementById('c');
let block2 = document.querySelector('.dislike');
let dizlike = document.getElementById('d');
let d = document.getElementById('l');
let heart_item = document.querySelector('.heart-item');
let dizlike_item = document.querySelector('.dizlike-item');
block2.addEventListener('click', Plus2);
block.addEventListener('click', Plus);
block.addEventListener('mouseover', function() {
heart_item.classList.toggle('anim1');
heart_item.classList.toggle('anim2');
heart_item.classList.toggle('anim3');
heart_item.classList.toggle('anim4');
});
block2.addEventListener('mouseover', function() {
dizlike_item.classList.toggle('d1');
dizlike_item.classList.toggle('d2');
dizlike_item.classList.toggle('d3');
dizlike_item.classList.toggle('d4');
});
let like = 1;
function Plus() {
count.textContent = like;
like++;
if(like) {
block.classList.toggle('hide');
heart.classList.toggle('color');
}
if(count >= 300) {
alert('Image is very populary');
return location.reload();
}
}
let dislike = 1;
function Plus2() {
d.textContent = dislike;
dislike++;
if(dislike) {
block2.classList.toggle('b');
dizlike.classList.toggle('c');
}
if(dislike >= 300) {
alert('Image is very fuck');
return location.reload();
}
}