$(function(){ get_oshirase_rdf("#oshirase_list", "/api/rss/getCrossDomainFile.php?uri=http://tamonohiroba.jp/oshirase/category/information/?feed=rdf"); get_cotonoha_rdf("#cotonoha_update_list", "/api/rss/getCrossDomainFile.php?uri=http://tamonohiroba.jp/cotonoha/?feed=rdf"); get_blog_rdf("#blog_update_list", "/api/rss/getCrossDomainFile.php?uri=http://tamonohiroba.jugem.jp/?mode=rss"); get_schedule_info("#schedule_update_list", "/api/schedule/getSchedule.php"); }); function get_blog_rdf(target_id, src_uri){ $.ajax({ url: src_uri,//RSSファイル名 async: true, cache: false, dataType:"xml", success: function(xml){ $(xml).find('item').each(function(i){ if ( i > 4 ) { // 取得件数 - 1 return false; } var title = $(this).find('title').text(); var url = $(this).find('link').text(); //日付を整形 var date; $(this).children().each(function(){ if ($(this)[0].tagName == "dc:date") { date = $(this).text(); } }); date = dateParse_rdf(date); //"2008/10/14 タイトル" の形式で出力 $(target_id).append('
  • '+date+'
    '+title+'
  • '); }); } }); } function get_oshirase_rdf(target_id, src_uri){ $.ajax({ url: src_uri,//RSSファイル名 async: true, cache: false, dataType:"xml", success: function(xml){ $(xml).find('item').each(function(i){ var title = $(this).find('title').text(); //日付を整形 var date; $(this).children().each(function(){ if ($(this)[0].tagName == "dc:date") { date = $(this).text(); } }); date = dateParse_rdf(date); //コンテンツを取得 var content; $(this).children().each(function(){ if ($(this)[0].tagName == "content:encoded") { content = $(this).text(); } }); //コンテンツを出力 $(target_id).append('
    '+content+'

    '); }); } }); } function get_cotonoha_rdf(target_id, src_uri){ $.ajax({ url: src_uri,//RSSファイル名 async: true, cache: false, dataType:"xml", success: function(xml){ $(xml).find('item').each(function(i){ if ( i > 4 ) { // 取得件数 - 1 return false; } var url = $(this).find('link').text(); var title = $(this).find('title').text(); //日付を整形 var date; $(this).children().each(function(){ if ($(this)[0].tagName == "dc:date") { date = $(this).text(); } }); date = dateParse_rdf(date); //"2008/10/14 タイトル" の形式で出力 $(target_id).append('
  • '+date+'
  • '); }); } }); } function get_schedule_info(target_id, src_uri){ $.ajax({ url: src_uri, async: true, cache: false, dataType:"xml", success: function(xml){ $(xml).find('item').each(function(i){ if ( i > 4 ) { // 取得件数 - 1 return false; } var title = $(this).find('title').text(); var item_id = $(this).find('item_id').text(); var date = $(this).find('date').text();; //"2008/10/14 タイトル" の形式で出力 $(target_id).append('
  • '+date+'
  • '); }); } }); } //dateParse: "2008/10/14" 形式 function dateParse_rdf(str){ str = str.replace(/-/g, "/"); str = str.replace(/T/g, " "); str = str.replace(/\+.*$/, ""); str = str.replace(/Z.*$/, ""); var objDate = new Date(str); var year = objDate.getFullYear(); var month = objDate.getMonth() + 1; var date = objDate.getDate(); str = year + '/' + month + '/' + date; return str; }