所以我有一个RSS源显示在多个页面上。在一个页面上,我希望显示等于或超出今天日期的所有事件。在另一个页面上,我想要未来的事件(如主页),但只需要特定字符串标题的事件。如果文件正确读取RSS源,因为源没有任何旧日期,所有这一切都可以避免。这就是问题的真正核心。
截至目前,我已为主页添加了一些内容。它会看到前x个旧条目,然后绕过不等于或大于今天日期的旧条目。这仅适用于主页。
for (var i = 0; i < result.feed.entries.length; i++) {
var entry = result.feed.entries[i];
//RegEx queries for 'match' method
var filter_by_REG = RegExp(filter_by, 'i');
var filter_by_2_REG = RegExp(filter_by_2, 'i');
var cond1 = result.feed.entries[i].title.match(filter_by_REG);
var cond2 = result.feed.entries[i].title.match(filter_by_2_REG);
var today = new Date;
var pubDate = new Date(entry.publishedDate);
if (pubDate >= today) {
//Display All items
if(display_all == true){
cond1 = true; cond2 = true;
}
}
//Query entries for matches and add them to "entry" array for display
if(cond1 || cond2 ){
var pubDate = new Date(entry.publishedDate);
var pubMonth = month_names[pubDate.getMonth()];
var pubdateNum = pubDate.getDate();
var href = 'http-link-here';//entry.link;
var title = removeDateTitle(entry.title);
var location = entry.categories[0];
if(location != undefined){
location = location.replace(/[+]/g ," ");
}
var time = formatTime( entry.publishedDate );
var desc = entry.content;
desc = removeDateDesc(desc);
desc_short = desc.split(" ").splice(0, 25).join(" ");
desc_short += "...";
// Output
html += '<div class="calentry' + ' tooltip_' + i + '">' + '<div class="calcon">' + '<div class="caltop">' + pubMonth + '</div>' + '<div class="calbottom">' +
pubdateNum + '</div>' + '</div>' + '<div class="description"><h3 class="calhead"><a href="' + href + '" target="_blank">' + title + '</a></h3>' +
'<div class=callocation>' + time + ' in ' + location + '</div>' + '<p>' + desc_short + '<br />' +
'</p></div><div class="clear"></div>' + '</div>';
//QtipContent
html += '<div style="display: none;">' +
'<b>Full Description:</b><br />' + replaceURLWithHTMLLinks(desc) + '<br />' +
'<p><b>Time: </b>' + time + '<br />' +
'<b>Location: </b>' + location +
//throw new Error(html);
//update content
content.innerHTML = html;
}
}//end loop
//Display message when no feed items found
if(html == ''){
html += '<p class="cal_noEvents">No events currently scheduled.</p>';
content.innerHTML = html;
}
//Hide PreLoader
$('#loading').fadeOut('slow');
//Animate loaded content
$(content).wrapInner('<div class="calendarInner" />'); //wrap with inner div
var contentHeight = $('.calendarInner').outerHeight();// Get the height of the content div.
contentHeight = contentHeight;
$(content).animate({height:contentHeight}, 1000); // Animate the height
$('.calendarInner').css('width','100%'); //Fix border line issue after animation
//Qtip
var cal_items
$('.calentry').each(function() {
var thisEntry = $(this);
thisEntry.qtip(
{
content: {
text: thisEntry.next('div:hidden'),
title: {
text: thisEntry.find('h3').text(),
button: true
}
},
position: {
my: 'center', // ...at the center of the viewport
at: 'center',
target: $(window)
},
show: {
event: 'click', // Show it on click...
solo: true, // ...and hide all other tooltips...
modal: true // ...and make it modal
},
hide: false,
style: {
classes: 'ui-tooltip-light ui-tooltip-rounded',
width: 500
}
});
}).bind('click', function(event){ event.preventDefault(); return false; });
//end qtip
}
}
function OnLoad() {
// Create a feed instance that will grab the feed.
var feed = new google.feeds.Feed(feed_url);
feed.setNumEntries(count);
// Calling load sends the request off. It requires a callback function.
feed.load(feedLoaded);
}
google.setOnLoadCallback(OnLoad);
} //end init
};
$.fn.extend({
//pass the options variable to the function
fsucalendar: function(options) {
//Set the default values, use comma to separate the settings, example:
var defaults = {
filter_by : false,
filter_by_2 : false,
count : 4,
display_all : false,
feed_url : 'noFeed',
link_url : 'http://cal.aspx'
}
var options = $.extend(defaults, options);
var o = options;
//Call the init method (get the ball rollin) -- passing options 'o'
source.init(o);
}
});
})(jQuery);