Created
March 1, 2010 20:26
-
-
Save jaikoo/318774 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tumblr.News = { | |
renderLinks: function(data, maxTitles){ | |
var newsItems = '' | |
var articles = data['posts']; | |
var title = ''; | |
var count = 0; | |
$.each(articles, function(i, item){ | |
if(count < maxTitles){ | |
title = item['regular-title'] || item['photo-caption'] || item['video-caption']; | |
var tumblr_id = item['id'] | |
if(title != undefined){ | |
newsItems += '<li><a href="/news/' + tumblr_id + '">' + title + '</a></li>'; | |
} | |
count++; | |
} | |
}); | |
$('.news-items').html(newsItems); | |
}, | |
render: function(data){ | |
var article = data['posts'][0]; | |
var title = article['regular-title'] || article['photo-caption'] || article['video-caption']; | |
var date = new Date(Date.parse(article['date'])) | |
var months = new Array(12); | |
months[0] = "Jan"; | |
months[1] = "Feb"; | |
months[2] = "Mar"; | |
months[3] = "Apr"; | |
months[4] = "May"; | |
months[5] = "Jun"; | |
months[6] = "Jul"; | |
months[7] = "Aug"; | |
months[8] = "Sep"; | |
months[9] = "Oct"; | |
months[10] = "Nov"; | |
months[11] = "Dec"; | |
if(title != undefined){ | |
$('h2.news-title').text(title); | |
$('span.day').text(date.getDate()); | |
$('span.month').text(months[date.getMonth()]); | |
if(article['type'] == 'photo'){ | |
$('div.news-content').html('<img src="' + article['photo-url-500' ]+'" alt="' + article['photo-caption'] +'"/>'); | |
}else if(article['type'] == 'video'){ | |
$('div.news-content').html(article['video-source']); | |
}else{ | |
$('div.news-content').html(article['regular-body']); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment