diff options
Diffstat (limited to 'public/assets/js/lib/views')
| -rw-r--r-- | public/assets/js/lib/views/index/hootbox.js | 4 | ||||
| -rw-r--r-- | public/assets/js/lib/views/index/index.js | 4 | ||||
| -rw-r--r-- | public/assets/js/lib/views/index/threadbox.js | 37 |
3 files changed, 30 insertions, 15 deletions
diff --git a/public/assets/js/lib/views/index/hootbox.js b/public/assets/js/lib/views/index/hootbox.js index 048c017..15de06b 100644 --- a/public/assets/js/lib/views/index/hootbox.js +++ b/public/assets/js/lib/views/index/hootbox.js @@ -1,4 +1,4 @@ -var HootboxView = FormView.extend({ +var HootBox = FormView.extend({ el: "#hootbox", @@ -17,7 +17,7 @@ var HootboxView = FormView.extend({ parse: function(comment){ var t = this.template.replace(/{{username}}/g, comment.username) - .replace(/{{comment}}/g, comment.comment) + .replace(/{{comment}}/g, comment.comment) return t }, diff --git a/public/assets/js/lib/views/index/index.js b/public/assets/js/lib/views/index/index.js index cb648fa..473df38 100644 --- a/public/assets/js/lib/views/index/index.js +++ b/public/assets/js/lib/views/index/index.js @@ -7,7 +7,8 @@ var IndexView = View.extend({ initialize: function(opt){ // opt.parent = parent - this.hootbox = new HootboxView ({ parent: this }) + this.hootbox = new HootBox ({ parent: this }) + this.threadbox = new ThreadBox ({ parent: this }) this.load() }, @@ -17,6 +18,7 @@ var IndexView = View.extend({ populate: function(data){ this.hootbox.load(data.hootbox) + this.threadbox.load(data.threads) }, success: function(){ 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) }, }) |
