Drop this little gem in your site’s header:
[javascript]
<script>
function numberFormat(x) {
return x.toString().replace(/B(?=(d{3})+(?!d))/g, ‘,’);
}
jQuery(document).ready(function($){
$(‘.trigger_facebook_count’).each(function(){
var url = $(this).attr(‘data-url’);
var that = $(this);
$.get(‘http://graph.facebook.com/’ + url, function(data) {
that.html(numberFormat(data.shares));
});
});
});
</script>
[/javascript]
Then, add elements to your page like so:
[html]<div class="trigger_facebook_count" data-url="http://bossip.com"></div>%5B/html%5D
Remember to change the data-url to whatever URL you are referencing, and viola! You’re done.
Leave a Reply