ほるメモいんぶろ - 投稿一覧ソース
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ほるメモいんぶろ - 投稿一覧</title>
<style type="text/css">
* {
font-family: "MS Pゴシック";
font-size: 12px;
}
/* ヘッダとデータの クラス */
.myVhtd {
color:#FFFFFF;
background: #000000;
padding: 7px!important;
border-style: solid;
border-color: #A0A0A0;
border-width: 1px;
}
.myVtd {
padding: 7px!important;
border-style: solid;
border-color: #A0A0A0;
border-width: 1px;
}
</style>
<script type="text/javascript" src="http://www.google.com/jsapi" charset="utf-8">
</script>
<script type="text/javascript">
google.load("gdata", "1");
google.load('visualization', '1', { packages: ['table'] });
</script>
</head>
<body>
<h2 id="blog_title"></h2>
<div id="table_area"></div>
<script type="text/javascript">
var bloggerService = new google.gdata.blogger.BloggerService('GoogleInc-jsguide-1.0');
var feedUri = 'http://holmes21.blogspot.com/atom.xml';
// 正常処理
var handleBlogPostFeed = function(postsFeedRoot) {
// タイトル生成
var blogTitle = document.getElementById('blog_title');
blogTitle.innerHTML = "ブログタイトル:" + postsFeedRoot.feed.getTitle().getText();
var data;
var visualization;
// テーブル用データ作成
data = new google.visualization.DataTable();
// カラム作成
data.addColumn('string', '更新日');
data.addColumn('string', 'タイトル');
data.addColumn('string', 'ページアドレス');
data.addColumn('string', '内容');
var posts = postsFeedRoot.feed.getEntries();
// 投稿テーブル一覧生成
for (var i = 0, post; post = posts[i]; i++) {
// 日付生成
var blogUpdated = post.getUpdated().getValue().getDate();
var aData = blogUpdated.toString().split(" ");
aData[0] = exChangeDay(aData[0]);
aData[1] = exChangeMonth(aData[1]);
var postDate = aData[3] + '/' + aData[1] + '/' + aData[2] + aData[0] + ' ' + aData[4];
// 投稿タイトル
var postTitle = post.getTitle().getText();
// 一部ページアドレス
var postURL = post.getHtmlLink().getHref();
var URLLength = 'http://holmes21.blogspot.com/'.length;
postURL = postURL.substr(URLLength, postURL.length-URLLength);
// 内容取得
var postContent = post.getContent().getText();
// 一行追加
data.addRow();
data.setCell(i, 0, postDate );
data.setCell(i, 1, postTitle );
data.setCell(i, 2, postURL );
data.setCell(i, 3, postContent );
}
// テーブル作成
visualization =
new google.visualization.Table(
document.getElementById('table_area')
);
// テーブルにデータを適用
visualization.draw(data,
{showRowNumber: true
, sortColumn:0
, sortAscending:false
, cssClassNames: {
tableCell: 'myVtd',
headerCell: 'myVhtd'
}
});
};
// エラー処理
var handleError = function(error) {
var objul = document.getElementsByTagName("ul").item(0);
objul.id = "home";
objul.title = "表示エラー";
objul.innerHTML = "表示エラーです";
};
// ここで実行
bloggerService.getBlogPostFeed(feedUri, handleBlogPostFeed, handleError);
// 曜日変換
function exChangeDay(day){
switch(day){
case "Sun":
day = "(日)";
break;
case "Mon":
day = "(月)";
break;
case "Tue":
day = "(火)";
break;
case "Wed":
day = "(水)";
break;
case "Thu":
day = "(木)";
break;
case "Fri":
day = "(金)";
break;
default:
day = "(土)";
}
return day;
}
// 月変換
function exChangeMonth(month){
switch(month){
case "Jan":
month = "01";
break;
case "Feb":
month = "02";
break;
case "Mar":
month = "03";
break;
case "Apr":
month = "04";
break;
case "May":
month = "05";
break;
case "Jun":
month = "06";
break;
case "Jul":
month = "07";
break;
case "Aug":
month = "08";
break;
case "Sep":
month = "09";
break;
case "Oct":
month = "10";
break;
case "Nov":
month = "11";
break;
default:
month = "12";
}
return month;
}
</script>
</body>
</html>