Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. $.jGFeed(
  2. href,
  3. function(feeds){
  4.  
  5. if(!feeds) {
  6. container.append('Error fetching feed');
  7. return false;
  8. }
  9.  
  10.  
  11. container.hide();
  12. container.removeClass('loading');
  13. container.append('<h2>' + feeds.title + '</h2>');
  14.  
  15. //process feed entries
  16. for(var i=0; i<feeds.entries.length; i++){
  17. var entry = feeds.entries[i];
  18.  
  19. //build html string for entry
  20. var html = '<div class ="ajax-feed-item">';
  21. html += '<h3><a href="" + entry.link + "">';
  22. html += entry.title + '</a></h3>';
  23. html += '<div class="ajax-feed-date">';
  24. html += entry.publishedDate + '</div>';
  25. html += '<div class="ajax-feed-author">';
  26. html += entry.author + '</div>';
  27. html += '<div class="ajax-feed-content-snippet">';
  28. html += entry.contentSnippet + '</div>';
  29. html += '<div id="ajax-feed-content-' +i;
  30. html += '" class-"ajax-feed-content" ';
  31. html += 'style="height:0px; overflow:hidden;">';
  32. html += entry.content + '</div>';
  33. html += '<div><a class="ajax-feed-readmore" ';
  34. html += 'href="' + i + '">+</a></div>';
  35.  
  36.  
  37.  
  38. html += '</div>';
  39.  
  40. container.append(html);
  41.  
  42. }
  43. $('a.ajax-feed-readmore').click(function(e){
  44. e.preventDefault();
  45.  
  46. var content_id = $(this).attr('href');
  47. var div_id = 'ajax-feed-content-' + content_id;
  48. var content_div = $('#' + div_id);
  49. var content_txt = content_div.html();
  50. var snippet_div = content_div.prev();
  51. var snippet_txt = snippet_div.html();
  52.  
  53. content_div.html(snippet_txt);
  54.  
  55. snippet_div.html(content_txt);
  56.  
  57. if ($(this).html() === '-')
  58. {
  59. $(this).html('+');
  60. }
  61. else
  62. {
  63. $(this).html('-');
  64. }
  65. });
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72. container.show('slow');
  73.  
  74. },
  75. 10
  76. );//end jGfeed
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement