diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-12-23 01:03:06 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-12-23 01:03:06 +0100 |
| commit | dbb2d747323293e6ded68e5fd037ca3e01a7c6c2 (patch) | |
| tree | b0a8e04229101c069db565233151cddaba14324e /public/assets/js/lib | |
| parent | fe7ee50baa8f96836ecefa2088d129b90705125c (diff) | |
fix profile
Diffstat (limited to 'public/assets/js/lib')
| -rw-r--r-- | public/assets/js/lib/views/profile/profile.js | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/public/assets/js/lib/views/profile/profile.js b/public/assets/js/lib/views/profile/profile.js index 077db4e..2254bd5 100644 --- a/public/assets/js/lib/views/profile/profile.js +++ b/public/assets/js/lib/views/profile/profile.js @@ -1,20 +1,20 @@ 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") @@ -34,9 +34,9 @@ var ProfileView = View.extend({ ].map(pair => { var key = pair[0], label = pair[1] if (! user[key]) return; - return [key, sanitize(user[key])] + return [label, sanitize(user[key])] }) - + if (user.email) { fields.push([ 'Email', @@ -62,26 +62,34 @@ var ProfileView = View.extend({ } } if (user.website) { - var websit = sanitize(user.website) + var website = sanitize(user.website) fields.push([ 'Website', - '<a href="https://twitter.com/' + website + '">' + website + '</a>' + '<a href="' + sanitize(website) + '">' + sanitize(website) + '</a>' ]) } - - fields = [ + + fields = fields.concat([ ["firstseen", "First Seen"], ["lastseen", "Last Seen"], - ].split(" ").map((key) => { + ].map((pair) => { var key = pair[0], label = pair[1] if (! user[key]) return; var date = verbose_date(user[key]) - return [key, date[0] + ' <small>' + date[1] + '</small>'] - }).concat(fields) + return [label, date[0] + ' <small>' + date[1] + '</small>'] + })) - var t = this.template.replace(/{{key}}/, " ") - .replace(/{{value}}/, '<a href="/mail/compose/' + username + '">send ' + username + ' a message</a>') - $table.append(t) + fields.push([ + ' ', + '<a href="/mail/compose/' + username + '">send ' + username + ' a message</a>' + ]) + + var rows = fields.filter(pair => !!pair).map(pair => { + var t = this.template.replace(/{{label}}/, pair[0]) + .replace(/{{value}}/, pair[1]) + return t + }) + $table.append(rows.join("")) }, }) |
