google.load("feeds", "1");

function initialize() {
  var feedurl = "http://pipes.yahoo.com/pipes/pipe.run?URL=http%3A%2F%2Ffeedblog.ameba.jp%2Frss%2Fameblo%2Fmiya-curtain%2Frss20.xml&_id=DrFZRK663RGaE1sE1pzWFw&_render=rss";
  var feed = new google.feeds.Feed(feedurl);
  feed.setNumEntries(5);
  feed.load(dispfeed);

  function dispfeed(result){
    if (!result.error){
      var container = document.getElementById("feed");
      if (!container) return false;
      var htmlstr = "";
      htmlstr += "<ul>";
      for (var i = 0; i < result.feed.entries.length; i++) {
        var entry = result.feed.entries[i];
        htmlstr += '<li class="title">';
		var strdate = createDateString(entry.publishedDate);
        htmlstr += '<span class="cur_date">' + strdate + "</span>" ;
        htmlstr += '<a href="' + entry.link + '">' + '<span class="cur_title">' + entry.title + "</span>" + '</a>';
        htmlstr += "</li>";
		htmlstr += '<li class="content">';
		htmlstr +=  entry.contentSnippet.substr(0,50) + " ..." ;
		htmlstr += "</li>"
      }
      htmlstr += "</ul>";

       container.innerHTML = htmlstr;
    }else{
       alert(result.error.code + ":" + result.error.message);
    }
  }
}

function createDateString(publishedDate){
  var pdate = new Date(publishedDate);

  var pday = pdate.getDate();
  if (pday < 10) {pday = "0" + pday;}
  var pmonth = pdate.getMonth() + 1;
  if (pmonth < 10) {pmonth = "0" + pmonth;}
  var pyear = pdate.getFullYear();
  if (pyear < 2000) pyear += 1900;
  var phour = pdate.getHours();
  var pminute = pdate.getMinutes();
  var psecond = pdate.getSeconds();
  var strdate = pyear + "/" + pmonth + "/" + pday + "/" ;

  return strdate;
}

google.setOnLoadCallback(initialize);

