From 136fb22a14391e781c7cd1fed624af8fbe638f1f Mon Sep 17 00:00:00 2001 From: Scott Ostler Date: Thu, 9 Sep 2010 21:42:19 -0400 Subject: Add image-only toggle --- static/js/pichat.js | 78 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 26 deletions(-) (limited to 'static') diff --git a/static/js/pichat.js b/static/js/pichat.js index 09c7dd6..e32ec3b 100644 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -1,10 +1,9 @@ -/*function deleteCookie(name) { - // Only deletes non-wildcard cookies - document.cookie = name + "=;expires=Thu, 01-Jan-1970 00:00:01 GMT"; -} -deleteCookie('compojure-session'); -deleteCookie('login-token'); -*/ +// http://plugins.jquery.com/files/jquery.cookie.js.txt +jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;} +var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;} +expires='; expires='+date.toUTCString();} +var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i") return content.substr(6,content.length - 13) - else return linkify(escapeHtml(content)); + if (content.substr(0,6) == "") + return content.substr(6,content.length - 13) + else return linkify(escapeHtml(content)); } // todo: // isLoading doesn't get passed the right thing by $.map in addMessages function buildMessageDiv(msg, isLoading) { var nick = escapeHtml(msg.nick); -// if (nick == '' && Nick != '') return; - removeOldMessages() + removeOldMessages(); + + var builtContent = buildMsgContent(msg.content); + var msgId = ('msg_id' in msg) ? 'id="message-' + msg.msg_id + '"' : ''; var loadingClass = isLoading ? ' loading' : ''; var containsImageClass = LastMsgContainsImage ? ' contains-image' : ''; - return '
' + var displayStyle = (TextEnabled || LastMsgContainsImage) ? '' : ' style="display: none"'; + + return '
' + '' + nick + '' + ' ' + '' - + '' + buildMsgContent(msg.content) + '' + + '' + builtContent + '' + '
'; } @@ -521,8 +547,6 @@ function sendClicked(){ typeof Nick !== 'undefined' ? Nick : 'anon'); } submitMessage() - - } function paletteClicked(){ @@ -531,8 +555,6 @@ function paletteClicked(){ typeof Nick !== 'undefined' ? Nick : 'anon'); } paletteToggle() - - } @@ -544,6 +566,10 @@ function initChat() { var content = dump.find(".content") MessageContentCache[dump.attr("id").substr(8)] = content.text() content.html(buildMsgContent(content.text())); + if (!TextEnabled && !dump.hasClass('contains-image')) + dump.hide(); + else + dump.show(); }); $('#msgInput').keyup(ifEnter(submitMessage)); -- cgit v1.2.3-70-g09d2