/*==============================================================================
	iBlog のためのシンプルな Recent Comments クラス

	$Id$
	Copyright (C) 2005 OKAMURA Yuji, All rights reserved.
==============================================================================*/
/*---- 静的属性 ----*/

/*---- 静的メソッド ----*/
/*
 * iBlog のための Haloscan による Recent Comments クラス(簡易表示版)<br>
 * @param URL,
 *        RSS Feed を書き出す HTML の DOM ノード
 *        ブログのベース URL
 */
function CRCHalo4iBlogSimple(url, welmt, async, blogBaseUrl) {
	/*---- 基底クラスのコンストラクタ ----*/
	this.CRCHalo4iBlog = CRCHalo4iBlog;
	this.CRCHalo4iBlog(url, welmt, async, blogBaseUrl);

	/*---- メソッド ----*/
	// 外部インターフェースを意図

	// 下位クラスで書き換えを意図

	/*
	 * RSS 出力用の HTML を生成する
	 * @param channel	channel 要素をハッシュ化したもの
	 * @return HTML を表す文字列
	 */
	this.RssHTML = CRCHalo4iBlogSimple_RssHTML;

	/*
	 * item 出力用の HTML を生成する
	 * @param itemIdx	何番目のアイテムか
	 * @param channel	channel 要素をハッシュ化したもの
	 * @return HTML を表す文字列
	 * コメントがブログのエントリに対するものでないときは空文字列
	 */
	this.ItemHTML = CRCHalo4iBlogSimple_ItemHTML;

	// このクラスおよび下位クラスでの使用を意図

	// このクラスでのみ使用を意図

}

function CRCHalo4iBlogSimple_RssHTML(channel) {
	var	html;
	var	i;
	var	cnt = 0;

	html = '';
	for (i = 0; i < channel['item'].length; i++) {
		var	itemHtml = this.ItemHTML(i, channel);

		if (itemHtml != '') {
			html += itemHtml;
			cnt++;
		}
	}

	if (cnt == 0) {
		html = this.m_NoCommentsMessage;
	}

	return html;
}

function CRCHalo4iBlogSimple_ItemHTML(itemIdx, channel) {
	var	html;
	var	hash;

	// コメントの属性を取得する
	hash = this.CommentAttr(channel['item'][itemIdx]['title']);
	if (!hash['categoryUUID']) return '';

	// アイテム(コメント)用の HTML を生成する。
	html = '<div>'
		+ '<a href="'
		+ this.m_BlogBaseURL
		+ hash['categoryUUID']
		+ '/'
		+ this.SafeHTMLAttrText(hash['thread'])
		+ '/index.html">'
		+ this.SafeHTMLText(hash['thread'])
		+ '</a>'
		+ ' : '
		+ '<a href="'
		+ this.CommentURL(this.SafeHTMLAttrText(
		  	channel['item'][itemIdx]['link']
		  ))
		+ '" title="'
		+ this.SafeHTMLAttrText(channel['item'][itemIdx]['description'])
		+ '">'
		+ this.SafeHTMLText(hash['post'])
		+ '</a>'
		+ '</div>'
	;

	return html;
}
