normalizing usernames and sanitizing username display

This commit is contained in:
Josh Wolfe 2012-03-03 01:53:41 -07:00
parent 1cb5f47c94
commit 000dd4dde6
2 changed files with 6 additions and 3 deletions

View file

@ -104,10 +104,10 @@ renderChat = ->
users: users
chats: mpd.chats
if mpd.hasUserName()
$("#user-id").html(mpd.getUserName() + ": ")
$("#user-id").text(mpd.getUserName() + ": ")
$("#chat-input").attr('placeholder', "chat")
else
$("#user-id").html("")
$("#user-id").text("")
$("#chat-input").attr('placeholder', "your name")
$chat_tab.find("span").text("Chat#{chat_status_text}")

View file

@ -251,7 +251,10 @@ io.sockets.on 'connection', (socket) ->
value = JSON.parse data.toString()
setDynamicMode value
socket.on 'SetUserName', (data) ->
if (user_name = data.toString()) != ""
user_name = data.toString().trim().split(/\s+/).join(" ")
if user_name != ""
user_name_limit = 20
user_name = user_name.substr(0, user_name_limit)
status.user_names[user_id] = user_name
else
delete status.user_names[user_id]