diff options
Diffstat (limited to 'public/assets/js/lib/views/index/threadbox.js')
| -rw-r--r-- | public/assets/js/lib/views/index/threadbox.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/public/assets/js/lib/views/index/threadbox.js b/public/assets/js/lib/views/index/threadbox.js new file mode 100644 index 0000000..951b025 --- /dev/null +++ b/public/assets/js/lib/views/index/threadbox.js @@ -0,0 +1,47 @@ +/* +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) + }, + +}) |
