summaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorsostler <sbostler@gmail.com>2010-01-30 02:11:40 -0500
committersostler <sbostler@gmail.com>2010-01-30 02:11:40 -0500
commit1dcfbf2578d41c5442c21f3f58170049bb2e6f1a (patch)
tree8116136944c6a46258e5ee49b4e0963974bb6dd9 /static
parent65f06c8d8593881f10d767dd0610ca6f63569f56 (diff)
Changed submission URIs from GET to POST
Diffstat (limited to 'static')
-rwxr-xr-xstatic/js/pichat.js100
-rwxr-xr-xstatic/js/register.js2
2 files changed, 50 insertions, 52 deletions
diff --git a/static/js/pichat.js b/static/js/pichat.js
index 79f21b0..0a99f6c 100755
--- a/static/js/pichat.js
+++ b/static/js/pichat.js
@@ -7,22 +7,22 @@ function escapeHtml(txt) {
}
function linkify(text) {
- var URLRegex = /((\b(http\:\/\/|https\:\/\/|ftp\:\/\/)|(www\.))+(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi;
- return text.replace(URLRegex, linkReplace);
+ var URLRegex = /((\b(http\:\/\/|https\:\/\/|ftp\:\/\/)|(www\.))+(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi;
+ return text.replace(URLRegex, linkReplace);
}
function linkReplace(match){
- var PicRegex = /\.(jpg|jpeg|png|gif|bmp)$/i;
- var matchWithoutParams = match.replace(/\?.*$/i, "")
- if (PicRegex.test(matchWithoutParams)){
- return "<a target='_blank' href='" + match + "'><img src='" + match + "'></a>"
- } else {
- return "<a target='_blank' href='" + match + "'>" + match + "</a>"
- }
+ var PicRegex = /\.(jpg|jpeg|png|gif|bmp)$/i;
+ var matchWithoutParams = match.replace(/\?.*$/i, "")
+ if (PicRegex.test(matchWithoutParams)){
+ return "<a target='_blank' href='" + match + "'><img src='" + match + "'></a>"
+ } else {
+ return "<a target='_blank' href='" + match + "'>" + match + "</a>"
+ }
}
function buildMsgContent(content) {
- return linkify(content)
+ return linkify(content)
}
function buildMessageDiv(msg, isLoading) {
@@ -32,35 +32,35 @@ function buildMessageDiv(msg, isLoading) {
return '<div class="msgDiv ' + loadingClass + '" ' + msgId + '>'
+ '<b><a href="/u/' + nick + ' ">' + nick + '</a>: </b>'
+ buildMsgContent(msg.content)
- + '</div>';
+ + '</div>';
}
function buildUserDiv(user) {
if (user.avatar) {
return '<div class="username">'
- + '<a href="/u/' + escapeHtml(user.nick) + '" target="_blank">'
- + '<img src="' + user.avatar + '" width="50" height="50">'
- + escapeHtml(user.nick) + '</a></div>';
+ + '<a href="/u/' + escapeHtml(user.nick) + '" target="_blank">'
+ + '<img src="' + user.avatar + '" width="50" height="50">'
+ + escapeHtml(user.nick) + '</a></div>';
} else {
return '<div class="username">'
- + '<a href="/u/' + escapeHtml(user.nick) + '" target="_blank">'
- + escapeHtml(user.nick) + '</a></div>';
+ + '<a href="/u/' + escapeHtml(user.nick) + '" target="_blank">'
+ + escapeHtml(user.nick) + '</a></div>';
}
}
function buildGrowlDataAndPopDatShit(msg) {
- var nick = escapeHtml(msg.nick);
- nick = '<a href="/u/' + nick + ' " style="color:pink">' + nick + '</a>:'
- var msg = buildMsgContent(msg.content)
- growl(nick, msg)
+ var nick = escapeHtml(msg.nick);
+ nick = '<a href="/u/' + nick + ' " style="color:pink">' + nick + '</a>:'
+ var msg = buildMsgContent(msg.content)
+ growl(nick, msg)
}
function growl(user, msg) {
$.gritter.add({
- // (string | mandatory) the heading of the notification
- title: user,
- // (string | mandatory) the text inside the notification
- text: msg
+ // (string | mandatory) the heading of the notification
+ title: user,
+ // (string | mandatory) the text inside the notification
+ text: msg
});
}
@@ -89,19 +89,19 @@ function submitMessage() {
.removeClass('loading').addClass('loaded');
};
var onError = function(resp, textStatus, errorThrown) {
- div.remove();
+ div.remove();
handleMsgError(resp);
};
-
+
$.ajax({
- type: 'GET',
- timeout: 5000,
- url: '/msg',
- data: { 'room': Room, 'content': content },
- cache: false,
- dataType: 'json',
- success: onSuccess,
- error: onError
+ type: 'POST',
+ timeout: 5000,
+ url: '/msg',
+ data: { 'room': Room, 'content': content },
+ cache: false,
+ dataType: 'json',
+ success: onSuccess,
+ error: onError
});
}
@@ -147,9 +147,9 @@ function setUserList(users) {
function updateUI(msgs, users) {
if (window['growlize'] && msgs && msgs.length > 0) {
- $.map(msgs, buildGrowlDataAndPopDatShit)
+ $.map(msgs, buildGrowlDataAndPopDatShit)
} else if (msgs && msgs.length > 0) {
- addNewMessages(msgs);
+ addNewMessages(msgs);
}
if (users !== null) {
var flattened = users.sort().join(",")
@@ -226,30 +226,27 @@ function initProfile() {
t.html(buildMsgContent(t.text()));
});
- var onSubmit = function(original_element, edit, old) {
- edit = $.trim(edit);
- if (edit == old) { return old };
- // TODO: Prevent entering script tags
- if (original_element == 'avatar' && edit.indexOf("<") != -1) {
- return old;
- }
+ var onSubmit = function(attr, newVal, oldVal) {
+ newVal = $.trim(newVal);
+ if (newVal == oldVal) { return oldVal };
+
$.ajax({
- type: "GET",
+ type: "POST",
timeout: 5000,
url: "/update-profile",
- data: { 'attr': original_element, 'val': edit }
+ data: { 'attr': attr, 'val': newVal }
});
- if (original_element == 'avatar') {
- var s = '<img id="avatarPic" src="' + edit + '" width="150" />';
+ if (attr == 'avatar') {
+ var s = '<img id="avatarPic" src="' + newVal + '" width="150" />';
$('#avatarPic').replaceWith(s);
}
- return escapeHtml(edit);
+ return escapeHtml(newVal);
};
var opt = { 'default_text': 'Enter here!',
'callback': onSubmit,
'field_type': 'text',
- 'callbackShowErrors': false };
+ 'callbackShowErrors': false };
$('#avatar.editable').editInPlace(opt);
@@ -266,13 +263,14 @@ function initLog() {
}
+// TODO
function favoriteImage() {};
-function setupUpload(elementId, roomKey) {
+function setupUpload(elementId, roomKey) {
new AjaxUpload(elementId, {
action: '/upload',
autoSubmit: true,
name: 'image',
- data: { room: roomKey }
+ data: { room: roomKey }
});
} \ No newline at end of file
diff --git a/static/js/register.js b/static/js/register.js
index 89a37fa..d8f9b6a 100755
--- a/static/js/register.js
+++ b/static/js/register.js
@@ -34,7 +34,7 @@ function submitRegistration() {
};
$.ajax({
- type: 'GET',
+ type: 'POST',
timeout: 5000,
url: 'submit-registration',
data: {'nick': nick, 'email': email, 'hash': hash },