Skip to content

Instantly share code, notes, and snippets.

@nytrmg-user
Created August 13, 2011 16:15
Show Gist options
  • Save nytrmg-user/1143995 to your computer and use it in GitHub Desktop.
Save nytrmg-user/1143995 to your computer and use it in GitHub Desktop.
Greig hearing
<script type="text/javascript" src="http://cache.boston.com/universal/js/date.js"></script>
<script type="text/javascript">
function twitter_update(data){
for (var i=0; i<data.length; i++) {
// Use Date.js to correctly parse Twitter dates, which are non-standard
var date = new Date(Date.parse(data[i].created_at).add({ hours: -4 }));
// prettyDate plugin returns "1 minute ago", "3 hours ago", etc.
var timestamp = prettyDate(date.toString("yyyy-MM-ddTHH:mm:ss"));
var re = /((http|https|ftp):\/\/[\w?=&.\/-;#~%-]+(?![\w\s?&.\/;#~%"=-]*>))/g;
data[i].text = data[i].text.replace(re, '<a href="$1">$1</a>');
var hash_re = /[#]+([A-Za-z0-9-_]+)/g;
data[i].text = data[i].text.replace(hash_re, '<a href="http://twitter.com/#!/search/%23$1">#$1</a>');
var mention_re = /[@]+([A-Za-z0-9-_]+)/g;
data[i].text = data[i].text.replace(mention_re, '<a href="http://twitter.com/$1">@$1</a>');
$("#twitterView").append('<p id="twitterTweet" class="text"><span class="username"><a href="http://twitter.com/#!/'+data[i].user.screen_name+'">'+data[i].user.screen_name+'</a></span>: '+data[i].text+' </a><span class="time"> <a href="http://www.twitter.com/'+data[i].user.screen_name+'/status/'+data[i].entity_id+'">'+timestamp+'</a></span></p>')
}
}
</script>
<div id="twitterContainer" class="HPoption">
<div id="twitterHeader" class="HPoption" style="padding: 0px 10px 0px 10px">
<!-- <div id="tweethead" style="font-family: Arial, Helvetica; font-size: 17px; font-weight: bold; padding: 5px 0px 5px 0px; margin-left: -10px;">Live tweets from Catherine Greig's bail hearing today</div> -->
</div>
<div id="twitterView" class="HPFULLoption">
</div>
<script type="text/javascript" src="http://tweetriver.com/BostonUpdate/greig-hearing.json?callback=twitter_update">
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment