1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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)
},
})
|