mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
23 lines
No EOL
669 B
JavaScript
23 lines
No EOL
669 B
JavaScript
var Like = function(eventId, csrfToken) {
|
|
this.eventId = eventId
|
|
this.csrfToken = csrfToken
|
|
this.link = $('#event_'+this.eventId+'_actions a#like')
|
|
}
|
|
|
|
Like.prototype.toggleLike = function() {
|
|
var self = this
|
|
$.post('/event/'+this.eventId+'/toggle_like', {csrf_token: this.csrfToken}, function(res) {
|
|
if(res.result == 'liked')
|
|
self.link.text('Unlike ('+res.event_like_count+')')
|
|
|
|
if(res.result == 'unliked') {
|
|
var linkText = 'Like'
|
|
|
|
if(res.event_like_count > 0)
|
|
linkText += ' ('+res.event_like_count+')'
|
|
|
|
self.link.text(linkText)
|
|
}
|
|
self.link.attr('data-original-title', res.liking_site_names.join('<br>'))
|
|
})
|
|
} |