-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphpex.js
More file actions
23 lines (22 loc) · 826 Bytes
/
Copy pathphpex.js
File metadata and controls
23 lines (22 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$(".btn-like").each(function(idx, el) {
var button = $(el)
var heartShape = button.find(".heart-shape")
$.get("/practice/like_proc.php", {
getLikedByCode: button.data("articleId")
}, function(res) {
heartShape.text(res == "liked" ? "♥" : "♡")
button.fadeIn(200)
})
})
$(".btn-like").on("click", function(e) {
var button = $(e.currentTarget || e.target)
var likeCount = button.find(".like-count")
var heartShape = button.find(".heart-shape")
$.post("/practice/like_proc.php", {
articleId: button.data("articleId")
}, function(res) {
var addCount = (res == "like" ? 1 : res == "unlike" ? -1 : 0)
likeCount.text(+likeCount.text() + addCount)
heartShape.text(res == "like" ? "♥" : res == "unlike" ? "♡" : "♡")
})
})