diff options
| author | Scott Ostler <scottbot9000@gmail.com> | 2010-06-22 01:27:47 -0400 |
|---|---|---|
| committer | Scott Ostler <scottbot9000@gmail.com> | 2010-06-22 01:27:47 -0400 |
| commit | 662ab0a287412d80752e0c3c41ea3766345a5bee (patch) | |
| tree | 46a68eb27f3b1fe828139aa62ecea4970ec4d575 /static/js/pichat.js | |
| parent | e3de12ddc86a3becd3d8d0fc195115c1e7847097 (diff) | |
add avatar upload limits
Diffstat (limited to 'static/js/pichat.js')
| -rw-r--r-- | static/js/pichat.js | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/static/js/pichat.js b/static/js/pichat.js index 3981d7e..1f64c20 100644 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -705,7 +705,8 @@ function setupUploadAvatar(elementId) { }; var onComplete = function(file, resp) { $('#spinner').hide(); - var r = $.trim(resp); + var r = $.trim(resp); + if (r == 'INVALID_REQUEST') { location.reload(); } else if (r == 'NOT_LOGGED_IN') { @@ -714,13 +715,21 @@ function setupUploadAvatar(elementId) { alert("Sorry, dump.fm can't deal with your image. Pick another :("); return; } else if (r.match(/FILE_TOO_BIG/)) { - var maxSize = r.split(" ")[1] / 1024; - alert("Sorry. Your file is just too fucking big. " - + maxSize + "KB or less please."); - return; - } - var s = '<img id="dashavatarPic" src="' + r + ' />'; - $('#dashavatarPic').replaceWith(s).show(); + var maxSize = r.split(" ")[1] / 1024; + alert("Sorry. Your avatar is just too fucking big. " + + maxSize + "KB or less please."); + return; + } else if (r.match(/INVALID_RESOLUTION/)) { + var maxWidth = r.split(" ")[1]; + var maxHeight = r.split(" ")[2]; + alert("Sorry, the maximum avatar resolution is " + + maxWidth + "x" + maxHeight); + return; + } + + var s = '<img id="dashavatarPic" src="' + r + '" />'; + console.log('setting avatar img to ' + s); + $('#dashavatar').html(s).show(); }; new AjaxUpload(elementId, { action: '/upload/avatar', |
