Add short preview to rss news

This commit is contained in:
kpcyrd 2014-09-15 14:53:00 +02:00
parent f448ed429f
commit e1a49398ab

View file

@ -4,25 +4,30 @@ var rss = [
var MAX_RSS = 5;
$(document).ready(function() {
var addItem = function(title, link, date) {
var addItem = function(title, link, date, text) {
var item = $('<a>')
.attr('class', 'css-truncate')
.attr('href', link)
.attr('target', '_blank')
.data('date', date)
.text(title);
$('#news').append($('<li>').append(item));
var prev = $('<p>')
.attr('class', 'css-truncate')
.html(text);
$('#news').append($('<li>').append(item).append(prev));
};
var getAddedItems = function() {
var news = [];
$('#news').find('a').forEach(function(item) {
var a = $(item);
$('#news').find('li').forEach(function(item) {
var a = $(item).children('a');
var p = $(item).children('p');
var title = a.text();
var link = a.attr('href');
var date = a.data('date');
var text = p.html();
news.push({title:title, link:link, date:date});
news.push({title:title, link:link, date:date, text:text});
});
return news;
};
@ -48,7 +53,7 @@ $(document).ready(function() {
var i = 0;
items.forEach(function(item) {
if(i++ >= MAX_RSS) return;
addItem(item.title, item.link, item.date);
addItem(item.title, item.link, item.date, item.text);
});
};
@ -60,16 +65,18 @@ $(document).ready(function() {
var title = $(entry).find('title').text();
var link = $(entry).find('link').text();
var date = $(entry).find('pubDate').text();
var text = $(entry).find('description').text();
news.push({title:title, link:link, date:date});
news.push({title:title, link:link, date:date, text:text});
});
$(data).find('entry').forEach(function(entry) {
var title = $(entry).find('title').text();
var link = $(entry).find('link').attr('href');
var date = $(entry).find('published').text();
var text = $(entry).find('content').text();
news.push({title:title, link:link, date:date});
news.push({title:title, link:link, date:date, text:text});
});
updateNewsFeed(news);