Skip to content

Instantly share code, notes, and snippets.

@artgibson
Created August 12, 2010 20:38
Show Gist options
  • Save artgibson/521680 to your computer and use it in GitHub Desktop.
Save artgibson/521680 to your computer and use it in GitHub Desktop.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Recent Tweets</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="http://fanpagelist.com/css.css" />
<link rel="stylesheet" type="text/css" href="http://fanpagelist.com/jquery/jquery.css" />
<link rel="stylesheet" type="text/css" href="http://fanpagelist.com/jquery/jquery.jtweetsanywhere-1.0.1.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://fanpagelist.com/jquery/jquery.jtweetsanywhere-1.0.1.min.js"></script>
<! -- Embedly Jquery Lib -->
<script type="text/javascript" src="http://scripts.embed.ly/jquery.embedly.js" ></script>
<!-- Twitter @anywhere -->
<script src="http://platform.twitter.com/anywhere.js?id=smRhyIBLpDFOFtSrVUmQXA&v=1.1" type="text/javascript"></script>
</head>
<body>
<div style="margin:10px 0;width:480px"><strong>Bookmark this tab:</strong> <a href="/user/ashton/tweets">http://fanpagelist.com/user/ashton/tweets</a></div>
<div style="width:480px;margin:5px 0" id="tweet_box"></div>
<div style="margin: 10px 0;"><span style="font-weight:bold; color:#ff0000">TIP:</span> Hover your mouse over profile images or <span id="tip_usernames">usernames</span> below to view more information</div>
<div style="width:480px" id="popular_tweets"></div>
<div style="width:480px" id="recent_tweets"></div>
<script type="text/javascript">
//helper to pull out all urls from tweet into a list
function getUrls(source) {
var e=/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
return source.match(e);
}
$('#tweet_box').jTweetsAnywhere({
showTweetBox: {
label: '<span style="font-size:14px;color: #525163;font-weight:bold">Send a Tweet to Ashton Kutcher</span>',
counter: true,
width: 490,
height: 65,
defaultContent: '@aplusk (via @FanPageList) ',
onTweet: function(textTweet, htmlTweet){
alert('You sent this Tweet to Ashton Kutcher: ' + textTweet);
}
}
});
$('#popular_tweets').jTweetsAnywhere({
searchParams: ['q=from:aplusk', 'result_type=popular'],
count: 3,
loadingDecorator: function(tweet, options){
return 'Loading popular tweets...';
},
tweetTimestampDecorator:
function (tweet,options){
var meta=tweet.metadata['recent_retweets'];
var b=formatDate(tweet.created_at),c=parseInt(((new Date).getTime()-Date.parse(b))/1E3);a="";
if(c<60)a+="less than a minute ago";else if(c<3600){c=parseInt((c+30)/60);a+=c+" minute"+(c==1?"":"s")+" ago"}else if(c<86400){c=parseInt((c+1800)/3600);a+="about "+c+" hour"+(c==1?"":"s")+" ago"}else{c=parseInt((c+43200)/86400); a+="about "+c+" day"+(c==1?"":"s")+" ago";b=new Date(b);c="AM";var e=b.getHours();if(e>12){e-=12;c="PM"}var f=b.getMinutes();a+=" ("+e+":"+((f<10?"0":"")+f)+" "+c+" "+(b.getMonth()+1)+"/"+b.getDate()+"/"+b.getFullYear()+")"}
if(typeof(meta)=='undefined'){
return'<span class="jta-tweet-timestamp">'+a+'<br /><span style="color:#525163;background: #97C1d9;border-radius:3px;padding: 2px 3px;">Popular</span></span>';
} else {
return'<span class="jta-tweet-timestamp">'+a+'<br /><span style="color:#525163;background: #97C1d9;border-radius:3px;padding: 2px 3px;">'+meta+'+ recent retweets</span>'+'</span>';
}
}
});
$('#recent_tweets').jTweetsAnywhere({
username: 'aplusk',
tweetProfileImagePresent: true,
count: 20,
loadingDecorator: function(tweet, options){
return '<span>Loading tweets...</span>';
},
<!-- Custom Tweet Text Decorator -->
tweetTextDecorator: function(tweet, options)
{
// the default tweet text decorator optionally marks links, @usernames, and
// #hashtags
var tweetText = options.linkDecorator ? options.linkDecorator(tweet.text, options) : tweet.text;
if (options.usernameDecorator)
tweetText = options.usernameDecorator(tweetText, options);
if (options.hashtagDecorator)
tweetText = options.hashtagDecorator(tweetText, options);
// embed code
var embed_code = '';
// calling Embedly directly here
urls = getUrls(tweetText);
if (urls != null){
$.each(urls, function(index, url){
$.embedly(url, {maxWidth:420}, function(oembed){
if (oembed != null){
embed_code = oembed.code;
return false;
}
});
});
}
return '<span class="tweet-text">' + tweetText + embed_code + '</span>';
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment