var request=null;
var targetId="gameComment";
function getGameComments(pageNo, pageSize, resourceTypeId, resourceId){
	var url="/asych/gcs?pageNo="+pageNo+"&pageSize="+pageSize+"&resourceTypeId="+resourceTypeId+"&resourceId="+resourceId;
	$.getJSON(url,function(data){writeHtml(data);}); 
}

function writeHtml(data){
	var list=data.model.comments;
	var size=list.length;
	var str="";  
	for(var i=0; i<size; i++){
		var channel="";
        var version="";
		var comment=list[i];
		str=str + "<li><div class=\"head\">" + "<img src=\"http://img.d.cn:9000/images/new_image/android/guest.png\" alt=\"1楼\" />"
		if(comment.showName == null || comment.showName == ""){
			str=str + "匿名";
		}else{
			str=str + comment.showName;
		}
        if(comment.version != null && comment.version!=""){
            version = "v" + comment.version;
        }
        if(comment.channelFlag == 2){
            channel="来自 手机用户";
        }else if(comment.channelFlag == 4){
            channel="来自 <a href=\"/software/374.html\" target=\"_blank\">地瓜游戏中心</a>"+version;
        }
		str=str + "</div><div class=\"body\"><span>";
		str=str + dateStr(comment.createdDate, "yy-mm-dd hh:mi:ss", false);
		str=str + "&nbsp;</span>";
		str=str + "<em>" + comment.floor + "</em>" + "<p>" + comment.comment + "</p>";
        str=str + "<div class=\"channel\">"+channel+"</div>"
		str=str + "<a href=\"#reply\" onclick=\"replyComment('comment', '" + comment.floor + "');\">回复</a><div class=\"star star"+ (comment.stars - 1) + "\"></div></div></li>"
	}
	document.getElementById(targetId).innerHTML=str;
}

function dateStr(date) {
	var str="";
	str = str + (date.year+1900) + "-";

	if(date.month < 9){
		str = str + "0" + (date.month + 1) + "-";
	}else{
		str=str + (date.month + 1) + "-";
	}

	if(date.date < 10){
		str = str + "0" + (date.date) + " ";
	}else{
		str=str + (date.date) + " ";
	}

	if(date.hours < 10){
		str = str + "0" + (date.hours) + ":";
	}else{
		str=str + (date.hours) + ":";
	}

	if(date.minutes < 10){
		str = str + "0" + (date.minutes) + ":";
	}else{
		str=str + (date.minutes) + ":";
	}

	if(date.seconds < 10){
		str = str + "0" + (date.seconds) + " ";
	}else{
			str=str + (date.seconds) + " ";
	}
	return str;
}

