summaryrefslogtreecommitdiff
path: root/static/js
diff options
context:
space:
mode:
Diffstat (limited to 'static/js')
-rwxr-xr-xstatic/js/pichat.js44
1 files changed, 43 insertions, 1 deletions
diff --git a/static/js/pichat.js b/static/js/pichat.js
index 3775cfe..330aa86 100755
--- a/static/js/pichat.js
+++ b/static/js/pichat.js
@@ -5,6 +5,10 @@ var MaxImagePosts = 40
// Utils
+// use e.g. "backgroundColor" not "background-color"
+function isCSSPropertySupported(prop){
+ return prop in document.body.style;
+}
function escapeHtml(txt) {
if (!txt) { return ""; }
@@ -470,7 +474,7 @@ function initDirectory() {
}
//big hand stuff
-
+// TODO: replace this with simple pointer-events thing.
function initBigHand(id){
var cursorId = "#cursor-big"
@@ -535,4 +539,42 @@ function initBigHand(id){
$(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.find("a").attr("href").substr(3) // 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.link + "&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 + "&notes=" + message.via
+ Share.openLink(url)
+ }
} \ No newline at end of file