var displayMostRecent = 3;

function loadTranscripts(committee, number) {
        var counter = 0;

         if (number) {
                displayMostRecent = number;
                console.log("going to display transcripts: " + displayMostRecent);
        }

        $.get(committee + "/rss_en.xml", function (data) {
        $(data).find("item").each(function () {
          var el = $(this);
          counter = counter + 1;
          console.log(el.find("enclosure"));

          var thumbnail = "";
          if (el.find("enclosure").length > 0) {
                thumbnail = '<img class="listThumbnail" src="'+ committee + '/' + el.find("enclosure")[0].getAttribute("url") + '" alt="thumbnail"></img>';
          }
	  console.log("Thumbnail: " + thumbnail);

          if (counter <= displayMostRecent) {
          var txt = '<article class="listing listing--archive" id="' + el.find("guid").text() + '">'
		// TODO: use proper link! this is for testing only
		//+ '<a href="' + el.find("link").text() + '">' + '<img style="" src="TEST2/ENG_2019_10_01_AM_800kbps_NCH.jpg" />' + '</a>'
                + '<a href="' +committee+ '/' + el.find("link").text() + '">' + thumbnail + '</a>'
		+ '<h3 class="listing__title"><a href="' +committee+ '/' + el.find("link").text() + '">'  + el.find("description").text() + '</a></h3>'
                + '<p class="secondary"><time class="listing__published">'+ el.find("pubDate").text() + '</time></p>'
                + '</article>';

          $('#recentTranscripts').append(txt);
          }

    });
});

};

