📄 showtopic.js
字号:
var comments;
var tipBox;
function addComment(){
var author=$F("postAuthor");
var memo=$F("postMemo");
var id=$F("hidTopicId");
var date;
if(tipBox.using){
tipBox.setText(MultiLang.s157);
return;
}
if(author.trim().length==0 || memo.trim().length==0){
tipBox.setText(MultiLang.s158);
tipBox.show();
tipBox.hideAfterSeconds(3);
tipBox.using=false;
return;
}
tipBox.show();
tipBox.setText(MultiLang.s186);
var option={
parameters:"author="+escape(author)+"&memo="+escape(memo)+"&topicId="+id,
method:"post",
onSuccess:function(transport){
var response=transport.responseText;
//the xmlhttp return the server time if success
if(/^\d{4}-\d{1,2}-\d{1,2}/.test(response)){
date=response;
tipBox.setText(MultiLang.s160);
tipBox.hideAfterSeconds(3);
var dl=document.createElement("dl");
Element.addClassName(dl,"list");
var dt=document.createElement("dt");
dt.appendChild(document.createElementWithText("span",MultiLang.s187+(cc(comments)+1)+MultiLang.s188));
dt.appendChild(document.createElementWithText("span",MultiLang.s171+date));
dt.appendChild(document.createElementWithText("span",MultiLang.s30+author.escapeHTML2()));
var dd=document.createElementWithText("dd",memo.escapeHTML2());
dl.appendChild(dt);
dl.appendChild(dd);
comments.appendChild(dl);
if(!isie())comments.appendChild(document.createTextNode(""));
$("postAuthor").value=author="";
$("postMemo").value=memo="";
}
else{
tipBox.setText(response);
tipBox.hideAfterSeconds(3);
}
},
onFailure:function(transport){
tipBox.using=false;
tipBox.setText(MultiLang.s189+transport.status+MultiLang.s190+" [<a href='javascript:addComment();' style='color:blue;'>"+MultiLang.s11+"</a>]");
tipBox.clearDelay();
}
}
var request=new Ajax.Request("../ajax.aspx?s="+Math.random()+"&oper=addComment",option);
}
window.onload=function(){
var option={
parameters:"s="+Math.random()+"&oper=topicCount&topicId="+$F("hidTopicId"),
method:"get",
onSuccess:function(transport){
if($("hits")){$("hits").innerHTML=transport.responseText;}
}
}
new Ajax.Request("../ajax.aspx",option);
if(!$("postComment"))return;
comments=$("comments");
tipBox=new TipBox("",{});
$("postComment").insertBefore(tipBox.box,$("postComment").childNodes[ci(1)]);
$("btnPostComment").onclick=addComment;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -