From dbb2d747323293e6ded68e5fd037ca3e01a7c6c2 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 23 Dec 2017 01:03:06 +0100 Subject: fix profile --- public/assets/js/lib/views/profile/profile.js | 42 ++++++++++++++++----------- public/assets/js/util/format.js | 2 +- 2 files changed, 26 insertions(+), 18 deletions(-) (limited to 'public/assets') 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', - '' + website + '' + '' + sanitize(website) + '' ]) } - - 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] + ' ' + date[1] + ''] - }).concat(fields) + return [label, date[0] + ' ' + date[1] + ''] + })) - var t = this.template.replace(/{{key}}/, " ") - .replace(/{{value}}/, 'send ' + username + ' a message') - $table.append(t) + fields.push([ + ' ', + 'send ' + username + ' a message' + ]) + + 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("")) }, }) diff --git a/public/assets/js/util/format.js b/public/assets/js/util/format.js index 36a3d37..c765052 100644 --- a/public/assets/js/util/format.js +++ b/public/assets/js/util/format.js @@ -230,7 +230,7 @@ function make_link(file){ return file.filename } function profile_image(username){ - return "//s3.amazonaws.com/i.asdf.us/bucky/data/profile/" + username + ".jpg" + return "//s3.amazonaws.com/i.asdf.us/bucky/profile/" + username + ".jpg" } function make_thumb(file){ if (file.storage) { -- cgit v1.2.3-70-g09d2