From 699dc9c754b76490091b5f1108a05953f6b8272c Mon Sep 17 00:00:00 2001 From: dumpfmprod Date: Wed, 24 Feb 2010 08:08:31 -0500 Subject: Added filename check --- static/js/pichat.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'static/js/pichat.js') diff --git a/static/js/pichat.js b/static/js/pichat.js index 3137ac4..641662f 100755 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -291,8 +291,8 @@ function favoriteImage() {}; function setupUpload(elementId, roomKey) { var onSubmit = function(file, ext) { - if (!(ext && /^(jpg|png|jpeg|gif)$/i.test(ext))) { - alert('Error: invalid file extension ' + ext); + if (!(ext && /^(jpg|png|jpeg|gif|bmp)$/i.test(ext))) { + alert('SORRY, NOT AN IMAGE DUDE... '); return false; } }; -- cgit v1.2.3-70-g09d2 From c3a98fda15c707f3718e30cf1abb30c1ea042df8 Mon Sep 17 00:00:00 2001 From: Scott Ostler Date: Wed, 24 Feb 2010 09:55:06 -0500 Subject: Added edit-toggle to profile --- static/js/pichat.js | 51 +++++++++++++++++---------- template/profile.st | 99 +++++++++++++++++++++++++++-------------------------- 2 files changed, 83 insertions(+), 67 deletions(-) (limited to 'static/js/pichat.js') diff --git a/static/js/pichat.js b/static/js/pichat.js index 071e8e6..d348d93 100755 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -240,18 +240,12 @@ function initChat() { setTimeout(refresh, 1000); } -function initProfile() { - jQuery(".linkify").each(function() { - var text = jQuery(this).text(); - jQuery(this).html(linkify(text)); - }); - - - $('.logged-dump .content').each(function() { - var t = $(this); - t.html(buildMsgContent(t.text())); - }); +function makePlainText() { + var j = $(this); + j.text(j.text()); +} +function enableProfileEdit() { var onSubmit = function(attr, newVal, oldVal) { newVal = $.trim(newVal); if (newVal == oldVal) { return oldVal }; @@ -273,22 +267,43 @@ function initProfile() { return escapeHtml(newVal); }; + $('#avatar-editing').show(); + var avatarOpts = { 'default_text': 'Enter here!', 'callback': onSubmit, 'field_type': 'text', 'callbackShowErrors': false }; $('#avatar.editable').editInPlace(avatarOpts); + if ($('#upload').length > 0) { + setupUploadAvatar('upload'); + } + var textareaOpts = { 'default_text': 'Enter here!', 'callback': onSubmit, 'field_type': 'textarea', - 'callbackShowErrors': false }; - $('#contact.editable, #bio.editable').editInPlace(textareaOpts); + 'callbackShowErrors': false }; + $('#contact, #bio') + .addClass('editable') + .editInPlace(textareaOpts) + .each(makePlainText); + + var resetPage = function() { location.reload() }; + $('#edit-toggle a').text('--> Done editing <--').click(resetPage); +} - if ($('#upload').length > 0) { - setupUploadAvatar('upload'); - } +function initProfile() { + $(".linkify").each(function() { + var text = jQuery(this).text(); + jQuery(this).html(linkify(text)); + }); + $('#edit-toggle').click(enableProfileEdit); + + $('.logged-dump .content').each(function() { + var t = $(this); + t.html(buildMsgContent(t.text())); + }); }; function initLog() { @@ -331,9 +346,9 @@ function setupUploadAvatar(elementId) { var onComplete = function(file, resp) { $('#spinner').hide(); if (resp == 'INVALID_REQUEST') { - location.href = location.href; + location.reload(); } else if (resp == 'NOT_LOGGED_IN') { - location.href = location.href; + location.reload(); } else if (resp == 'INVALID_IMAGE') { alert("Sorry, dump.fm can't deal with your image. Pick another :("); return; diff --git a/template/profile.st b/template/profile.st index b5d3f38..52b745c 100755 --- a/template/profile.st +++ b/template/profile.st @@ -34,59 +34,60 @@ $dumps:{ d | $logged_dump(dump=d)$ }$ -
- -

$nick$

- - $if(avatar)$ - - $else$ - - $endif$ - - $if(is_home)$ -
$avatar$
- - - $endif$ - - - $if(is_home)$ -

contact info

-
$contact$
- $elseif(contact)$ -

contact info

-
$contact$
- $else$ -

-
- $endif$ - - -
- - $if(is_home)$ -

bio

-
$bio$
- $elseif(bio)$ -

bio

-
$bio$
- $else$ -
- $endif$ - - -
-
-
-
+
+ +

$nick$

+ $if(avatar)$ + + $else$ + + $endif$ + + $if(is_home)$ + + $endif$ + + $endif$ + +

contact info

+ $if(contact)$ +
$contact$
+ $else$ +

+
+ $endif$ +
+ +

bio

+ $if(bio)$ +
$bio$
+ $else$ +
+ $endif$ + + $if(is_home)$ +
+ + $endif$ + + +
+
+
+
$else$

 

 

-

 

 

 

-

 

-

☺✌ Welcome to dump.fm ✌☺

+

 

+

 

+

 

+
+

☺✌ Welcome to dump.fm ✌☺



-- cgit v1.2.3-70-g09d2 From f3b32cefcec1db03b2fb27a7ece322eccf125927 Mon Sep 17 00:00:00 2001 From: Scott Ostler Date: Thu, 25 Feb 2010 20:13:46 -0500 Subject: Split apart enableProfileEdit --- static/js/pichat.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'static/js/pichat.js') diff --git a/static/js/pichat.js b/static/js/pichat.js index d348d93..b847f58 100755 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -61,7 +61,6 @@ function buildMessageDiv(msg, isLoading) { } function buildUserDiv(user) { - console.warn(user); if (user.avatar) { return '
' + '' @@ -166,7 +165,6 @@ function updateUI(msgs, users) { } if (users !== null) { var flattened = flattenUserJson(users); - console.log(flattened); if (!('userlist' in cache) || flattened != cache.userlist) { $("#userList").html($.map(users, buildUserDiv).join('')); } @@ -245,11 +243,11 @@ function makePlainText() { j.text(j.text()); } -function enableProfileEdit() { +function activateProfileEditable() { var onSubmit = function(attr, newVal, oldVal) { newVal = $.trim(newVal); if (newVal == oldVal) { return oldVal }; - + $.ajax({ type: "POST", timeout: 5000, @@ -267,29 +265,30 @@ function enableProfileEdit() { return escapeHtml(newVal); }; - $('#avatar-editing').show(); - - var avatarOpts = { 'default_text': 'Enter here!', + var avatarOpts = { 'default_text': 'Paste URL here!', 'callback': onSubmit, 'field_type': 'text', 'callbackShowErrors': false }; - $('#avatar.editable').editInPlace(avatarOpts); - - if ($('#upload').length > 0) { + if ($('#avatar.editable').length > 0) { + $('#avatar.editable').editInPlace(avatarOpts); setupUploadAvatar('upload'); } var textareaOpts = { 'default_text': 'Enter here!', 'callback': onSubmit, 'field_type': 'textarea', - 'callbackShowErrors': false }; - $('#contact, #bio') - .addClass('editable') + 'callbackShowErrors': false }; + $('#contact.editable, #bio.editable') .editInPlace(textareaOpts) .each(makePlainText); +} +function enableProfileEdit() { + $('#contact, #bio, #avatar').addClass('editable'); + $('#avatar-editing').show(); var resetPage = function() { location.reload() }; $('#edit-toggle a').text('--> Done editing <--').click(resetPage); + activateProfileEditable(); } function initProfile() { @@ -299,6 +298,7 @@ function initProfile() { }); $('#edit-toggle').click(enableProfileEdit); + activateProfileEditable(); $('.logged-dump .content').each(function() { var t = $(this); -- cgit v1.2.3-70-g09d2 From fa8c89b543bb6e23cc7cac5983cb61818a4e3139 Mon Sep 17 00:00:00 2001 From: Scott Ostler Date: Sat, 27 Feb 2010 18:28:06 -0500 Subject: in-progress topics --- src/site.clj | 36 +++++++++++++++++++++++++++++++++--- static/js/pichat.js | 40 ++++++++++++++++++++++++++++++++++++---- template/banner.st | 4 +++- 3 files changed, 72 insertions(+), 8 deletions(-) (limited to 'static/js/pichat.js') diff --git a/src/site.clj b/src/site.clj index cd2b82f..28dadcb 100755 --- a/src/site.clj +++ b/src/site.clj @@ -148,10 +148,11 @@ (map process-user (sort-by #(% :nick) (vals @(room :users))))) -(defn updates [room since] +(defn updates [room since] {"users" (prepare-user-list room) "messages" (map process-message-for-json - (new-messages room since))}) + (new-messages room since)) + "topic" @(room :topic)}) (def *dumps-per-page* 20) @@ -200,7 +201,9 @@ :name (room-db :name) :description (room-db :description) :users (ref {}) - :messages (ref (fetch-messages-by-room (room-db :room_id) false))}) + :messages (ref (fetch-messages-by-room (room-db :room_id) false)) + :topic (ref nil) + }) ;; Templates @@ -357,6 +360,32 @@ :else (do (update-user-db user-id attr val) (resp-success "OK"))))) +;; Topics + +(defn valid-topic? [topic] + topic) + +(defn valid-deadline? [deadline] + deadline) + +(defn set-topic! [room topic deadline maker] + (ref-set (room :topic) + {:topic topic + :deadline deadline + :maker maker})) + +(defn validate-set-topic [session params] + (let [room (@rooms (params :room)) + topic (params :topic) + deadline (params :deadline)] + (cond (not (session :is_admin)) (resp-error "NOT_VIP") + (not (valid-topic? topic)) (resp-error "INVALID_TOPIC") + (not (valid-deadline? deadline)) (resp-error "INVALID_DEADLINE") + (not room) (resp-error "INVALID_ROOM") + :else (do + (dosync (set-topic! room topic deadline (session :nick))) + (resp-success "OK"))))) + ;; Chat (defn validate-room-access [room-key session] @@ -620,6 +649,7 @@ (POST "/msg" (validated-msg session params)) (POST "/submit-registration" (register session params)) (POST "/update-profile" (update-profile session params)) + (POST "/set-topic" (validate-set-topic session params)) (GET "/about_us" (serve-template "about_us" session)) (GET "/goodies" (serve-template "goodies" session)) (GET "/help" (serve-template "help" session)) diff --git a/static/js/pichat.js b/static/js/pichat.js index b847f58..8917e7c 100755 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -1,8 +1,11 @@ var cache = {} -var pendingMessages = {} +var PendingMessages = {} var MaxImagePosts = 40 +// Utils + + function escapeHtml(txt) { if (!txt) { return ""; } else { return $("").text(txt).html(); } @@ -30,6 +33,8 @@ function linkReplace(url){ } } +// Message Handling + var ImageMsgCount = 0 function removeOldMessages(){ // don't count posts that are all text @@ -73,6 +78,8 @@ function buildUserDiv(user) { } } +// Growl + function buildGrowlDataAndPopDatShit(msg) { var nick = escapeHtml(msg.nick); nick = '' + nick + ':' @@ -95,11 +102,13 @@ function handleMsgError(resp) { } } +// Messages + function submitMessage() { var content = $.trim($('#msgInput').val()); $('#msgInput').val(''); if (content == '') { return; } - pendingMessages[content] = true; + PendingMessages[content] = true; var msg = { 'nick': Nick, 'content': content }; var div = addNewMessage(msg, true); @@ -173,14 +182,34 @@ function updateUI(msgs, users) { } function isDuplicateMessage(m) { - if (m.nick == Nick && m.content in pendingMessages) { - delete pendingMessages[m.content]; + if (m.nick == Nick && m.content in PendingMessages) { + delete PendingMessages[m.content]; return true; } else { return false; } } +var CurrentTopic = null; + +function isSameTopic(curTopic, newTopic) { + if (!!curTopic != !!newTopic) { return false; } + else if (!curTopic) { return false; } // => !newTopic also + else { + return curTopic.topic == newTopic.topic && + curTopic.deadline == newTopic.deadline && + curTopic.maker == newTopic.maker; + } +} + +function updateTopic(newTopic) { + if (isSameTopic(CurrentTopic, newTopic)) { return; } + alert('new topic'); + CurrentTopic = newTopic; + $('#topic').text(topic.topic); + +} + function refresh() { var onSuccess = function(json) { try { @@ -192,6 +221,9 @@ function refresh() { if (typeof UnseenMsgCounter !== 'undefined' && !HasFocus) { UnseenMsgCounter += messages.length; } + if (json.topic) { + updateTopic(json.topic); + } } catch(e) { if (IsAdmin && window.console) { console.error(e); diff --git a/template/banner.st b/template/banner.st index 557a0e0..dd7a7b3 100755 --- a/template/banner.st +++ b/template/banner.st @@ -28,7 +28,9 @@
- + +
+ $if(isadmin)$
★ VIP ★ -- cgit v1.2.3-70-g09d2