Reputation: 349
I need to make some changes to this news ticker which is based on goldyberg's jquery horizontal newsticker using Google JSAPI:
http://inetwebdesign.com/jQueryTools/tickers/horizontal-news-ticker2/horizontal-news-ticker3.html
I have two questions:
How do you limit the number of words that are being pulled into the div? Right now it is too long and it wraps.
How do you add the date from the rss feed to the string that is displayed?
Here is the code I believe is relevant:
parse: function(entries) {
var feedMarkup = '';
feedMarkup += '<ul>';
for (var i = 0; i < entries.length; i++) {
feedMarkup += '<li><a target="_blank"
href="'+entries[i].link+'">'+entries[i].title+'</a></li>';
}
feedMarkup += '</ul>';
$("#ticker-content").empty().append(feedMarkup).fadeIn(400);
$('#ticker ul
li:eq(0)').show();
current = $('#ticker ul li:eq(0)').index();
first = 0;
last = $('#ticker ul li').length;
Thanks in advance for your help.
Regards, umbre
Upvotes: 0
Views: 4894
Reputation: 626
A demo is here: http://www.marlenynunez.com/files/jsapi/horizontal-news-ticker4.html
HTML file:
<script type="text/javascript" src="js/date.js"></script>
<script type="text/javascript" src="js/scripts.js"></script>
scripts.js file:
parse: function(entries) {
var feedMarkup = '';
var pubDate;
var titleText;
var splitText;
feedMarkup += '<ul>';
for (var i = 0; i < entries.length; i++) {
titleText = entries[i].title;
splitText = titleText.substring(0,60).split(" ");
titleText = splitText.slice(0, -1).join(" ") + '...';
pubDate = Date.parse(String(entries[i].publishedDate)).toString('MMM dd');
feedMarkup += '<li>'+pubDate+' | <a target="_blank" href="'+entries[i].link+'">'+titleText+'</a></li>';
}
Upvotes: 1