summaryrefslogtreecommitdiff
path: root/static/js
diff options
context:
space:
mode:
authordumpfmprod <dumpfmprod@ubuntu.(none)>2010-02-24 08:11:03 -0500
committerdumpfmprod <dumpfmprod@ubuntu.(none)>2010-02-24 08:11:03 -0500
commit7b9c7f610974c56f13e05387c1f5ff9d7ca16ad0 (patch)
tree4086d35a5a4fa49808ec3a9f5fb8b0d9109ac93c /static/js
parent0f8f1b234276514560e6df3bb6f6bac56fa9807d (diff)
parent49ef1a688025d9183452fe5f1dccf7802d64dc62 (diff)
resolved merge
Diffstat (limited to 'static/js')
-rwxr-xr-xstatic/js/home.js8
-rwxr-xr-xstatic/js/pichat.js51
2 files changed, 49 insertions, 10 deletions
diff --git a/static/js/home.js b/static/js/home.js
index 107486c..e9be833 100755
--- a/static/js/home.js
+++ b/static/js/home.js
@@ -5,7 +5,6 @@ function ifEnter(fn) {
}
function initLoginForm() {
-
var nick = "#nickInput", nickFiller = "username"
var pass = "#passwordInput", passLabel = "#passwordInputLabel", passFiller = "password"
var submit = "#signin-submit"
@@ -145,17 +144,16 @@ function initBigHand(id){
}
function login() {
- //$('#passwordInput, #loginSubmit').blur();
var nick = $('#nickInput').val();
var password = $('#passwordInput').val();
var rememberme = $('#remembermeInput').attr('checked') ? 'yes' : '';
var hash = hex_sha1(nick + '$' + password + '$dumpfm');
var onSuccess = function(json) {
+ location.href = location.href;
if (typeof pageTracker !== 'undefined') {
- pageTracker._setCustomVar(1, "logged-in", nick, 1);
- }
- location.href = "/chat";
+ pageTracker._setCustomVar(1, "logged-in", nick);
+ }
};
var onError = function(resp, textStatus, errorThrown) {
diff --git a/static/js/pichat.js b/static/js/pichat.js
index 641662f..071e8e6 100755
--- a/static/js/pichat.js
+++ b/static/js/pichat.js
@@ -61,6 +61,7 @@ function buildMessageDiv(msg, isLoading) {
}
function buildUserDiv(user) {
+ console.warn(user);
if (user.avatar) {
return '<div class="username">'
+ '<a href="/u/' + escapeHtml(user.nick) + '" target="_blank">'
@@ -149,6 +150,14 @@ function setUserList(users) {
$("#userList").html($.map(users, buildUserDiv).join(''));
}
+function flattenUserJson(users) {
+ var s = "";
+ $.map(users.sort(), function(user) {
+ s += user.nick + user.avatar;
+ });
+ return s;
+}
+
function updateUI(msgs, users) {
if (window['growlize'] && msgs && msgs.length > 0) {
$.map(msgs, buildGrowlDataAndPopDatShit)
@@ -156,7 +165,8 @@ function updateUI(msgs, users) {
addNewMessages(msgs);
}
if (users !== null) {
- var flattened = users.sort().join(",")
+ var flattened = flattenUserJson(users);
+ console.log(flattened);
if (!('userlist' in cache) || flattened != cache.userlist) {
$("#userList").html($.map(users, buildUserDiv).join(''));
}
@@ -231,7 +241,6 @@ function initChat() {
}
function initProfile() {
-
jQuery(".linkify").each(function() {
var text = jQuery(this).text();
jQuery(this).html(linkify(text));
@@ -241,7 +250,7 @@ function initProfile() {
$('.logged-dump .content').each(function() {
var t = $(this);
t.html(buildMsgContent(t.text()));
- });
+ });
var onSubmit = function(attr, newVal, oldVal) {
newVal = $.trim(newVal);
@@ -276,6 +285,10 @@ function initProfile() {
'callbackShowErrors': false };
$('#contact.editable, #bio.editable').editInPlace(textareaOpts);
+ if ($('#upload').length > 0) {
+ setupUploadAvatar('upload');
+ }
+
};
function initLog() {
@@ -283,7 +296,6 @@ function initLog() {
var t = $(this);
t.html(buildMsgContent(t.text()));
});
-
}
// TODO
@@ -302,7 +314,7 @@ function setupUpload(elementId, roomKey) {
}
}
new AjaxUpload(elementId, {
- action: '/upload',
+ action: '/upload/message',
autoSubmit: true,
name: 'image',
data: { room: roomKey },
@@ -311,6 +323,35 @@ function setupUpload(elementId, roomKey) {
});
}
+function setupUploadAvatar(elementId) {
+ // NOTE: AjaxUpload responses aren't converted from JSON.
+ var onSubmit = function(file, error) {
+ $('#spinner').show();
+ };
+ var onComplete = function(file, resp) {
+ $('#spinner').hide();
+ if (resp == 'INVALID_REQUEST') {
+ location.href = location.href;
+ } else if (resp == 'NOT_LOGGED_IN') {
+ location.href = location.href;
+ } else if (resp == 'INVALID_IMAGE') {
+ alert("Sorry, dump.fm can't deal with your image. Pick another :(");
+ return;
+ }
+ var s = '<img id="avatarPic" src="' + resp + '" width="150" />';
+ $('#avatarPic').replaceWith(s).show();
+ $('#avatar').text(resp);
+ };
+ new AjaxUpload(elementId, {
+ action: '/upload/avatar',
+ autoSubmit: true,
+ name: 'image',
+ onSubmit: onSubmit,
+ onComplete: onComplete
+ });
+}
+
+
// scrolling stuff
// this code keeps the div scrolled to the bottom, but will also let the user scroll up, without jumping down