mirror of
https://github.com/neocities/neocities.git
synced 2025-05-30 01:10:07 +02:00
comment liking
This commit is contained in:
parent
8210670122
commit
51a85a0b03
9 changed files with 125 additions and 29 deletions
|
@ -15,5 +15,24 @@ var Comment = {
|
|||
console.log(res)
|
||||
location.reload()
|
||||
})
|
||||
},
|
||||
|
||||
toggleLike: function(commentId, csrfToken) {
|
||||
var link = $('#comment_'+commentId+'_like')
|
||||
|
||||
$.post('/comment/'+commentId+'/toggle_like', {csrf_token: csrfToken}, function(res) {
|
||||
if(res.result == 'liked')
|
||||
link.text('Unlike ('+res.comment_like_count+')')
|
||||
|
||||
if(res.result == 'unliked') {
|
||||
var linkText = 'Like'
|
||||
|
||||
if(res.comment_like_count > 0)
|
||||
linkText += ' ('+res.comment_like_count+')'
|
||||
|
||||
link.text(linkText)
|
||||
}
|
||||
link.attr('data-original-title', res.liking_site_names.join('<br>'))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue