Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter by Date #16

Open
wavemaster447 opened this issue Aug 28, 2013 · 0 comments
Open

Filter by Date #16

wavemaster447 opened this issue Aug 28, 2013 · 0 comments

Comments

@wavemaster447
Copy link

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant