diff --git a/js/main.js b/js/main.js index ef6800c..e159591 100644 --- a/js/main.js +++ b/js/main.js @@ -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 = $('') .attr('class', 'css-truncate') .attr('href', link) .attr('target', '_blank') .data('date', date) .text(title); - $('#news').append($('
  • ').append(item)); + var prev = $('

    ') + .attr('class', 'css-truncate') + .html(text); + $('#news').append($('

  • ').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);