varComment=newObject();
var$C=function(tagName)
{
returndocument.createElement(tagName);
};
String.prototype.trim=function()
{
returnthis.replace(/^s*|s*$/g,"");
};
String.prototype.realLength=function()
{
returnthis.replace(/[^x00-xff]/g,"**").length;
};
String.prototype.left=function(n)
{
if(this.length>n)
{
returnthis.substr(0,n)+'...';
}
else
{
returnthis;
}
};
Array.prototype.remove=function(n)
{
if(n<0)
{
returnthis;
}
else
{
returnthis.slice(0,n).concat(this.slice(n+1,this.length));
}
};
functionfindPosX(obj)
{
varcurleft=0;
if(obj&&obj.offsetParent)
{
while(obj.offsetParent)
{
curleft+=obj.offsetLeft;
obj=obj.offsetParent;
}
}
elseif(obj&&obj.x)curleft+=obj.x;
returncurleft;
}
functionfindPosY(obj)
{
varcurtop=0;
if(obj&&obj.offsetParent)
{
while(obj.offsetParent)
{
curtop+=obj.offsetTop;
obj=obj.offsetParent;
}
}
elseif(obj&&obj.y)curtop+=obj.y;
returncurtop;
}
varinput_domain='http://input.comment.qq.com';
varindex_domain='http://comment1.qq.com';
varpinglun_domain='http://pinglun.qq.com';
varjs_domain='http://pinglun.qq.com';
varimg_domain='http://mat1.qq.com/pinglun';
Comment.Configure={
version:'1.0',
newline:'n',
site_length:20,
key_length:20,
id_length:10,
index_line_sum:10000,
index_width:5,
default_mode:'origin_count',
default_order:1,
default_reply_per_page:10,
quote_str_len:60,
intro_len:150,
debate_intro_len:200,
content_len:200,
reply_default_title:'请填写标题',
intro_min_length:20,
request_delay:100,
login_frame_delay:2000,
reply_type_def:{
'1':'
'2':'
'3':'
},
postUrl:input_domain+'/post.cmt',
logoutUrl:input_domain+'/cgi-bin/qqlogout',
commentIndex:'http://pinglun.qq.com/',
loginIframeUrl:index_domain+'/i_login.htm',
defaultLogoUrl:img_domain+'/images/defpic.jpg'
}
Comment.Define={
getReplyType:function(type)
{
if(Comment.Configure.reply_type_def[type])
{
returnComment.Configure.reply_type_def[type];
}
else
{
return'';
}
}
}
Comment.PGV_Count=function(option)
{
if(typeof(pgvMain)=='function')
{
pvRepeatCount=1;
pvCurDomain=sDomain;
if(option)
{
if(option.domain)
{
pvCurDomain=option.domain;
}
if(option.path)
{
pvCurUrl=option.path;
}
}
pgvMain();
//Debug.log('callpgvfunction');
}
}
Comment.UrlFactory={
get3LevelDir:function(id)
{
varpath=parseInt(id/1000000)+'/';
path+=parseInt(id/1000)+'/';
path+=id/1;
returnpath;
},
getCommentUrl:function(id)
{
return(this.get3LevelDir(id)+'/');
},
getDebateUrl:function(id)
{
returnthis.get3LevelDir(id);
},
getUserUrl:function(id)
{
returnthis.get3LevelDir(id);
},
getReplyUrl:function(key)
{
varpath=key.substr(0,8);
path+='/'+(key.substr(8,4));
path+='/'+(key.substr(12,2));
path+='/'+key;
returnpath;
},
getIndexUrl:function(id)
{
varlength=id.toString().length;
if(length
for(vari=0;i
id='0'+id;
}
}
returnid;
},
getIndexDir:function(mode)
{
varmodes={
'origin_count':'originindex',
'total_count':'allindex',
'top_count':'topindex'
};
returnmodes[mode];
},
getRangeHeader:function(start,length,line_len)
{
varrange_start=start*line_len;
varrange_length=length*line_len;
return['Range','bytes='+range_start+'-'+(parseInt(range_start)+parseInt(range_length)-1-Comment.Configure.newline.length)];
},
getCommentNormalUrl:function(site,id)
{
return'comment.htm?site='+site+'&id='+id;
},
getCommentGroupUrl:function(site,id)
{
return'comment_group.htm?site='+site+'&id='+id;
},
getCommentDebateUrl:function(site,id)
{
return'comment_debate.htm?site='+site+'&id='+id;
},
getCommentUserUrl:function(uin)
{
return'comment_user.htm?uin='+uin;
},
getCommentUserLink:function(uin,nick)
{
return'
},
getCommentListLink:function(site_en,site_cn,sort_en,sort_cn,className)
{
if(className)
{
className='class="'+className+'"';
}
else
{
className='';
}
return'
+'
+'
}
}
Comment.ContentFormat={
decode:function(content)
{
returncontent.split(Comment.Configure.newline);
}
}
Comment.DataObjectFactory=function(content,model)
{
content=Comment.ContentFormat.decode(content);
vardataModel=Comment.DataObject[model];
if(content.length-1!=dataModel.length)
{
if(model!='commentinfo'&&model!='listsum')
{
//alert('[DEBUG信息]O/R映射失败,远程数据和本地模型数量不匹配!请检查!');
}
}
vardataObject=newObject();
for(vari=0;i
dataObject[dataModel[i]]=content[i];
}
returndataObject;
}
Comment.DataObject={
'commentinfo':
[
'site_cn',
'sort_en',
'sort_cn',
'source',
'source_url',
'title',
'url',
'intro',
'intro_img',
'group_id',
'intro_show',
'create_time',
'debate_id'
],
'groupinfo':
[
'site_cn',
'title',
'url',
'intro',
'intro_img',
'comment_id',
'intro_show',
'create_time'
],
'debateinfo':
[
'site_cn',
'title',
'url',
'intro',
'intro_img',
'agree_id',
'disagree_id',
'middle_id',
'intro_show',
'create_time'
],
'sum':
[
'origin_count',
'total_count',
'top_count'
],
'reply':
[
'comment_id',
'uin',
'nickname',
'pub_time',
'pass_time',
'ip',
'title',
'content',
'reply_key',
'is_del',
'reply_type',
'reply_kind',
'tips'
],
'pksum':
[
'agree',
'disagree',
'middle'
],
'listsum':
[
'all'
],
'usersum':
[
'total_count',
'top_count',
'is_expert'
],
'userinfo':
[
'user_img',
'user_intro'
]
}
/*控制器类*/
Comment.Control=newObject();
/*分页控制器*/
Comment.Control.Pagination=Class.create();
Comment.Control.Pagination.prototype={
initialize:function(option)
{
this.totalPage=option.totalPage;
this.currPage=1;
this.zoom_start=3;
this.zoom_end=613;
this.bindControl();
},
reset:function(option)
{
this.totalPage=option.totalPage;
this.currPage=1;
this.movePageControl(this.currPage);
},
updateOrder:function()
{
},
countCurrPage:function(offset)
{
varpage=parseInt(offset*this.totalPage/this.zoom_end)+1;
if(page>this.totalPage)
{
page=this.totalPage;
}
returnpage;
},
movePageControl:function(toPage)
{
if(toPage<1||toPage>this.totalPage)
{
return;
}
varoffset=0;
if(toPage==1)
{
offset=this.zoom_start;
}
elseif(toPage==this.totalPage)
{
offset=this.zoom_end;
}
else
{
offset=this.zoom_start+(toPage-1)*(this.zoom_end/(this.totalPage-1));
}
$('scrfloat').style.left=offset+'px';
//$('scrfloat_2').style.left=offset+'px';
},
bindControl:function()
{
varself=this;
vartooltip=$('Page_tip');
varoffsetX=10;
varoffsetY=-10;
functiongetSite(o)
{
varobj=o;
varobjS=obj.offsetLeft;
while(obj!=obj.offsetParent&&obj.offsetParent)
{
obj=obj.offsetParent;
if(obj.tagName=='span')
{
objS+=obj.offsetLeft;
}
}
returnobjS;
}
Event.observe($('scr'),'mousedown',mDown,false);
//Event.observe($('scr_2'),'mousedown',mDown,false);
varflag=false;
functionmDown()
{
flag=true;
if(window.event.srcElement.id!='scr'
&&window.event.srcElement.id!='scr_2')
{
$('scrfloat').style.left=$('scrfloat').offsetLeft;
//$('scrfloat_2').style.left=$('scrfloat').style.left;
}
else
{
$('scrfloat').style.left=(window.event.x-5);
//$('scrfloat_2').style.left=$('scrfloat').style.left;
}
tooltip.style.display='block';
t=$('scrfloat').offsetLeft;
tooltip.innerHTML=self.countCurrPage(t);
tooltip.style.left=window.event.clientX+offsetX+'px';
tooltip.style.top=window.event.clientY+offsetY+document.documentElement.scrollTop+'px';
}
functionmMove()
{
if(flag)
{
$('scrfloat').style.left=window.event.clientX-getSite($('scr'))-5+'px';
//$('scrfloat_2').style.left=window.event.clientX-getSite($('scr'))-5+'px';
}
if(parseInt($('scrfloat').style.left.replace('px',''))>self.zoom_end)
{
$('scrfloat').style.left=self.zoom_end+'px';
//$('scrfloat_2').style.left=$('scrfloat').style.left;
}
if(parseInt($("scrfloat").style.left.replace('px',''))
$('scrfloat').style.left=self.zoom_start+'px';
//$('scrfloat_2').style.left=$('scrfloat').style.left;
}
if(flag)
{
t=$('scrfloat').offsetLeft;
tooltip.innerHTML=self.countCurrPage(t);
tooltip.style.left=window.event.clientX+offsetX+'px';
tooltip.style.top=window.event.clientY+offsetY+document.documentElement.scrollTop+'px';
}
}
functionmUp()
{
if(flag)
{
t=$('scrfloat').offsetLeft;
self.setCurrPage(self.countCurrPage(t));
}
flag=false;
tooltip.style.display='none';
}
functionmEnd()
{
window.event.returnValue=false;
}
window.document.onmousemove=mMove;
window.document.ondragstart=mEnd;
window.document.onmouseup=mUp;
Event.observe($('up'),'click',mUpBtn,false);
Event.observe($('down'),'click',mDownBtn,false);
functionmUpBtn()
{
self.setCurrPage(self.currPage-1,1);
}
functionmDownBtn()
{
self.setCurrPage(self.currPage+1,1);
}
},
nextPage:function()
{
if(this.currPage
++this.currPage;
this.onPageChange();
}
},
previousPage:function()
{
if(this.currPage>0)
{
--this.currPage;
this.onPageChange();
}
},
setCurrPage:function(page,move)
{
if(page>0&&page<=this.totalPage&&page!=this.currPage)
{
this.currPage=page;
this.onPageChange();
if(move!=null)
{
this.movePageControl(page);
}
}
},
onPageChange:function()
{
},
getCurrPage:function()
{
returnthis.currPage;
}
}
Comment.Iterator={
getIndex:function(objComment)
{
varrangeList=newArray();
functiongetIndexId(reply_id)
{
returnparseInt(reply_id/Comment.Configure.index_line_sum);
}
functiongetReplyPos(reply_id)
{
return(reply_id%Comment.Configure.index_line_sum);
}
if(objComment.order==0)
{
varreply_start=(objComment.currPage-1)*objComment.replyPerPage;
varstart_index_id=getIndexId(reply_start);
varstart_reply_id=getReplyPos(reply_start);
varcurrReply=1;
varreplySum=0;
while(currReply++)
{
if(reply_start+currReply>objComment.totalReply)
{
rangeList.push({
url:Comment.UrlFactory.getIndexUrl(start_index_id),
range:Comment.UrlFactory.getRangeHeader(start_reply_id,currReply-replySum-1,objComment.index_line_len)
});
break;
}
if(currReply==objComment.replyPerPage)
{
rangeList.push({
url:Comment.UrlFactory.getIndexUrl(start_index_id),
range:Comment.UrlFactory.getRangeHeader(start_reply_id,currReply-replySum,objComment.index_line_len)
});
break;
}
if(start_reply_id+currReply>Comment.Configure.index_line_sum)
{
rangeList.push({
url:Comment.UrlFactory.getIndexUrl(start_index_id),
range:Comment.UrlFactory.getRangeHeader(start_reply_id,currReply,objComment.index_line_len)
});
start_index_id++;
start_reply_id=0;
replySum=currReply-1;
}
}
}
else
{
varreply_start=objComment.totalReply-1-(objComment.currPage-1)*objComment.replyPerPage;
varstart_index_id=getIndexId(reply_start);
varstart_reply_id=getReplyPos(reply_start);
varcurrReply=1;
varreplySum=0;
while(currReply++)
{
if(reply_start-currReply<0)
{
rangeList.push({
url:Comment.UrlFactory.getIndexUrl(start_index_id),
range:Comment.UrlFactory.getRangeHeader(0,start_reply_id+1,objComment.index_line_len)
});
break;
}
if(currReply==objComment.replyPerPage)
{
rangeList.push({
url:Comment.UrlFactory.getIndexUrl(start_index_id),
range:Comment.UrlFactory.getRangeHeader(start_reply_id-currReply+replySum+1,currReply-replySum,objComment.index_line_len)
});
break;
}
if(start_reply_id-currReply<0)
{
rangeList.push({
url:Comment.UrlFactory.getIndexUrl(start_index_id),
range:Comment.UrlFactory.getRangeHeader(0,start_reply_id+1,objComment.index_line_len)
});
start_index_id--;
start_reply_id=Comment.Configure.index_line_sum-1;
replySum=currReply;
}
}
}
returnrangeList;
}
}
/*显示样式控制器*/
Comment.Control.Display=Class.create();
Comment.Control.Display.prototype={
initialize:function()
{
}
}
/*页面显示类*/
Comment.Page=newObject();
/*评论页控制接口*/
Comment.Page.Base={
changeMode:function(mode)
{
this.mode=mode;
this.totalReply=this.data_sum[mode];
this.totalPage=parseInt(this.totalReply/this.replyPerPage)
+(this.totalReply%this.replyPerPage!=0?1:0);
},
changeOrder:function(order)
{
if(this.order==order)
return;
this.order=order;
this.currPage=1;
this.resetPageControl();
this.bindPageNav();
this.bindReplyList();
this.bindOrderControl();
},
bindOrderControl:function()
{
varself=this;
if(self.order==0)
{
$('order_front').style.cursor='none';
$('order_front').style.color='#000';
$('order_front').onclick=function(e)
{
returnfalse;
}
$('order_desc').style.cursor='pointer';
$('order_desc').style.color='#3B78AF';
$('order_desc').onclick=function()
{
self.changeOrder(1);
returnfalse;
}
}
elseif(self.order==1)
{
$('order_front').style.cursor='pointer';
$('order_front').style.color='#3B78AF';
$('order_front').onclick=function(e)
{
self.changeOrder(0);
returnfalse;
}
$('order_desc').style.cursor='none';
$('order_desc').style.color='#000';
$('order_desc').onclick=function()
{
returnfalse;
}
}
},
bindRowsPerPage:function()
{
varself=this;
$A($('rows_page').getElementsByTagName('a')).each(function(button)
{
button.onclick=function()
{
self.replyPerPage=button.value;
self.currPage=1;
self.resetPageControl();
self.bindPageNav();
self.bindReplyList();
returnfalse;
}
});
},
selectTab:function(mode)
{
varself=this;
$A($('mode_tab').getElementsByTagName('p')).each(function(tab)
{
if(tab.value==mode)
{
$A($('mode_tab').getElementsByTagName('p')).each(function(t)
{
if(t.value!='')
{
t.className='none';
}
});
tab.className='c';
}
});
},
appendTab:function(option)
{
varpTab=$C('p');
pTab.innerHTML=option.title;
pTab.value='';
$('mode_tab').appendChild(pTab);
pTab.onclick=function()
{
window.open(option.url);
}
returnfalse;
},
bindTabControl:function()
{
varself=this;
$A($('mode_tab').getElementsByTagName('p')).each(function(tab)
{
varmode=tab.value;
if(mode!='')
{
tab.onclick=function()
{
$A($('mode_tab').getElementsByTagName('p')).each(function(t)
{
t.className='none';
});
this.className='c';
self.currPage=1;
self.changeMode(mode)
self.resetPageControl();
self.bindPageNav();
self.bindReplyList();
returnfalse;
}
}
});
},
bindPageRandom:function()
{
varself=this;
$A($('page_random','page_random_2')).each(function(button)
{
button.onclick=function()
{
if(self.totalPage==1)
{
self.currPage=1;
}
else
{
self.currPage=Math.floor(Math.random()*(self.totalPage+1));
if(self.currPage==0)
{
self.currPage=1;
}
}
self.bindPageNav();
self.bindReplyList();
returnfalse;
}
});
},
bindPageNav:function(flag)
{
varself=this;
varcurrPage=self.currPage;
if(flag!=1)
{
this.pageControl.movePageControl(currPage);
}
varpagesPerRange=6;
this.totalPage=parseInt(this.totalReply/this.replyPerPage)
+(this.totalReply%this.replyPerPage!=0?1:0);
varstartPage=parseInt((self.currPage-1)/pagesPerRange)*pagesPerRange+1;
createPageNav($('page_nav'),false);
createPageNav($('page_nav_2'),true);
functioncreatePageNav(obj,top)
{
obj.innerHTML='';
vari=startPage;
if(self.currPage!=1)
{
obj.appendChild(createPage2(1,'第一页',top));
obj.appendChild(createPage({
page:'上一页',
onclick:function()
{
self.currPage=self.currPage-1;
self.bindPageNav();
self.bindReplyList();
if(top)
{
window.location.replace('#reload');
}
returnfalse;
}
}));
}
for(;i
if(i>self.totalPage)
{
break;
}
obj.appendChild(createPage2(i,'',top));
}
if(self.currPage
obj.appendChild(createPage({
page:'下一页',
onclick:function()
{
self.currPage=self.currPage+1;
self.bindPageNav();
self.bindReplyList();
if(top)
{
window.location.replace('#reload');
}
returnfalse;
}
}));
obj.appendChild(createPage2(self.totalPage,'最末页',top));
}
}
functioncreatePage(option)
{
varp=$C('a');
if(option.page==self.currPage)
{
p.style.fontWeight='bold';
}
p.innerHTML=(option.text&&option.text!='')?option.text:option.page;
p.href='';
p.onclick=option.onclick;
if(option.title)
{
p.title=option.title;
}
returnp;
}
functioncreatePage2(page,text,top)
{
returncreatePage({
page:page,
onclick:function()
{
self.currPage=page;
self.bindPageNav();
self.bindReplyList();
if(top)
{
window.location.replace('#reload');
}
returnfalse;
},
text:text!=''?text:''
});
}
},
bindPageControl:function()
{
this.totalPage=parseInt(this.totalReply/this.replyPerPage)
+(this.totalReply%this.replyPerPage!=0?1:0);
this.pageControl=newComment.Control.Pagination({
totalPage:this.totalPage
});
/*overwriteeventvirtualfunction*/
varself=this;
this.pageControl.onPageChange=function()
{
self.currPage=this.getCurrPage();
self.bindPageNav(1);
self.bindReplyList();
}
},
resetPageControl:function()
{
this.totalPage=parseInt(this.totalReply/this.replyPerPage)
+(this.totalReply%this.replyPerPage!=0?1:0);
this.pageControl.reset({
totalPage:this.totalPage
});
},
bindTopReply:function()
{
varself=this;
varrangeList=newArray();
functiongetIndexId(reply_id)
{
returnparseInt(reply_id/Comment.Configure.index_line_sum);
}
functiongetReplyPos(reply_id)
{
return(reply_id%Comment.Configure.index_line_sum);
}
vartop_show_sum=5;
varindex_line_len=self.index_line_len;
varreply_start=self.data_sum['top_count']-1;
varstart_index_id=getIndexId(reply_start);
varstart_reply_id=getReplyPos(reply_start);
varcurrReply=1;
varreplySum=0;
while(currReply++)
{
if(reply_start-currReply<0)
{
rangeList.push({
url:Comment.UrlFactory.getIndexUrl(start_index_id),
range:Comment.UrlFactory.getRangeHeader(0,start_reply_id+1,index_line_len)
});
break;
}
if(currReply==top_show_sum)
{
rangeList.push({
url:Comment.UrlFactory.getIndexUrl(start_index_id),
range:Comment.UrlFactory.getRangeHeader(start_reply_id-currReply+replySum+1,currReply-replySum,index_line_len)
});
break;
}
if(start_reply_id-currReply<0)
{
rangeList.push({
url:Comment.UrlFactory.getIndexUrl(start_index_id),
range:Comment.UrlFactory.getRangeHeader(0,start_reply_id+1,index_line_len)
});
start_index_id--;
start_reply_id=Comment.Configure.index_line_sum-1;
replySum=currReply;
}
}
varreplyList=newArray();
varreplyAllList=newArray();
varrangeSum=rangeList.length;
for(vari=0;i
newgetReplyList(i);
}
functiongetReplyList(i)
{
varcomment_type='normal';
varcomment_id=self.commentId;
if(self.name=='Group')
{
comment_type='group';
comment_id=self.groupId;
}
varsCommentIndexUrl='/'+self.site+'/'+comment_type+'/'
+Comment.UrlFactory.getCommentUrl(comment_id)
+Comment.UrlFactory.getIndexDir('top_count')
+'/'
+rangeList[i].url
+'.htm'+noCacheUrl();
newAjax.Request(
sCommentIndexUrl,
{
method:'get',
asynchronous:true,
onSuccess:onSucc,
onFailure:onError,
requestHeaders:rangeList[i].range
}
);
functiononSucc(response)
{
replyList[i]=Comment.ContentFormat.decode(response.responseText);
if(i==rangeSum-1)
{
replySort();
self.bindReplyList();
}
}
functiononError()
{
}
}
functionreplySort()
{
if(self.order==0)
{
if(replyList.length==1)
{
replyAllList=replyAllList.concat(replyList[0]);
}
else
{
for(vari=0;i
replyAllList=replyAllList.concat(replyList[i]);
}
}
}
else
{
if(replyList.length==1)
{
for(vari=replyList[0].length-1;i>=0;--i)
{
replyAllList.push(replyList[0][i])
}
}
else
{
for(vari=0;i
for(varj=replyList[i].length-1;j>=0;--j)
{
replyAllList.push(replyList[i][j])
}
}
}
}
varstr='';
for(varj=0;j
str+=replyAllList[j]+'rn';
}
self.topReplyList=replyAllList;
}
}
}
Comment.User={
logined:null,
uin:null
}
Comment.Post={
init:function(option)
{
this.base=option.base;
this.option=option;
this.initAsyncForm();
this.bindPostTypeSelector();
this.bindOtherEvent();
this.bindPostBtn();
this.bindBottomPostBtn();
this.bindBottomTitleEvent();
this.bindBottomPostTypeEvent();
this.setDefault();
},
bindOpenPostBtn:function(btn,c_id)
{
$(btn).onclick=function()
{
Comment.Post.beforeOpenPost(0,'',c_id);
returnfalse;
}
},
formElem:[
'b_anonymous',
'c_id',
'c_site',
'c_sort',
'c_title',
'c_content',
'r_key',
'r_type',
'r_tips',
'g_id'
],
initAsyncForm:function()
{
varformElem=this.formElem;
varform=$C('form');
form.id='post_form';
$A(formElem).each(function(elem_name)
{
varelem=$C('input');
elem.type='hidden';
elem.name=elem_name;
elem.value='';
form.appendChild(elem);
});
document.getElementsByTagName('body')[0].appendChild(form);
},
clearAsyncForm:function()
{
$A($('post_form').getElementsByTagName('input')).each(function(elem)
{
elem.value='';
});
},
setDefault:function()
{
$('stat_post_type').innerHTML='非匿名发表';
},
bindOtherEvent:function()
{
if(!$('r_quote_del'))
{
return;
}
/*引用事件*/
$('r_quote_del').onclick=function()
{
$('r_quote').style.display='none';
returnfalse;
}
/*选择回复立场*/
$A($('reply_type').getElementsByTagName('input')).each(
function(radio)
{
if(radio.value=='middle')
{
radio.checked=true;
}
radio.onclick=function()
{
if(this.value=='agree')
{
$('stat_reply_type').innerHTML='支持原帖';
makeFormValue({r_type:'0'});
}
elseif(this.value=='disagree')
{
$('stat_reply_type').innerHTML='反对原帖';
makeFormValue({r_type:'1'});
}
else
{
$('stat_reply_type').innerHTML='中立态度';
makeFormValue({r_type:'2'});
}
}
});
/*选择辩论立场*/
$A($('debate_id').getElementsByTagName('input')).each(
function(radio)
{
radio.onclick=function()
{
if(this.value=='agree')
{
$('stat_debate_type').innerHTML='我是正方';
makeFormValue({c_id:Comment.Post.base.data_info.agree_id});
}
elseif(this.value=='disagree')
{
$('stat_debate_type').innerHTML='我是反方';
makeFormValue({c_id:Comment.Post.base.data_info.disagree_id});
}
elseif(this.value=='middle')
{
$('stat_debate_type').innerHTML='我是中立方';
makeFormValue({c_id:Comment.Post.base.data_info.middle_id});
}
}
});
},
setReplyType:function(type)
{
$A($('reply_type').getElementsByTagName('input')).each(
function(radio)
{
if(radio.value==type)
{
radio.click();
return;
/*
radio.checked=true;
vartype_num={
'agree':'0',
'disagree':'1',
'middle':'2'
};
makeFormValue({r_type:type_num[type]});
*/
}
else
{
radio.checked=false;
}
});
},
setDebate:function(type,c_id)
{
$A($('debate_id').getElementsByTagName('input')).each(
function(radio)
{
if(radio.value==type)
{
radio.checked=true;
makeFormValue({c_id:c_id});
}
else
{
radio.checked=false;
}
});
},
clearValue:function()
{
$A($(
'l_c_title',
'l_c_content'
)).each(
function(input)
{
input.value='';
});
},
bindTitleEvent:function()
{
vard_title=Comment.Configure.reply_default_title;
$('l_c_title').value=d_title;
$('l_c_title').onfocus=function()
{
if($('l_c_title').value==d_title)
{
$('l_c_title').value='';
}
}
$('l_c_title').onblur=function()
{
if($('l_c_title').value=='')
{
$('l_c_title').value=d_title;
}
}
},
bindBottomTitleEvent:function()
{
if(!$('b_c_title'))
{
return;
}
vard_title=Comment.Configure.reply_default_title;
$('b_c_title').value=d_title;
$('b_c_title').onfocus=function()
{
if($('b_c_title').value==d_title)
{
$('b_c_title').value='';
}
}
$('b_c_title').onblur=function()
{
if($('b_c_title').value=='')
{
$('b_c_title').value=d_title;
}
}
},
setPostTypeSelector:function(type)
{
if(type=='login_select')
{
$('l_login_frame').src='i_login.htm?l_login_frame';
showElement('l_login_post');
$('stat_post_type').innerHTML='登录发表';
$('l_b_tips').disabled=false;
$('l_b_tips').checked=false;
$('l_b_anonymous').checked=false;
}
elseif(type=='anonymous_select')
{
hideElement('l_login_post');
$('stat_post_type').innerHTML='匿名发表';
$('l_b_tips').disabled=true;
$('l_b_tips').checked=false;
$('l_b_anonymous').checked=true;
}
},
bindPostTypeSelector:function()
{
if(!$('l_b_anonymous'))
{
return;
}
$('l_b_anonymous').onclick=function()
{
if($('l_b_anonymous').checked)
{
Comment.Post.setPostTypeSelector('anonymous_select');
}
else
{
Comment.Post.setPostTypeSelector('login_select');
}
}
},
bindPostBtn:function()
{
if(!$('l_post_btn'))
{
return;
}
varself=this;
$('l_post_btn').onclick=function()
{
if(!getCookie('skey')&&!$('l_b_anonymous').checked)
{
alert('很抱歉,您尚未登录,请先登录');
return;
}
if($('l_c_title').value.length>32)
{
alert('很抱歉,标题不得超过32个字符');
return;
}
varc_content=$('l_c_content').value.trim();
if(c_content=='')
{
alert('很抱歉,请填写评论内容');
$('l_c_content').focus();
return;
}
elseif(c_content.realLength()>10000)
{
alert('很抱歉,评论内容不能超过10,000个字符(5,000个汉字)');
$('l_c_content').focus();
return;
}
if(self.base.min_len)
{
if(c_content.realLength()
alert('很抱歉,评论内容不能少于'+self.base.min_len+'个字符('+self.base.min_len/2+'个汉字)');
$('l_c_content').focus();
return;
}
}
makeFormValue(
{
b_anonymous:$('l_b_anonymous').checked?'1':'',
c_site:self.base.site,
c_sort:self.base.sort_en,
c_title:($('l_c_title').value==Comment.Configure.reply_default_title?'':$('l_c_title').value),
c_content:$('l_c_content').value,
g_id:self.base.comment_g_id,
r_tips:$('l_b_tips').checked?'1':''
});
self.postData();
returnfalse;
};
},
bindBottomPostBtn:function()
{
if(!$('b_post_btn'))
{
return;
}
varself=this;
$('b_post_btn').onclick=function()
{
if(!getCookie('skey')&&!$('b_b_anonymous').checked)
{
alert('很抱歉,您尚未登录,请先登录');
return;
}
if($('b_c_title'))
{
if($('b_c_title').value.length>32)
{
alert('很抱歉,标题不得超过32个字符');
$('b_c_title').focus();
return;
}
}
varc_content=$('b_c_content').value.trim();
if(c_content=='')
{
alert('很抱歉,请填写评论内容');
$('b_c_content').focus();
return;
}
elseif(c_content.realLength()>10000)
{
alert('很抱歉,评论内容不能超过10,000个字符');
$('b_c_content').focus();
return;
}
if(self.base.min_len)
{
if(c_content.realLength()
alert('书评内容不能少于'+self.base.min_len+'字符');
$('b_c_content').focus();
return;
}
}
makeFormValue(
{
b_anonymous:$('b_b_anonymous').checked?'1':'',
c_site:self.base.site,
c_sort:self.base.sort_en,
c_title:($('b_c_title').value==Comment.Configure.reply_default_title?'':$('b_c_title').value),
c_content:$('b_c_content').value,
g_id:self.base.comment_g_id,
c_id:self.base.commentId,
r_tips:$('b_b_tips').checked?'1':''
});
self.postData();
returnfalse;
};
},
bindBottomPostTypeEvent:function()
{
varself=this;
if(!$('b_b_anonymous'))
{
return;
}
if(self.base.name!='MiniNormal')
{
setTimeout(setBottomLocation,Comment.Configure.login_frame_delay);
}
functionsetBottomLocation()
{
$('b_login_frame').src='i_login.htm?b_login_frame';
}
$('b_b_anonymous').onclick=function()
{
if($('b_b_anonymous').checked)
{
hideElement('b_login_post');
with($('b_b_tips'))
{
disabled=true;
checked=false;
}
}
else
{
$('b_login_frame').src='i_login.htm?b_login_frame';
showElement('b_login_post');
$('b_b_tips').disabled=false;
}
if(self.base.name=='MiniNormal')
{
self.base.updateHeight();
}
}
},
postData:function()
{
showLoading('正在发送...');
varpost_form=$('post_form');
post_form.action=Comment.Configure.postUrl;
post_form.target='post_async';
post_form.method='post';
post_form.submit();
},
fastReplyWords:
[
[
'精彩,一针见血',
'观点独到',
'说得很对',
'你说得有道理'
],
[
'乱七八糟说什么',
'你说得没道理',
'简直是胡说八道'
]
],
fastReply:function(btn,type,r_key,c_id)
{
varself=this;
$('fastLayer').innerHTML='';
$('fastLayer').style.display='block';
$('fastLayer').style.left=findPosX(btn)+1+'px';
$('fastLayer').style.top=findPosY(btn)+20+'px';
varreplyWords=this.fastReplyWords[type];
for(vari=0;i
varword=$C('a');
word.innerHTML=replyWords[i];
word.href='#';
$('fastLayer').appendChild(word);
word.onclick=function()
{
replyPost(this.innerHTML);
returnfalse;
}
}
functionreplyPost(content)
{
makeFormValue(
{
b_anonymous:(getCookie('skey')?'':'1'),
c_id:c_id,
c_site:self.base.site,
c_sort:self.base.data_commentinfo.sort_en,
r_key:r_key,
r_type:(type==0?'3':'4'),
r_tips:'',
c_title:'',
c_content:content,
g_id:self.base.comment_g_id
});
self.postData();
}
},
onError:function(msg)
{
alert(msg);
},
onSucc:function()
{
varself=this;
setTimeout(reload,300);
functionreload()
{
self.base.reload();
window.location.replace('#reload');
}
},
clearBottomInput:function()
{
$A($(
'b_c_title',
'b_c_content'
)).each(function(elem)
{
if(elem)
{
elem.value='';
}
});
},
logout:function()
{
varurl=Comment.Configure.loginIframeUrl+'?l_login_frame';
if($('l_login_frame'))
{
$('l_login_frame').src=Comment.Configure.logoutUrl+'?url='+url;
}
if($('b_login_frame'))
{
$('b_login_frame').src=Comment.Configure.logoutUrl+'?url='+url;
}
},
callback:function(url)
{
hideLoading();
$('post_async').src='about:blank';
varcode=url.substr(url.indexOf('code=')+5);
if(code=='-')
{
code=-1;
}
code=code/1;
getFormValue('r_type');
if(code==-1&&Comment.Post.r_type>=3)
{
code=0;
}
varerrMsg='';
switch(code)
{
case-1:
errMsg='您的评论已提交审核,感谢您的参与!';
this.closePostLayer();
this.clearBottomInput();
break;
case0:
errMsg='发表成功,感谢您的参与!';
this.onSucc();
this.closePostLayer();
this.clearBottomInput();
break;
case1:
errMsg='很抱歉,您填写的内容不完整,请重新输入您的内容。';
break;
case2:
errMsg='很抱歉,您尚未登录或登录已经过期,请先登录。';
this.logout();
break;
case3:
errMsg='您的评论已提交审核,感谢您的参与!';
this.closePostLayer();
this.clearBottomInput();
break;
case4:
errMsg='您的IP地址已暂时被屏蔽。';
break;
case5:
errMsg='您的QQ号已暂时禁止在本评论系统发言。';
break;
case6:
errMsg='很抱歉,您的QQ号码和密码不匹配。';
break;
case7:
errMsg='很抱歉,系统繁忙,请稍候再试。';
break;
case8:
errMsg='很抱歉,您发表的频率太快,请稍后再试。';
break;
}
if(errMsg!='')
{
this.onError(errMsg);
}
},
openPostLayer:function()
{
$('sPost').style.top=document.documentElement.scrollTop+50;
$('sPost').style.left=300;
$('sLayer').style.height=document.documentElement.scrollHeight;
$('sLayer').oncontextmenu=function(){returnfalse};
$('sLayer').className='dis';
$('sPost').className='dis';
this.auto=setInterval(setAuto,200);
functionsetAuto()
{
$('sPost').style.top=document.documentElement.scrollTop+50;
}
},
closePostLayer:function()
{
if(!$('sLayer'))
{
return;
}
$('sLayer').oncontextmenu=function(){returntrue};
$('sLayer').className='undis';
$('sPost').className='undis';
clearInterval(this.auto);
this.clearAsyncForm();
this.clearValue();
Debug.log('clearAsyncForm');
},
beforeOpenPost:function(type,r_key,c_id,content)
{
/*type->发表评论的方式
0:普通评论的回复
1:普通评论的引用回复
2:辩论评论的回复
*/
this.bindTitleEvent();
$('post_article').innerHTML=this.base.comment_title.left(20);
if(getCookie('skey'))
{
this.setPostTypeSelector('login_select');
}
else
{
this.setPostTypeSelector('anonymous_select');
}
$('l_b_tips').checked=false;
switch(type)
{
case0:
hideElement('debate_id','reply_type','r_quote');
makeFormValue(
{
c_id:c_id
});
break;
case1:
hideElement('debate_id');
$('post_quote').innerHTML=(content).stripTags();
showElement('r_quote','reply_type');
this.setReplyType('middle');
$('stat_reply_type').innerHTML='中立态度';
makeFormValue(
{
r_key:r_key,
r_type:'2',
c_id:c_id
});
break;
case2:
hideElement('reply_type','r_quote');
showElement('debate_id');
break;
}
this.openPostLayer();
}
}
varNDEBUG=true;
varDebug={
init:function()
{
if(NDEBUG==true)
{
return;
}
vardivDebug=$C('div');
this.divDebug=divDebug;
with(divDebug.style)
{
top='10px';
left='10px';
width='300px';
height='200px';
overflow='scroll';
verticalAlign='top';
position='absolute';
backgroundColor='#fff';
padding='5px';
lineHeight='110%';
}
document.getElementsByTagName('body')[0].appendChild(divDebug);
this.auto=setInterval(setAuto,200);
functionsetAuto()
{
divDebug.style.top=document.documentElement.scrollTop+10;
}
Debug.log('Debug');
divDebug.ondblclick=function()
{
NDEBUG=true;
Element.remove(divDebug);
}
this.height=0;
},
log:function(str)
{
if(NDEBUG==true)
{
return;
}
varnow=newDate();
this.divDebug.innerHTML+='['+now.getHours()+':'
+now.getMinutes()+':'
+now.getSeconds()+']'+str+'
';
this.divDebug.scrollTop=10000000;
}
}
vardivLoading=null;
functionshowLoading(action)
{
if(!divLoading)
{
divLoading=$C('div');
divLoading.className='loading';
document.getElementsByTagName('body')[0].appendChild(divLoading);
}
if(!action)
{
divLoading.innerHTML='正在读取...';
}
else
{
divLoading.innerHTML=action;
}
divLoading.style.top=document.documentElement.scrollTop;
divLoading.style.left='0px';
divLoading.style.display='block';
}
functionhideLoading()
{
if(!divLoading)
{
return;
}
divLoading.style.display='none';
}
functionshowElement()
{
for(vari=0;i
varelement=arguments[i];
if($(element))
{
$(element).style.display='block';
}
}
}
functionhideElement()
{
for(vari=0;i
varelement=arguments[i];
if($(element))
{
$(element).style.display='none';
}
}
}
functiongetFormValue(name)
{
$A($('post_form').getElementsByTagName('input')).each(function(elem)
{
if(elem.name==name)
{
Comment.Post.r_type=elem.value;
returnelem.value;
}
else
{
returnnull;
}
});
}
functionmakeFormValue(name2Value)
{
Debug.log('makeFormValuestart');
$A($('post_form').getElementsByTagName('input')).each(function(elem)
{
if(name2Value[elem.name]!=null)
{
elem.value=name2Value[elem.name];
}
Debug.log(elem.name+':'+elem.value);
});
Debug.log('makeFormValueend');
}
functionnoCacheUrl()
{
return'?cache='+rndNum(9);
}
functionrndNum(n)
{
varrnd='1.';
for(vari=0;i
returnrnd;
}
varsUrl=window.location.href.toString();
varsDomain=sUrl.substring(7,sUrl.indexOf('/',7));
varsPath=sUrl.substring(sUrl.indexOf('/',7));
varsParam=sUrl.substring(sUrl.indexOf('?')+1);
if(sParam.indexOf('#')!=-1)
{
sParam=sParam.substr(0,sParam.indexOf('#'));
}
document.domain='qq.com';
varinitWith={
'comment':'Normal',
'i_comment':'MiniNormal',
'comment_group':'Group',
'comment_debate':'Debate',
'comment_reply_pk':'ReplyPK',
'comment_user':'UserReply',
'list':'List'
};
window.onload=function()
{
Comment.Start();
}
Comment.Start=function()
{
Debug.init();
for(varurlininitWith)
{
if(sUrl.indexOf('/'+url+'.htm')!=-1)
{
if(url=='list')
{
Comment.Page[initWith[url]].load(sUrl);
}
else
{
Comment.Page[initWith[url]].load(sParam.toQueryParams());
}
}
}
document.body.onclick=function()
{
if($('fastLayer'))
{
$('fastLayer').style.display='none';
}
}
}
Comment.HotList=
{
siteObject:{
'news':'新闻',
'ent':'娱乐',
'finance':'财经',
'tech':'科技',
'auto':'汽车',
'gamezone':'游戏',
'edu':'教育',
'book':'读书',
'lady':'女性',
'astro':'星座',
'sports':'体育',
'comic':'动漫',
'luxury':'时尚',
'joke':'笑话',
'cq':'重庆',
'xian':'西安',
'view':'说吧'
},
getRandomSite:function()
{
if(!this.siteArray)
{
this.siteArray=newArray();
for(varsite_eninthis.siteObject)
{
this.siteArray.push(site_en);
}
}
varsite_sum=this.siteArray.length;
varrnd_site=Math.floor(Math.random()*site_sum);
returnthis.siteArray[rnd_site];
},
bindTopHotList:function(container,site)
{
vartopSiteSum=6;
vartopSite=newObject();
if(site!='')
{
if(this.siteObject[site])
{
topSite[site]=this.siteObject[site];
topSiteSum--;
}
}
while(topSiteSum>0)
{
varrnd_site=this.getRandomSite();
if(topSite[rnd_site])
{
continue;
}
topSite[rnd_site]=this.siteObject[rnd_site];
topSiteSum--;
}
varhot_index=0;
varhot_header='';
varhot_body='';
for(varsite_enintopSite)
{
hot_header+='
'+topSite[site_en]+'
';hot_body+='';
hot_index++;
}
varhot_html='
- '+hot_header+' '+hot_body+'
$(container).innerHTML=hot_html;
for(varsite_enintopSite)
{
this.bindTopSite('Hot_Top_'+site_en,'/c/async_html/'+site_en+'_top.htm');
}
},
bindRightHotList:function(container,site)
{
vartopSiteSum=3;
vartopSite=newObject();
if(site!='')
{
if(this.siteObject[site])
{
topSite[site]=this.siteObject[site];
topSiteSum--;
}
}
while(topSiteSum>0)
{
varrnd_site=this.getRandomSite();
if(topSite[rnd_site])
{
continue;
}
topSite[rnd_site]=this.siteObject[rnd_site];
topSiteSum--;
}
varhot_body='';
for(varsite_enintopSite)
{
hot_body+='
- '+topSite[site_en]+'热评