From 704efb06cd424de7411f198bc4c6ce6b99a9dcbe Mon Sep 17 00:00:00 2001 From: sostler Date: Fri, 18 Dec 2009 21:56:51 -0500 Subject: Checkin before leaving --- static/pichat.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'static/pichat.js') diff --git a/static/pichat.js b/static/pichat.js index 826bcba..d489bba 100755 --- a/static/pichat.js +++ b/static/pichat.js @@ -15,7 +15,8 @@ function escapeHtml(txt) { } function buildUserDiv(user) { - return '
' + escapeHtml(user) + '
'; + var nick = escapeHtml(user); + return '
' + nick + '
'; } // http://stackoverflow.com/questions/37684/replace-url-with-html-links-javascript @@ -29,6 +30,7 @@ var URLRegex = /((http\:\/\/|https\:\/\/|ftp\:\/\/)|(www\.))+(\w+:{0,1}\w*@)?(\S var PicRegex = /\.(jpg|jpeg|png|gif|bmp)$/i; function buildMsgContent(content) { + content = $.trim(content); var match = URLRegex.exec(content) if (match && PicRegex.test(match[0])) { return '' @@ -39,7 +41,8 @@ function buildMsgContent(content) { } function buildMessageDiv(msg) { - return '
' + escapeHtml(msg.nick) + ': ' + var nick = escapeHtml(msg.nick); + return '
' + nick + ': ' + buildMsgContent(msg.content) + '
'; } @@ -150,6 +153,7 @@ function initProfile() { }); var onSubmit = function(original_element, edit, old) { + edit = $.trim(edit); if (edit == old) { return old }; // MAJOR TODO: Prevent entering script tags if (original_element == 'avatar' && edit.indexOf("<") != -1) { @@ -161,7 +165,7 @@ function initProfile() { url: "/update-profile", data: { 'attr': original_element, 'val': edit } }); - if (original_element == 'avatar') { + if (original_element == 'avatar') { var s = ''; $('#avatarPic').replaceWith(s); } -- cgit v1.2.3-70-g09d2