diff options
Diffstat (limited to 'public/assets/js/lib/views/index/threadbox.js')
| -rw-r--r-- | public/assets/js/lib/views/index/threadbox.js | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/public/assets/js/lib/views/index/threadbox.js b/public/assets/js/lib/views/index/threadbox.js index 951b025..defeaff 100644 --- a/public/assets/js/lib/views/index/threadbox.js +++ b/public/assets/js/lib/views/index/threadbox.js @@ -17,31 +17,44 @@ var ThreadBox = View.extend({ this.template = this.$(".template").html() }, - load: function(comments){ - comments.forEach(this.appendComment.bind(this)) + load: function(threads){ + threads.forEach(this.appendThread.bind(this)) }, parse: function(thread){ + console.log(thread) + var views = hush_views(thread.viewed) + var size = thread.file_count == 0 ? ["hidden", 0] : hush_size(thread.size) + var comments = hush_null(thread.comment_count, "c") + var files = hush_null(thread.file_count, "f") + var dot = privacy_dot(thread.private) + var t = this.template .replace(/{{id}}/g, thread.id) .replace(/{{username}}/g, thread.username) + .replace(/{{privacy_dot}}/g, dot) .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) ) + .replace(/{{age_class}}/g, carbon_date(thread.lastmodified) ) + .replace(/{{views}}/g, views[1]) + .replace(/{{comments}}/g, comments[1]) + .replace(/{{files}}/g, files[1]) + .replace(/{{size}}/g, size[1] ) + .replace(/{{views_class}}/g, views[0]) + .replace(/{{comments_class}}/g, comments[0]) + .replace(/{{files_class}}/g, files[0]) + .replace(/{{size_class}}/g, size[0] ) return t }, - prependComment: function(comment){ - var $el = $( this.parse(comment) ) - this.$hoots.prepend($el) + prependThread: function(thread){ + var $row = $( this.parse(thread) ) + this.$el.prepend($row) }, - appendComment: function(comment){ - var $el = $( this.parse(comment) ) - this.$hoots.append($el) + appendThread: function(thread){ + var $row = $( this.parse(thread) ) + this.$el.append($row) }, }) |
