diff options
Diffstat (limited to 'public/assets/js/lib/views/profile')
| -rw-r--r-- | public/assets/js/lib/views/profile/profile.js | 57 |
1 files changed, 48 insertions, 9 deletions
diff --git a/public/assets/js/lib/views/profile/profile.js b/public/assets/js/lib/views/profile/profile.js index 1b3e496..077db4e 100644 --- a/public/assets/js/lib/views/profile/profile.js +++ b/public/assets/js/lib/views/profile/profile.js @@ -26,19 +26,58 @@ var ProfileView = View.extend({ $(".edit_profile").hide() } this.$("img").attr("src", profile_image(username)) - var fields = "username realname phone location".split(" ").map((key) => { + var fields = [ + ["username", "Username"], + ["realname", "Real Name"], + ["location", "Location"], + ["phone", "Phone"], + ].map(pair => { + var key = pair[0], label = pair[1] if (! user[key]) return; - var t = this.template.replace(/{{key}}/, sanitize(key)) - .replace(/{{value}}/, sanitize(user[key])) - $table.append(t) + return [key, sanitize(user[key])] }) - var fields = "firstseen lastseen".split(" ").map((key) => { + + if (user.email) { + fields.push([ + 'Email', + '<a href="mailto:' + sanitize(user.email) + '">' + sanitize(user.email) + '</a>' + ]) + } + if (user.twitter) { + if (user.twitter.match(/^http/)) { + var partz = user.twitter.split('/') + if (partz.length > 2) { + var handle = sanitize(partz[3]) + fields.push([ + 'Twitter', + '<a href="https://twitter.com/' + handle + '">@' + handle + '</a>' + ]) + } + } else { + var handle = sanitize(user.twitter) + fields.push([ + 'Twitter', + '<a href="https://twitter.com/' + handle + '">@' + handle + '</a>' + ]) + } + } + if (user.website) { + var websit = sanitize(user.website) + fields.push([ + 'Website', + '<a href="https://twitter.com/' + website + '">' + website + '</a>' + ]) + } + + fields = [ + ["firstseen", "First Seen"], + ["lastseen", "Last Seen"], + ].split(" ").map((key) => { + var key = pair[0], label = pair[1] 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) - }) + return [key, date[0] + ' <small>' + date[1] + '</small>'] + }).concat(fields) var t = this.template.replace(/{{key}}/, " ") .replace(/{{value}}/, '<a href="/mail/compose/' + username + '">send ' + username + ' a message</a>') |
