Skip to content

Instantly share code, notes, and snippets.

@abraham
Created August 24, 2010 12:08
Show Gist options
  • Save abraham/547432 to your computer and use it in GitHub Desktop.
Save abraham/547432 to your computer and use it in GitHub Desktop.
function fillAnywhereTweetBox(url) {
twttr.anywhere("1", function (twitter) {
var name = getBloggerPageName();
if (name == "the.hackerConundrum") {
var content = "Reading \"" + name +"\" - " + url + " by @abraham"
} else {
var content = "Reading \"" + name +"\" - " + url + " by @abraham"
}
twitter("#twitter-anywhere-gadget").tweetBox({
counter: 0,
height: 100,
width: 217,
label: "",
defaultContent: content,
complete: function (tb) {
$(".twitter-anywhere-tweet-box")[0].contentWindow.document.getElementById("tweet-box").focus();
}
});
});
}
function getGooglURL(url){
window.googlCallback = function(response) {
if(response.error_message) {
fillAnywhereTweetBox(url);
} else {
fillAnywhereTweetBox(response.short_url);
}
};
var s = document.createElement("script");
s.src = "http://ggl-shortener.appspot.com/?url=" + encodeURIComponent(url) + "&jsonp=googlCallback";
document.body.appendChild(s);
}
if (window.location.href == 'http://blog.abrah.am/') {
fillAnywhereTweetBox(window.location.href);
} else {
getGooglURL(window.location.href);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment