// JavaScript Document var getFeeds = function(target, url, num) { var query = "select * from rss where url=\""+url+"\""; query = encodeURIComponent(query); $.getJSON("http://query.yahooapis.com/v1/public/yql?q="+query+"&format=json&callback=?", function(res){ var item = res.query.results.item; var html = ''; var container = document.getElementById(target); container.innerHTML += html; latestInfo(); }); }; var feed1 = new getFeeds("feed", 'http://blog.sdtc.ac.jp/feed', 5); function latestInfo() { var showNum = 5; var t02 = $('.tab02 ul').clone().html(); var t03 = $('.tab03 ul').clone().html(); var t04 = $('.tab04 ul').clone().html(); var tmp = $(''); tmp.css('display', 'none'); $('body').append(tmp); tmp.html( $('.latest li').sort(function(a, b){ var dtA = $(a).find('em').html(); var dtB = $(b).find('em').html(); dtA = dtA.split('.'); dtB = dtB.split('.'); var dateA = new Date(parseInt(dtA[0].substr(dtA[0].length - 4), 10), parseInt(dtA[1], 10) - 1, dtA[2]); var dateB = new Date(parseInt(dtB[0].substr(dtB[0].length - 4), 10), parseInt(dtB[1], 10) - 1, dtB[2]); return parseInt((dateB.getTime() - dateA.getTime() < 0)? -1 : ((dateB.getTime() - dateA.getTime() > 0)? 1 : 0)); }) ); tmp.find('li').each(function(i){ if(i >= showNum) { $(this).remove(); } }); $('.tab01 section').empty(); $('.tab01 section').append(tmp); tmp.fadeIn(); }