mirror of
https://github.com/neocities/neocities.git
synced 2025-08-05 09:11:28 +02:00
event like support
This commit is contained in:
parent
cf6bf7f031
commit
eba4a6e3f5
7 changed files with 138 additions and 66 deletions
27
public/assets/scripts/news/like.js
Normal file
27
public/assets/scripts/news/like.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
var Like = function(eventId, csrfToken) {
|
||||
this.eventId = eventId
|
||||
this.csrfToken = csrfToken
|
||||
this.link = $('#event_'+this.eventId+'_actions a#like')
|
||||
}
|
||||
|
||||
Like.prototype.toggleLike = function() {
|
||||
console.log('herp?')
|
||||
var self = this
|
||||
$.post('/event/'+this.eventId+'/toggle_like', {csrf_token: this.csrfToken}, function(res) {
|
||||
console.log(res)
|
||||
|
||||
console.log(self.link.text('butts'))
|
||||
|
||||
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)
|
||||
}
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue