FeedEk
FeedEk copied to clipboard
Filter by Date
Hi,
I was working to adapt the code to filter by date (i.e. only show posts from today). I'm not terribly talented at JS, but here's what I came up with. I managed to break the core functionality (error object object method undefined), but it may be a jumping off point - is this possible?
/*
* FeedEk jQuery RSS/ATOM Feed Plugin v1.1.2
* http://jquery-plugins.net/FeedEk/FeedEk.html
* Author : Engin KIZIL
* http://www.enginkizil.com
*/
(function (e) { e.fn.FeedEk = function (t) { var n = { FeedUrl: "http://rss.cnn.com/rss/edition.rss", MaxCount: 5, ShowDesc: true, ShowPubDate: true, CharacterLimit: 0, TitleLinkTarget: "_blank", onlyToday: false };
if (t) { e.extend(n, t) } var r = e(this).attr("id");
var i;
e("#" + r).empty().append('<div style="padding:3px;"></div>'); e.ajax({ url: "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=" + n.MaxCount + "&output=json&q=" + encodeURIComponent(n.FeedUrl) + "&hl=en&callback=?", dataType: "json", success: function (t) { e("#" + r).empty();}});
var s = "";
e.each(t.responseData.feed.entries, function (e, t) {
if (n.onlyToday = false)
{
s += '<li><div class="itemTitle"><a href="' + t.link + '" target="' + n.TitleLinkTarget + '" >' + t.title + "</a></div>";
if (n.ShowPubDate) { i = new Date(t.publishedDate);
s += '<div class="itemDate">' + i.toLocaleDateString() + "</div>" } if (n.ShowDesc) { if (n.DescCharacterLimit > 0 && t.content.length > n.DescCharacterLimit) { s += '<div class="itemContent">' + t.content.substr(0, n.DescCharacterLimit) + "...</div>" } else { s += '<div class="itemContent">' + t.content + "</div>" } }}
else {
date = new Date(t.publishedDate);
today = new Date(getDate());
if (date = today)
{
s += '<li><div class="itemTitle"><a href="' + t.link + '" target="' + n.TitleLinkTarget + '" >' + t.title + "</a></div>";
if (n.ShowPubDate) { i = new Date(t.publishedDate);
s += '<div class="itemDate">' + i.toLocaleDateString() + "</div>" }
if (n.ShowDesc) {
if (n.DescCharacterLimit > 0 && t.content.length > n.DescCharacterLimit)
{ s += '<div class="itemContent">' + t.content.substr(0, n.DescCharacterLimit) + "...</div>"
}
else { s += '<div class="itemContent">' + t.content + "</div>" } } } //end if today
} //end else todayonly
}); //end each
e("#" + r).append('<ul class="slides">' + s + "</ul>") } });(jQuery)