diff options
| author | Scott Ostler <sostler@deathmachine.local> | 2010-03-11 08:01:05 -0500 |
|---|---|---|
| committer | Scott Ostler <sostler@deathmachine.local> | 2010-03-11 08:01:05 -0500 |
| commit | 3d83db95469600000f4fbc1337bfc6aac9efd9a4 (patch) | |
| tree | 05ba06023a71bc27e04cbb05280f4c96b63bef9d /static/js/pichat.js | |
| parent | e8142b2742433ea26f6434e5933cddea8b4711c2 (diff) | |
Added upload limits
Diffstat (limited to 'static/js/pichat.js')
| -rwxr-xr-x | static/js/pichat.js | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/static/js/pichat.js b/static/js/pichat.js index fd33729..7314ff8 100755 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -215,12 +215,25 @@ function isSameTopic(curTopic, newTopic) { } } +function displayNewTopic(topic) { + $('#topic').empty() + .append(topic.topic) + .append(topic.deadline) + .append(topic.maker).show(); +} + +function hideTopic(topic) { + $('#topic').empty().hide(); +} + function updateTopic(newTopic) { + if ($('#topic').length == 0) { return; } if (isSameTopic(CurrentTopic, newTopic)) { return; } - alert('new topic'); - CurrentTopic = newTopic; - $('#topic').text(topic.topic); - + if (newTopic) { + displayNewTopic(newTopic); + } else { + hideTopic(); + } } function refresh() { @@ -366,13 +379,29 @@ function favoriteImage() {}; function setupUpload(elementId, roomKey) { var onSubmit = function(file, ext) { if (!(ext && /^(jpg|png|jpeg|gif|bmp)$/i.test(ext))) { - alert('SORRY, NOT AN IMAGE DUDE... '); - return false; + alert('SORRY, NOT AN IMAGE DUDE... '); + return false; } }; var onComplete = function(file, response) { - if (typeof pageTracker !== 'undefined') { - pageTracker._trackEvent('Message', 'Upload', typeof Room !== 'undefined' ? Room : 'UnknownRoom'); + if (response.match(/FILE_TOO_BIG/)) { + var maxSize = response.split(" ")[1] / 1024; + alert("Sorry. Your file is just too fucking big. " + + maxSize + "KB or less please."); + return; + } else if (response.match(/FILE_NOT_IMAGE/)) { + alert("What did you upload? Doesn't seem like an image. Sorry."); + return; + } else if (response.match(/INVALID_RESOLUTION/)) { + var maxWidth = response.split(" ")[1]; + var maxHeight = response.split(" ")[2]; + alert("Sorry, the maximum image resolution is " + + maxWidth + "x" + maxHeight); + return; + } + if (typeof pageTracker !== 'undefined') { + var room = typeof Room !== 'undefined' ? Room : 'UnknownRoom' + pageTracker._trackEvent('Message', 'Upload', room); } } new AjaxUpload(elementId, { @@ -380,7 +409,7 @@ function setupUpload(elementId, roomKey) { autoSubmit: true, name: 'image', data: { room: roomKey }, - onSubmit: onSubmit, + onSubmit: onSubmit, onComplete: onComplete }); } |
