//根据ID取得dom对象
function $(id) {
return document.getElementById(id);
}
//去掉末尾的符号
function myRTrim(str, trimStr)
{
var s = new String(str);
if (trimStr.indexOf(s.charAt(s.length-1)) != -1)
{
var i = s.length - 1;
while (i >= 0 && trimStr.indexOf(s.charAt(i)) != -1){i--;}
s = s.substring(0, i+1);
}
return s;
}
//-----------串联需要获取评论记数的日志,统一获取并返回填充页面-------------//
var _FeedbackCountStack = ""; //需要获取评论记数的文章ID列表
var _FeedbackCountResult = ""; //获取评论记数的结果
//添加需要获取记数的文章ID
function AddFeedbackCountStack(ID)
{
_FeedbackCountStack += ID + ",";
}
//获得记数
function LoadFeedbackCount()
{
//发出请求
SendRequest("/NewCount.aspx?FeedbackCountStack=" + _FeedbackCountStack);
}
//发送请求,并异步获取返回值,放入_FeedbackCountResult
var req;
function SendRequest(url)
{
if(window.XMLHttpRequest){
req = new XMLHttpRequest();
req.onreadystatechange = callback;
req.open("GET",url,true);
req.send(null);
}else if(window.ActiveXObject){
req=new ActiveXObject("Microsoft.XMLHTTP");
if(req){
req.onreadystatechange = callback;
req.open("GET",url,true);
req.send(null);
}
}
}
function callback(){
if(req.readyState==4){
if(req.status==200){
_FeedbackCountResult = req.responseText;
FillFeedbackCount();
}
}
}
//填充评论数显示
function FillFeedbackCount()
{
var myFeedbackResultArray = _FeedbackCountResult.split(",");
var TmpResult;
for(var i=0; i<myFeedbackResultArray.length; i++)
{
TmpResult = myFeedbackResultArray[i].split("=");
$("FeedbackCount_" + TmpResult[0]).innerHTML = TmpResult[1];//bug经常在这里。
}
}