diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-09-06 02:22:28 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-09-06 02:22:28 -0400 |
| commit | 8e25a37aced0399ad13e2c184c618119ec3da16d (patch) | |
| tree | fea00aa951b5468e886e15a26774a7ea7da1d737 /public/assets/js/lib/views | |
| parent | f936c30cbcf9c5e1e5e77929f37a28603ab7c73a (diff) | |
beginning to port string formatting code..
Diffstat (limited to 'public/assets/js/lib/views')
| -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) + }, + +}) |
