mirror of
https://github.com/neocities/neocities.git
synced 2025-07-20 09:36:00 +02:00
more work on comments for events
This commit is contained in:
parent
eba4a6e3f5
commit
b96730b83f
17 changed files with 2298 additions and 43 deletions
16
public/assets/scripts/news/comment.js
Normal file
16
public/assets/scripts/news/comment.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
var Comment = function(eventId, csrfToken) {
|
||||
this.eventId = eventId
|
||||
this.csrfToken = csrfToken
|
||||
}
|
||||
|
||||
Comment.prototype.create = function(form) {
|
||||
var self = this
|
||||
var form = $(form)
|
||||
var comment = form.find('[name="comment"]').val()
|
||||
form.remove()
|
||||
|
||||
$.post('/event/'+this.eventId+'/comment', {csrf_token: this.csrfToken, comment: comment}, function(res) {
|
||||
console.log(res)
|
||||
})
|
||||
|
||||
}
|
|
@ -5,13 +5,8 @@ var Like = function(eventId, csrfToken) {
|
|||
}
|
||||
|
||||
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+')')
|
||||
|
||||
|
|
13
public/assets/scripts/news/template.js
Normal file
13
public/assets/scripts/news/template.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
var Template = {
|
||||
template: function(templateString, data) {
|
||||
var data = data || {}
|
||||
return _.template(templateString, data, {interpolate: /\{\{(.+?)\}\}/g})
|
||||
},
|
||||
|
||||
renderComment: function(event_id) {
|
||||
var event = $('#event_'+event_id+'_actions')
|
||||
var rendered = this.template($('#comment-template').html(), {event_id: event_id})
|
||||
event.find('a#reply').css('display', 'none')
|
||||
event.append(rendered)
|
||||
}
|
||||
}
|
6
public/assets/scripts/underscore-min.js
vendored
Normal file
6
public/assets/scripts/underscore-min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue