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
|
var LinksView = View.extend({
el: "#links",
events: {
"click a": function(){
},
},
template: $("#link-template").html(),
initialize: function(){
app.socket.on("link", this.prepend.bind(this))
},
show: function(){
$.getJSON("/_irc/links", function(data){
data.forEach(this.append.bind(this))
}.bind(this))
},
render: function(data){
var media = Parser.tokenize(data.url)
var tmpl = this.template.replace(/{{type}}/, media.type)
.replace(/{{text}}/, media.text)
.replace(/{{url}}/, media.url)
.replace(/{{nick}}/, sanitize(data.nick))
return tmpl
},
prepend: function(data){
var tmpl = this.render(data)
this.$el.prepend(tmpl)
},
append: function(data){
var tmpl = this.render(data)
this.$el.append(tmpl)
},
loadMembers: function(){
this.queue.forEach(this.appendMember.bind(this))
},
})
|