blob: 218053229484630ee8ce45481a6c37a9eee9c2ff (
plain)
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
|
var ProfileView = View.extend({
el: "#profile",
events: {
},
action: "/api/user/",
initialize: function(opt){
this.template = this.$(".template").html()
},
load: function(username){
$.get(this.action + username, this.populate.bind(this))
},
populate: function(user){
$("body").removeClass('loading')
var $table = this.$("table")
this.$("img").attr("src", "/data/profile/" + sanitize(user.username) + ".jpg")
var fields = "username realname phone location".split(" ").map((key) => {
if (! user[key]) return;
var t = this.template.replace(/{{key}}/, sanitize(key))
.replace(/{{value}}/, sanitize(user[key]))
$table.append(t)
})
var fields = "firstseen lastseen".split(" ").map((key) => {
if (! user[key]) return;
var date = verbose_date(user[key])
var t = this.template.replace(/{{key}}/, sanitize(key))
.replace(/{{value}}/, date[0] + ' <small>' + date[1] + '</small>')
$table.append(t)
})
},
})
|