summaryrefslogtreecommitdiff
path: root/public/assets/js/lib/views
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-09-06 02:22:28 -0400
committerJules Laplace <jules@okfoc.us>2015-09-06 02:22:28 -0400
commit8e25a37aced0399ad13e2c184c618119ec3da16d (patch)
treefea00aa951b5468e886e15a26774a7ea7da1d737 /public/assets/js/lib/views
parentf936c30cbcf9c5e1e5e77929f37a28603ab7c73a (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.js47
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)
+ },
+
+})