/* age_class views_class comments_class size_class files_class */ var ThreadBox = View.extend({ el: ".threads", events: { }, initialize: function(){ this.__super__.initialize.call(this) this.template = this.$(".template").html() }, load: function(comments){ comments.forEach(this.appendComment.bind(this)) }, parse: function(thread){ var t = this.template .replace(/{{id}}/g, thread.id) .replace(/{{username}}/g, thread.username) .replace(/{{title}}/g, thread.title) .replace(/{{age}}/g, get_age(thread.lastmodified) ) .replace(/{{views}}/g, thread.views + " v.") .replace(/{{comments}}/g, thread.comments + " c.") .replace(/{{files}}/g, thread.files + " c.") .replace(/{{size}}/g, get_size(thread.size) ) return t }, prependComment: function(comment){ var $el = $( this.parse(comment) ) this.$hoots.prepend($el) }, appendComment: function(comment){ var $el = $( this.parse(comment) ) this.$hoots.append($el) }, })