diff options
| author | sostler <sbostler@gmail.com> | 2009-12-18 21:56:51 -0500 |
|---|---|---|
| committer | sostler <sbostler@gmail.com> | 2009-12-18 21:56:51 -0500 |
| commit | 704efb06cd424de7411f198bc4c6ce6b99a9dcbe (patch) | |
| tree | 076c19e5c97264948f4d94f32b6869c5dd396f60 /static/pichat.js | |
| parent | 5a8312ca25868679df1acb3b3fc208482460ee0e (diff) | |
Checkin before leaving
Diffstat (limited to 'static/pichat.js')
| -rwxr-xr-x | static/pichat.js | 10 |
1 files changed, 7 insertions, 3 deletions
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 '<div>' + escapeHtml(user) + '</div>'; + var nick = escapeHtml(user); + return '<div><a href="/u/' + nick + '">' + nick + '</a></div>'; } // 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 '<a href="' + match[0] + '" target="_blank">' @@ -39,7 +41,8 @@ function buildMsgContent(content) { } function buildMessageDiv(msg) { - return '<div class="msgDiv"><b>' + escapeHtml(msg.nick) + ': </b>' + var nick = escapeHtml(msg.nick); + return '<div class="msgDiv"><b><a href="/u/' + nick + ' ">' + nick + '</a>: </b>' + buildMsgContent(msg.content) + '</div>'; } @@ -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 = '<img id="avatarPic" src="' + edit + '" width="150" />'; $('#avatarPic').replaceWith(s); } |
