diff options
Diffstat (limited to 'static')
| -rwxr-xr-x | static/index.html | 131 | ||||
| -rwxr-xr-x | static/js/home.js | 28 | ||||
| -rwxr-xr-x | static/js/pichat.js | 364 |
3 files changed, 269 insertions, 254 deletions
diff --git a/static/index.html b/static/index.html index da98e29..e8ec712 100755 --- a/static/index.html +++ b/static/index.html @@ -1,40 +1,13 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" -"http://www.w3.org/TR/html4/strict.dtd"> - -<html><head> -<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> -<script type="text/javascript" src="/static/js/sha1.js"></script> -<script type="text/javascript" src="/static/js/home.js"></script> -<script> -$(document).ready(initLoginForm); -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];} -} -</script> -<link rel="stylesheet" type="text/css" href="static/reset.css"> - <link rel="shortcut icon" href="static/favicon.ico"> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> + <head> + <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> + <script type="text/javascript" src="/static/js/sha1.js"></script> + <script type="text/javascript" src="/static/js/home.js"></script> + <link rel="stylesheet" type="text/css" href="static/reset.css"> + <link rel="shortcut icon" href="static/favicon.ico"> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>dump.fm</title></head> -<style type="text/css"> - - + <style type="text/css"> body { background:#EEF2FF url(/static/fade-blue.png) top center repeat-x; @@ -171,57 +144,53 @@ label { </style> </head> <body> - -<div id="main" align="center"> - - <img src="/static/flyhorse.gif" id="horse" /> - <img src="/static/guaranteed_customer_satisfaction.gif" id="customer" /> - - <div id="registerbox"> - <div id="logo-and-text"> - <a href="/"><img src="/static/dumpmod1.png"></a> - <p align="center" class="line">Talk with pictures!</p> - <div align="right" class="txt"> - <br> - <div align="center">Right now dump.fm is invite only...<br> - If you have a registration code, <a href="/register" style="text-decoration:none;">click here!</a> <br> + <div id="main" align="center"> + + <img src="/static/flyhorse.gif" id="horse" /> + <img src="/static/guaranteed_customer_satisfaction.gif" id="customer" /> + + <div id="registerbox"> + <div id="logo-and-text"> + <a href="/"><img src="/static/dumpmod1.png"></a> + <p align="center" class="line">Talk with pictures!</p> + <div align="right" class="txt"> + <br> + <div align="center">Right now dump.fm is invite only...<br> + If you have a registration code, <a href="/register" style="text-decoration:none;">click here!</a> <br> + </div> </div> </div> + <input type="text" id="nickInput" size="17" /> + <input id="passwordInputLabel" name="passwordInputLabel" size="17" type="text" class="invisible"> + <input type="password" id="passwordInput" size="17" /><br /> + <input id="signin-submit" value="Sign In" /> + <div id="remember"><label> + <input checked="checked" type="checkbox" name="rememberme" id="remembermeInput" /> + Remember Me + </label></div> </div> - <input type="text" id="nickInput" size="17" /> - <input id="passwordInputLabel" name="passwordInputLabel" size="17" type="text" class="invisible"> - <input type="password" id="passwordInput" size="17" /><br /> - - - <!-- <br /><a id="signin-submit">Sign In</a> --> - <input id="signin-submit" value="Sign In" /> - <div id="remember"><label> - <input checked="checked" type="checkbox" name="rememberme" id="remembermeInput" /> - Remember Me - </label></div> </div> -</div> -<div id="info" align="right"> - <img src="/static/vxhtml.gif"> - <img src="/static/aol_suck.gif"> + <div id="info" align="right"> + <img src="/static/vxhtml.gif"> + <img src="/static/aol_suck.gif"> <img src="/static/html_3_2.gif"> - <img src="/static/geocities.gif"> - <img src="/static/valid_html.gif"> -</div> - -<div id="preload"> - <img src="/static/img/cursors/osx.hand.gif" class="no-cursor invisible" id="cursor-big"> -</div> + <img src="/static/geocities.gif"> + <img src="/static/valid_html.gif"> + </div> -<script type="text/javascript"> -var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); -document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); -</script> -<script type="text/javascript"> -try { -var pageTracker = _gat._getTracker("UA-12364576-1"); -pageTracker._trackPageview(); -} catch(err) {}</script> + <div id="preload"> + <img src="/static/img/cursors/osx.hand.gif" class="no-cursor invisible" id="cursor-big"> + </div> + <script type="text/javascript"> + var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); + document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); + </script> + <script type="text/javascript"> + try { + var pageTracker = _gat._getTracker("UA-12364576-1"); + pageTracker._trackPageview(); + } catch(err) {} + </script> </body> </html> diff --git a/static/js/home.js b/static/js/home.js index e9be833..072617a 100755 --- a/static/js/home.js +++ b/static/js/home.js @@ -171,3 +171,31 @@ function login() { error: onError }); }; + + +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]; + } +} + diff --git a/static/js/pichat.js b/static/js/pichat.js index 4c1ca98..f643970 100755 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -7,67 +7,67 @@ var MaxImagePosts = 40 // use e.g. "backgroundColor" not "background-color" function isCSSPropertySupported(prop){ - return prop in document.body.style; + return prop in document.body.style; } function escapeHtml(txt) { - if (!txt) { return ""; } - else { return $("<span>").text(txt).html(); } + if (!txt) { return ""; } + else { return $("<span>").text(txt).html(); } } function linkify(text) { - LastMsgContainsImage = false - var URLRegex = /((\b(http\:\/\/|https\:\/\/|ftp\:\/\/)|(www\.))+(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi; - return text.replace(URLRegex, linkReplace); + LastMsgContainsImage = false + var URLRegex = /((\b(http\:\/\/|https\:\/\/|ftp\:\/\/)|(www\.))+(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi; + return text.replace(URLRegex, linkReplace); } // durty hack to use a global to check this... but otherwise i'd have to rewrite the String.replace function? :/ var LastMsgContainsImage = false -function linkReplace(url){ - var PicRegex = /\.(jpg|jpeg|png|gif|bmp)$/i; - var urlWithoutParams = url.replace(/\?.*$/i, ""); - - if (url.indexOf('http://') == 0 || url.indexOf('https://') == 0 || url.indexOf('ftp://') == 0) - linkUrl = url; - else - linkUrl = 'http://' + url; - - if (PicRegex.test(urlWithoutParams)){ - LastMsgContainsImage = true - return "<a target='_blank' href='" + linkUrl + "'><img src='" + linkUrl + "'></a>" - } else { - return "<a target='_blank' href='" + linkUrl + "'>" + url + "</a>" - } +function linkReplace(url) { + var PicRegex = /\.(jpg|jpeg|png|gif|bmp)$/i; + var urlWithoutParams = url.replace(/\?.*$/i, ""); + + if (url.indexOf('http://') == 0 || url.indexOf('https://') == 0 || url.indexOf('ftp://') == 0) + linkUrl = url; + else + linkUrl = 'http://' + url; + + if (PicRegex.test(urlWithoutParams)){ + LastMsgContainsImage = true + return "<a target='_blank' href='" + linkUrl + "'><img src='" + linkUrl + "'></a>" + } else { + return "<a target='_blank' href='" + linkUrl + "'>" + url + "</a>" + } } function linkifyWithoutImage(text) { - LastMsgContainsImage = false - var URLRegex = /((\b(http\:\/\/|https\:\/\/|ftp\:\/\/)|(www\.))+(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi; - return text.replace(URLRegex, linkReplaceWithoutImage); + LastMsgContainsImage = false + var URLRegex = /((\b(http\:\/\/|https\:\/\/|ftp\:\/\/)|(www\.))+(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi; + return text.replace(URLRegex, linkReplaceWithoutImage); } function linkReplaceWithoutImage(url){ - var PicRegex = /\.(jpg|jpeg|png|gif|bmp)$/i; - var urlWithoutParams = url.replace(/\?.*$/i, ""); - linkUrl = url.indexOf('http://') == 0 ? url : 'http://' + url; + var PicRegex = /\.(jpg|jpeg|png|gif|bmp)$/i; + var urlWithoutParams = url.replace(/\?.*$/i, ""); + linkUrl = url.indexOf('http://') == 0 ? url : 'http://' + url; - return "<a target='_blank' href='" + linkUrl + "'>" + url + "</a>" + return "<a target='_blank' href='" + linkUrl + "'>" + url + "</a>" } // Message Handling var ImageMsgCount = 0 function removeOldMessages(){ - // don't count posts that are all text - if (LastMsgContainsImage) ImageMsgCount += 1; - while (ImageMsgCount > MaxImagePosts) { - var imgMsg = $(".contains-image:first") - if (imgMsg.length) { - imgMsg.prevAll().remove() // remove all text messages before the image message - imgMsg.remove() - } else break; - ImageMsgCount -= 1; - } + // don't count posts that are all text + if (LastMsgContainsImage) ImageMsgCount += 1; + while (ImageMsgCount > MaxImagePosts) { + var imgMsg = $(".contains-image:first") + if (imgMsg.length) { + imgMsg.prevAll().remove() // remove all text messages before the image message + imgMsg.remove() + } else break; + ImageMsgCount -= 1; + } } function buildMsgContent(content) { @@ -75,15 +75,15 @@ function buildMsgContent(content) { } function buildMessageDiv(msg, isLoading) { - removeOldMessages() - var nick = escapeHtml(msg.nick); - var msgId = !isLoading ? 'id="message-' + msg.msg_id + '"' : ''; - var loadingClass = isLoading ? ' loading' : ''; - var containsImageClass = LastMsgContainsImage ? ' contains-image' : ''; - return '<div class="msgDiv ' + loadingClass + containsImageClass + '" ' + msgId + '>' - + '<b><a href="/u/' + nick + ' ">' + nick + '</a>: </b>' - + buildMsgContent(msg.content) - + '</div>'; + removeOldMessages() + var nick = escapeHtml(msg.nick); + var msgId = !isLoading ? 'id="message-' + msg.msg_id + '"' : ''; + var loadingClass = isLoading ? ' loading' : ''; + var containsImageClass = LastMsgContainsImage ? ' contains-image' : ''; + return '<div class="msgDiv ' + loadingClass + containsImageClass + '" ' + msgId + '>' + + '<b><a href="/u/' + nick + ' ">' + nick + '</a>: </b>' + + buildMsgContent(msg.content) + + '</div>'; } function buildUserDiv(user) { @@ -130,8 +130,8 @@ function submitMessage() { $('#msgInput').val(''); if (content == '') { return; } if (content.length > 6666) { - alert("POST TOO LONG DUDE!"); - return; + alert("POST TOO LONG DUDE!"); + return; } // this shouldn't just be client side :V PendingMessages[content] = true; @@ -139,8 +139,8 @@ function submitMessage() { var div = addNewMessage(msg, true); var onSuccess = function(json) { - if (typeof pageTracker !== 'undefined') { - pageTracker._trackEvent('Message', 'Submit', typeof Room !== 'undefined' ? Room : 'UnknownRoom'); + if (typeof pageTracker !== 'undefined') { + pageTracker._trackEvent('Message', 'Submit', typeof Room !== 'undefined' ? Room : 'UnknownRoom'); } div.attr('id', 'message-' + json) .removeClass('loading').addClass('loaded'); @@ -207,11 +207,11 @@ function updateUI(msgs, users) { } function sortUsersByAlpha(a, b){ - var nickA = a.nick.toLowerCase() - var nickB = b.nick.toLowerCase() - if (nickA > nickB) return 1 - else if (nickA < nickB) return -1 - return 0 + var nickA = a.nick.toLowerCase() + var nickB = b.nick.toLowerCase() + if (nickA > nickB) return 1 + else if (nickA < nickB) return -1 + return 0 } function isDuplicateMessage(m) { @@ -312,7 +312,7 @@ function activateProfileEditable() { var onSubmit = function(attr, newVal, oldVal) { newVal = $.trim(newVal); if (newVal == oldVal) { return oldVal }; - + $.ajax({ type: "POST", timeout: 5000, @@ -386,13 +386,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 r = typeof Room !== 'undefined' ? Room : 'UnknownRoom'; + pageTracker._trackEvent('Message', 'Upload', r); } } new AjaxUpload(elementId, { @@ -400,7 +416,7 @@ function setupUpload(elementId, roomKey) { autoSubmit: true, name: 'image', data: { room: roomKey }, - onSubmit: onSubmit, + onSubmit: onSubmit, onComplete: onComplete }); } @@ -432,50 +448,50 @@ function setupUploadAvatar(elementId) { onComplete: onComplete }); } - + // scrolling stuff // this code keeps the div scrolled to the bottom, but will also let the user scroll up, without jumping down function isScrolledToBottom(){ - var threshold = 15; - - var containerHeight = messageList.style.pixelHeight || messageList.offsetHeight - var currentHeight = (messageList.scrollHeight > 0) ? messageList.scrollHeight : 0 + var threshold = 15; + + var containerHeight = messageList.style.pixelHeight || messageList.offsetHeight + var currentHeight = (messageList.scrollHeight > 0) ? messageList.scrollHeight : 0 - var result = (currentHeight - messageList.scrollTop - containerHeight < threshold); + var result = (currentHeight - messageList.scrollTop - containerHeight < threshold); - return result; + return result; } function scrollIfPossible(){ - if (lastScriptedScrolledPosition <= messageList.scrollTop || isScrolledToBottom()) - scrollToEnd() + if (lastScriptedScrolledPosition <= messageList.scrollTop || isScrolledToBottom()) + scrollToEnd() } var lastScriptedScrolledPosition = 0 function scrollToEnd(){ - messageList.scrollTop = messageList.scrollHeight - lastScriptedScrolledPosition = messageList.scrollTop + messageList.scrollTop = messageList.scrollHeight + lastScriptedScrolledPosition = messageList.scrollTop } function scrollWatcher(){ - scrollIfPossible() - setTimeout(scrollWatcher, 500) + scrollIfPossible() + setTimeout(scrollWatcher, 500) } // well fuck webkit for not supporting {text-decoration: blink} function blinkStart(){ - blinkTimer = setInterval(function(){ - $(".blink").removeClass("blink").addClass("blink-turning-off") - $(".blink-off").removeClass("blink-off").addClass("blink") - $(".blink-turning-off").removeClass("blink-turning-off").addClass("blink-off") - },500); + blinkTimer = setInterval(function(){ + $(".blink").removeClass("blink").addClass("blink-turning-off") + $(".blink-off").removeClass("blink-off").addClass("blink") + $(".blink-turning-off").removeClass("blink-turning-off").addClass("blink-off") + },500); } function blinkStop(){ - clearInterval(blinkTimer); + clearInterval(blinkTimer); } function initDirectory() { @@ -489,104 +505,106 @@ function initDirectory() { // TODO: replace this with simple pointer-events thing. function initBigHand(id){ - var cursorId = "#cursor-big" - var cursor = $(cursorId)[0] - - // jquery's reported element sizes are not exactly the same as the browser's 'mouseover' target sizes - // so we'll allow a few pixels extra - var fudgeFactor = 2 + var cursorId = "#cursor-big" + var cursor = $(cursorId)[0] + + // jquery's reported element sizes are not exactly the same as the browser's 'mouseover' target sizes + // so we'll allow a few pixels extra + var fudgeFactor = 2 - $(id).addClass("no-cursor") + $(id).addClass("no-cursor") - // i have to do this weirdly bc putting the cursor image where the mouse cursor is causes problems with mouse events: - // * it stops mousemove events on the image below the mouse cursor - // * it fucks up mouseover/out and even mouseenter/leave events, as well as click - - // so i am doing this: - // on mousing over the image: - // make cursor visible - // find image co-ords - // bind a global mousemove func - // bind cursor click event - // unbind mouseover - // mousemove func: - // move image to mouse co-ords - // if mouse co-ords are outside the image co-ords: - // make cursor invisible - // unbind mousemove func - // unbind cursor click event + // i have to do this weirdly bc putting the cursor image where the mouse cursor is causes problems with mouse events: + // * it stops mousemove events on the image below the mouse cursor + // * it fucks up mouseover/out and even mouseenter/leave events, as well as click + + // so i am doing this: + // on mousing over the image: + // make cursor visible + // find image co-ords + // bind a global mousemove func + // bind cursor click event + // unbind mouseover + // mousemove func: + // move image to mouse co-ords + // if mouse co-ords are outside the image co-ords: + // make cursor invisible + // unbind mousemove func + // unbind cursor click event - var mousemove = function(e){ - var y = e.pageY, x = e.pageX, coords = initBigHand.coords + var mousemove = function(e){ + var y = e.pageY, x = e.pageX, coords = initBigHand.coords + + cursor.style.top = y + "px" + cursor.style.left = x - 32 + "px" // 32: (4 pixels * 8 pixels per big pixel) to line up pointy finger with cursor + if (y < coords.top || + y > coords.bottom || + x < coords.left || + x > coords.right) { + $(cursorId).addClass('invisible') + $(cursorId).css({"top": 0, "left": 0 }) + $(cursorId).unbind('click', cursorClick) + $('logo7').unbind('mousemove', mousemove) + $(id).mouseover(imageMouseOver) + } + } - cursor.style.top = y + "px" - cursor.style.left = x - 32 + "px" // 32: (4 pixels * 8 pixels per big pixel) to line up pointy finger with cursor - if (y < coords.top || - y > coords.bottom || - x < coords.left || - x > coords.right) { - $(cursorId).addClass('invisible') - $(cursorId).css({"top": 0, "left": 0 }) - $(cursorId).unbind('click', cursorClick) - $('logo7').unbind('mousemove', mousemove) - $(id).mouseover(imageMouseOver) - } - } - - var cursorClick = function(){ $(id).click() } - - var imageMouseOver = function(){ - //console.log("moused over...") - initBigHand.coords = { - "left": $(id).offset().left - fudgeFactor, - "top": $(id).offset().top - fudgeFactor, - "right": $(id).offset().left + $(id).width() + fudgeFactor, - "bottom": $(id).offset().top + $(id).height() + fudgeFactor + var cursorClick = function(){ $(id).click() } + + var imageMouseOver = function(){ + //console.log("moused over...") + initBigHand.coords = { + "left": $(id).offset().left - fudgeFactor, + "top": $(id).offset().top - fudgeFactor, + "right": $(id).offset().left + $(id).width() + fudgeFactor, + "bottom": $(id).offset().top + $(id).height() + fudgeFactor + } + $('body').mousemove(mousemove) + $(cursorId).click(cursorClick) + $(cursorId).removeClass('invisible') + $(id).unbind('mouseover', imageMouseOver) } - $('body').mousemove(mousemove) - $(cursorId).click(cursorClick) - $(cursorId).removeClass('invisible') - $(id).unbind('mouseover', imageMouseOver) - } - - $(id).mouseover(imageMouseOver) - + + $(id).mouseover(imageMouseOver) + } 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) - } + "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) + } }
\ No newline at end of file |
