...
HTML |
---|
<script> (function( $ ){ $.extend( { jTwitter: function( username, numPosts, fnk ) { var info = {}; // If no arguments are sent or only username is set if( username == 'undefined' || numPosts == 'undefined' ) { return; } else if( $.isFunction( numPosts ) ) { // If only username and callback function is set fnk = numPosts; numPosts = 5; } var url = "http://twitter.com/status/user_timeline/" + username + ".json?count="+numPosts+"&callback=?"; $.getJSON( url, function( data ){ if( $.isFunction( fnk ) ) { fnk.call( this, data ); } }); } }); })( jQuery ); function replaceURLWithHTMLLinks(text) { var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; return text.replace(exp,"<a href='$1'>$1</a>"); } jQuery(document).ready(function(){ $.jTwitter('BellaDati', 8, function(data){ $('#posts').empty(); $('#posts').addClass("postsComplete"); $.each(data, function(i, post){ $('#posts').append( '<div class="twitterPost post">' + replaceURLWithHTMLLinks(post.text) +'</div>' ); }); }); var stamp = new Date().getTime(); $.getJSON('http://www.belladati.com/blog:jsonFeed?count=10&stamp='+stamp+'&callback=?',function(){ }); }); function blogPostCallback(data) { $('#blog').empty(); $('#blog').addClass("blogComplete"); $.each(data, function(i, post){ var published = Date.parse(post.published); $('#blog').append( '<div class="blogPost post"><div class="blogPostTitle"><strong><a target="_blank" rel="external" href="'+post.url+'">' +post.title +'</a></strong></div>'+ '<a class="blogPostImage" target="_blank" rel="external" href="'+post.url+'"><img src="'+post.image+'" /></a>'+ '<div class="blogPostContent">'+post.short+'</div>'+ '<div class="blogPostDetail"></div>'+ '</div>' ); }); } </script> <style> .post { padding-bottom: 6px; margin-bottom: 6px !important; border-bottom: 1px solid #e5e5e5; } .blogPost { padding-left: 100px; position: relative; min-height: 80px; } .blogPostTitle { margin-bottom: 6px; } .blogPostImage { position: absolute; left: 0; top: 0; } </style> |