From 99167ae61a6f8331de84874d183b7d3882cc30ac Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Sun, 28 Dec 2014 12:59:51 +0200 Subject: Fixes #217 - username initials displayed in upper right corner blue circle Also fixes name when none set (i.e. development mode). --- src/client/main.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/client') diff --git a/src/client/main.js b/src/client/main.js index 863d0440..47c9de1d 100644 --- a/src/client/main.js +++ b/src/client/main.js @@ -8,6 +8,20 @@ function(textanalysis_ui, textanalysis, buttons, history, drag_n_drop, obj.size = Math.max(obj.savesize, obj.value.length); } + function get_user_initials() { + var words = logged_username.split(' '), + first_initial = words.length >= 1 && words[0].length >= 1 ? words[0][0] : ' ', + second_initial = words.length >= 2 && words[1].length >= 1 ? words[1][0] : (words.length >= 1 && words[0].length > 1 ? words[0][1] : '_'); + + return (first_initial + second_initial).toUpperCase(); + } + + function update_username_ui() { + // logged_username is defined in the body via a template server set variable + $('.profile-initials').html(get_user_initials()); + $('#user_id').html(logged_username); + } + this.main = function() { var json, search = $('#search'), @@ -23,6 +37,8 @@ function(textanalysis_ui, textanalysis, buttons, history, drag_n_drop, textanalysis_ui.main(); + update_username_ui(); + json = util.getParameterByName('json'); if (json) { rz_core.load_from_json(json); -- cgit v1.3.1