﻿/*google feed api*/
google.load("feeds", "1");
function initialize() {
  var feed = new google.feeds.Feed("http://pipes.yahoo.com/pipes/pipe.run?_id=2d74766196772595abe0382f3ca40cff&_render=rss&date=110830");
  feed.setNumEntries(10)
  feed.load(function(result) {
    if (!result.error) {
		
		var container = document.getElementById("importantFeed");
		var temp = '';
		//temp += '<li><strong><span class="infoListDate">2011/10/24</span><a href="http://ameblo.jp/barvillage2/entry-11053548675.html" target="_blank">【重要】サービス終了のお知らせ(10/24追記)</a></strong></li>';
		for (var i = 0; i < result.feed.entries.length; i++) {
			var fDate = createDateString(result.feed.entries[i].content);
			temp += '<li><span class="infoListDate">';
			temp += fDate;
			temp += '</span><a href="';
			temp += result.feed.entries[i].link;
			temp += '" target="_blank">';
			temp += result.feed.entries[i].title;
			temp += '</a></li>';			
		}
		
		container.innerHTML = temp;
    }
  });
}


/*日付フォーマット*/
function createDateString(publishedDate){
  /*var pdate = new Date(publishedDate);
  var pday = pdate.getDate();
  var pmonth = pdate.getMonth() + 1;
  var pyear = pdate.getFullYear();
  if (pmonth < 10 && pday < 10) {
  var strdate = pyear + "/0" + pmonth + "/0" + pday;
  }else if(pmonth < 10){
  var strdate = pyear + "/0" + pmonth + "/" + pday;
  }else if(pday < 10){
  var strdate = pyear + "/" + pmonth + "/0" + pday;
  }else{
  var strdate = pyear + "/" + pmonth + "/" + pday;
  }*/
  var pdate = publishedDate.split(" ");
  var edate = pdate[0].split("-");
  var pday = edate[2];
  var pmonth = edate[1];
  var pyear = edate[0];
  var strdate = pyear + "/" + pmonth + "/" + pday;
  
  return strdate;
}


google.setOnLoadCallback(initialize);
