diff options
Diffstat (limited to 'static/js/pichat.js')
| -rw-r--r--[-rwxr-xr-x] | static/js/pichat.js | 191 |
1 files changed, 154 insertions, 37 deletions
diff --git a/static/js/pichat.js b/static/js/pichat.js index a13b572..2cb577f 100755..100644 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -379,8 +379,55 @@ function initLog() { var t = $(this); t.html(buildMsgContent(t.text())); }); + initAnimThumb(); } +// jesus this logic is ugly +function initAnimThumb(){ + $(".buttons .thumb").bind('mouseover mouseout', + function(e) { + var favorited = $(this).hasClass("favorite") ? true : false; + if (e.type == "mouseover") { + if (favorited) { + $(this).attr("src", "/static/thumbup.gif"); +/* $(this).stop().animate({ + "width": "14px", + "height": "15px", + "marginLeft": "0px", + "marginTop": "0px" + }, 'fast'); */ + } else { + $(this).attr("src", "/static/thumbup.colored.4x.gif"); + $(this).stop().animate({ + "width": "56px", + "height": "60px", + "marginLeft": "-44px", + "marginTop": "-27px" + }, 'fast'); + } + } else { // mouseout + if (favorited) { + $(this).attr("src", "/static/thumbup.colored.gif"); + $(this).stop().animate({ + "width": "14px", + "height": "15px", + "marginLeft": "0px", + "marginTop": "0px" + }, 'fast'); + } else { + $(this).attr("src", "/static/thumbup.gif"); + $(this).stop().animate({ + "width": "14px", + "height": "15px", + "marginLeft": "0px", + "marginTop": "0px" + }, 'fast'); + } + } + }) +} + + // TODO function favoriteImage() {}; @@ -571,41 +618,111 @@ function initBigHand(id){ } Share = { - "getMessage": function(button){ - var message = $(button).parents(".logged-dump") - var id = message.attr("id").substr(8) // cut "message-001" to "001" - var nick = message.attr("nick") // cut "/u/timb" to "timb" - var link = "http://dump.fm/p/" + nick + "/" + id - var content = message.find(".linkify") - if (!content.length) content = message.find(".content") - var rawContent = content.html() - var img = content.find("img").attr("src") - var via = "via " + nick + " on dump.fm" - return {"nick": nick, "id": id, "link": encodeURIComponent(link), - "content": content, "img": encodeURIComponent(img), - "via": encodeURIComponent(via)} - }, - "openLink": function(url){ - window.open(url, "_blank") - }, - "facebook": function(button){ - var message = Share.getMessage(button) - var url = "http://www.facebook.com/share.php?u=" + message.img + "&t=" + message.via - Share.openLink(url) - }, - "tumblr": function(button){ - var message = Share.getMessage(button) - var url = "http://www.tumblr.com/share?v=3&u=" + message.img + "&t=" + message.via - Share.openLink(url) - }, - "twitter": function(button){ - var message = Share.getMessage(button) - var url = "http://twitter.com/home?status=" + message.img + encodeURIComponent(" ") + message.via - Share.openLink(url) - }, - "delicious": function(button){ - var message = Share.getMessage(button) - var url = "http://delicious.com/save?url=" + message.img + "&title=" + message.img + "¬es=" + message.via - Share.openLink(url) +<<<<<<< HEAD + "getMessage": function(button){ + var message = $(button).parents(".logged-dump") + var id = message.attr("id").substr(8) // cut "message-001" to "001" + var nick = message.attr("nick") // cut "/u/timb" to "timb" + var link = "http://dump.fm/p/" + nick + "/" + id + var content = message.find(".linkify") + if (!content.length) content = message.find(".content") + var rawContent = content.html() + var img = content.find("img").attr("src") + var via = "via " + nick + " on dump.fm" + return {"nick": nick, "id": id, "link": encodeURIComponent(link), "content": content, "img": encodeURIComponent(img), "via": encodeURIComponent(via)} + }, + "openLink": function(url){ + window.open(url, "_blank") + }, + "facebook": function(button){ + var message = Share.getMessage(button) + var url = "http://www.facebook.com/share.php?u=" + message.img + "&t=" + message.via + Share.openLink(url) + }, + "tumblr": function(button){ + var message = Share.getMessage(button) + var url = "http://www.tumblr.com/share?v=3&u=" + message.img + "&t=" + message.via + Share.openLink(url) + }, + "twitter": function(button){ + var message = Share.getMessage(button) + var url = "http://twitter.com/home?status=" + message.img + encodeURIComponent(" ") + message.via + Share.openLink(url) + }, + "delicious": function(button){ + var message = Share.getMessage(button) + var url = "http://delicious.com/save?url=" + message.img + "&title=" + message.img + "¬es=" + message.via + Share.openLink(url) + } +} + +Tag = { + // todo: get rid of all the duplicated code here and in share + "getMessage": function(button){ + var message = $(button).parents(".logged-dump") + var id = message.attr("id").substr(8) // cut "message-001" to "001" + var nick = message.attr("nick") // cut "/u/timb" to "timb" + var link = "http://dump.fm/p/" + nick + "/" + id + var content = message.find(".linkify") + if (!content.length) content = message.find(".content") + var rawContent = content.html() + var img = content.find("img").attr("src") + var via = "via " + nick + " on dump.fm" + return {"nick": nick, "id": id, "link": encodeURIComponent(link), + "content": content, "img": encodeURIComponent(img), + "via": encodeURIComponent(via)} + }, + "favorite": function(button){ + var message = Share.getMessage(button) + var favorited = ($(button).hasClass("favorite")) ? true : false + if (favorited) { + Tag.rm(message.id, "favorite") + $(button).removeClass("favorite") + } else { + Tag.add(message.id, "favorite") + $(button).addClass("favorite") } -}
\ No newline at end of file + }, + "add": function(message_id, tag){ + Tag.ajax("/cmd/tag/add", {"message_id": message_id, "tag": tag}) + }, + "rm": function(message_id, tag){ + Tag.ajax("/cmd/tag/rm", {"message_id": message_id, "tag": tag}) + }, + "ajax": function(url, data) { + $.ajax({ + "type": 'POST', + "timeout": 5000, + "url": url, + "data": data, + "cache": false + }); + } +} + + +// uhhh todo: move preload stuff into js: +// var nextImage = new Image(); +// nextImage.src = "your-url/newImage.gif"; + +// mAcRoMeDiA sHiT +function MM_swapImgRestore() { //v3.0 + var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; +} + +function MM_preloadImages() { //v3.0 + var d=document;if(d.images){ if(!d.MM_p) d.MM_p=new Array();var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} +} + +function MM_findObj(n, d) { //v4.01 + var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { + d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} + if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; + for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); + if(!x && d.getElementById) x=d.getElementById(n); return x; +} + +function MM_swapImage() { //v3.0 + var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) + if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} +} |
