summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/main.js16
-rw-r--r--src/server/rz_api.py15
2 files changed, 14 insertions, 17 deletions
diff --git a/src/client/main.js b/src/client/main.js
index ebf54530..0b728f95 100644
--- a/src/client/main.js
+++ b/src/client/main.js
@@ -8,20 +8,6 @@ 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;
@@ -32,8 +18,6 @@ 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);
diff --git a/src/server/rz_api.py b/src/server/rz_api.py
index 98d46136..8b7ac825 100644
--- a/src/server/rz_api.py
+++ b/src/server/rz_api.py
@@ -150,10 +150,23 @@ def monitor__server_info():
"time: " + dt.strftime("%H:%M:%S") + "<br>" + \
"</p></body></html>"
+def username_initials(username):
+ """
+ return two letter (always) initials of username.
+ we do it here rather then on the client side to avoid rendering twice, once
+ 'annonymous' and later the real name, because of loading delays
+ """
+ words = username.split(' ')
+ first_initial = words[0][0] if len(words) >= 1 and len(words[0]) >= 1 else ' '
+ second_initial = (words[1][0] if len(words) >= 2 and len(words[1]) >= 1 else
+ (words[0][1] if len(words) >= 1 and len(words[0]) > 1 else '_'))
+ return (first_initial + second_initial).upper()
+
def index():
session_username = session.get('username')
username = escape(session_username if session_username != None else "Anonymous Stranger")
- return render_template('index.html', username=username)
+ profileinitials = username_initials(username)
+ return render_template('index.html', username=username, profileinitials=profileinitials)
def login():