summaryrefslogtreecommitdiff
path: root/static/pichat.js
diff options
context:
space:
mode:
authorScott Ostler <sostler@ubuntu.(none)>2009-12-21 17:21:34 -0500
committerScott Ostler <sostler@ubuntu.(none)>2009-12-21 17:21:34 -0500
commit7a1af322fa38e1205613bc4767de7cc59b74c69c (patch)
tree1c4cb7dc700d582552668b5dbd5be8c151052e32 /static/pichat.js
parent2e3b548249968e8e83ef5f78d81e82064c8e6420 (diff)
parent704efb06cd424de7411f198bc4c6ce6b99a9dcbe (diff)
Fixed
Diffstat (limited to 'static/pichat.js')
-rwxr-xr-xstatic/pichat.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/static/pichat.js b/static/pichat.js
index 14af670..b12041c 100755
--- a/static/pichat.js
+++ b/static/pichat.js
@@ -15,7 +15,12 @@ function escapeHtml(txt) {
}
function buildUserDiv(user) {
+<<<<<<< HEAD:static/pichat.js
return '<div class="username"><img src="/static/cat.jpeg" width="50" height="50">' + escapeHtml(user) + '</div>';
+=======
+ var nick = escapeHtml(user);
+ return '<div><a href="/u/' + nick + '">' + nick + '</a></div>';
+>>>>>>> 704efb06cd424de7411f198bc4c6ce6b99a9dcbe:static/pichat.js
}
// http://stackoverflow.com/questions/37684/replace-url-with-html-links-javascript
@@ -29,6 +34,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 +45,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 +157,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 +169,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);
}