first commit
This commit is contained in:
@@ -0,0 +1,288 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<LabelType>评论类</LabelType>
|
||||
<LabelIntro>
|
||||
</LabelIntro>
|
||||
<OutType>txt</OutType>
|
||||
<LabelDataType>static</LabelDataType>
|
||||
<EnabelAjax>False</EnabelAjax>
|
||||
<Version officialVersion="" modifiedVersions="3000" compatibleVersion="" />
|
||||
<attributes>
|
||||
<name>nodeId</name>
|
||||
<datatype>int</datatype>
|
||||
<default>1</default>
|
||||
<intro>节点Id</intro>
|
||||
</attributes>
|
||||
<LabelTemplate>
|
||||
<![CDATA[
|
||||
<input type="hidden" id="commentViewpoint" value="1" />
|
||||
<input type="hidden" id="commentIsPrivate" value="0" />
|
||||
<input type="hidden" id="commentIsAnonymous" value="false" />
|
||||
<input type="hidden" id="commentRanking" value="3" />
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
|
||||
function $getE(obj) {
|
||||
return document.getElementById(obj);
|
||||
}
|
||||
|
||||
//初始化评论
|
||||
function commentInit() {
|
||||
var x = new AjaxRequest('XML', 'commentForm');
|
||||
x.labelname = "内容评论标签";
|
||||
x.para = ['itemId=@RequestInt_Id','nodeId=<xsl:value-of select="$nodeId"/>'];
|
||||
x.currentpage = 1;
|
||||
x.post('updatelabel', '{PE.SiteConfig.ajaxSitePath/}ajax.aspx', function(s) {
|
||||
var xml = x.createXmlDom(s);
|
||||
$getE('commentform').innerHTML = xml.getElementsByTagName("body")[0].firstChild.data;
|
||||
changepage(1, '评论列表', 'JS_基本风格');
|
||||
setCurrentUserInfo();
|
||||
});
|
||||
}
|
||||
|
||||
//添加评论
|
||||
function addComment() {
|
||||
if ($getE('commentTitle').value == '') {
|
||||
alert("请输入标题!");
|
||||
$getE("commentTitle").focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if ($getE('commentIsAnonymous').value == 'false') {
|
||||
if ($getE('commentUsername').value == '') {
|
||||
alert("请输入用户名!");
|
||||
$getE('commentUsername').focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if ($getE('commentEmail').value == '') {
|
||||
alert('请输入Email地址!');
|
||||
$getE('commentEmail').focus();
|
||||
return;
|
||||
}
|
||||
|
||||
var regEmail = /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
|
||||
if ($getE('commentEmail').value.match(regEmail) == null) {
|
||||
alert('请输入正确的Email格式!');
|
||||
$getE('commentEmail').focus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ($getE("commentContnet").value == '') {
|
||||
alert("请输入评论内容!");
|
||||
$getE("commentContnet").focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
var commentValidCode = "";
|
||||
var checkValidCode = false;
|
||||
if ($getE("commentValidCode") != null) {
|
||||
if ($getE("commentValidCode").value == '') {
|
||||
alert("请输入验证码!");
|
||||
$getE("commentValidCode").focus();
|
||||
return;
|
||||
}
|
||||
commentValidCode = $getE("commentValidCode").value;
|
||||
checkValidCode = true;
|
||||
}
|
||||
|
||||
var x = new AjaxRequest('XML', 'status');
|
||||
x.para = ['username=' + $getE("commentUsername").value, 'commenttitle=' + $getE("commentTitle").value, 'content=' + $getE("commentContnet").value, 'email=' + $getE("commentEmail").value, 'gid=@RequestInt_Id', 'nid=' + <xsl:value-of select="$nodeId"/>, 'private=' + $getE("commentIsPrivate").value, 'position=' + $getE("commentViewpoint").value, 'score=' + $getE("commentRanking").value, 'TxtValidCode=' + commentValidCode, 'isguest=' + $getE("commentIsAnonymous").value];
|
||||
x.paratype = ['nohtml', 'nohtml', 'nohtml']
|
||||
x.post('addcomment', '{PE.SiteConfig.ajaxSitePath/}ajax.aspx', function(s) {
|
||||
var xml = x.createXmlDom(s);
|
||||
var status = xml.getElementsByTagName("status")[0].firstChild.data;
|
||||
switch (status) {
|
||||
case "ok":
|
||||
changepage(1, '评论列表', 'JS_基本风格');
|
||||
alert("发表评论成功!");
|
||||
window.location.href = '#commentTarget';
|
||||
$getE("commentContnet").value = '';
|
||||
break;
|
||||
case "check":
|
||||
alert("发表评论成功,请等待管理员审核。");
|
||||
break;
|
||||
case "err":
|
||||
alert("发表评论失败!");
|
||||
break;
|
||||
case "nopurview":
|
||||
alert("此栏目已禁止发表评论!");
|
||||
break;
|
||||
case "noTourists":
|
||||
alert("此栏目已禁止游客发表评论!");
|
||||
break;
|
||||
case "checkCodeError":
|
||||
$getE("commentValidCode").value = '';
|
||||
refreshValidCode($getE("commentValidCodeImg"));
|
||||
alert("您输入的验证码和系统产生的不一致,请重新输入!");
|
||||
break;
|
||||
default:
|
||||
alert("发表评论失败!");
|
||||
break;
|
||||
}
|
||||
if (checkValidCode) {
|
||||
refreshValidCode($getE("commentValidCodeImg"));
|
||||
$getE("commentValidCode").value = '';
|
||||
checkValidCode = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addPkZone(commentid, position, content) {
|
||||
var x = new AjaxRequest('XML', 'status');
|
||||
x.para = ['commentid=' + commentid, 'position=' + position, 'content=' + content];
|
||||
x.post('addpkzone', '{PE.SiteConfig.ajaxsitepath/}ajax.aspx', function(s) {
|
||||
var xml = x.createXmlDom(s);
|
||||
var status = xml.getElementsByTagName("status")[0].firstChild.data;
|
||||
switch (status) {
|
||||
case "ok":
|
||||
changepage(1, '评论列表', 'JS_基本风格');
|
||||
break;
|
||||
default:
|
||||
alert("辩论失败!");
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//更新列表
|
||||
function changepage(pagenum, sourcename, spanname) {
|
||||
var x = new AjaxRequest('XML', 'pe100_' + sourcename);
|
||||
x.labelname = sourcename;
|
||||
x.currentpage = pagenum;
|
||||
x.para = ['itemId=@RequestInt_Id', 'outputQty=10', 'page=true', 'pagesize=10', 'currentpage=' + pagenum];
|
||||
x.post('updatelabel', '{PE.SiteConfig.ajaxSitePath/}ajax.aspx', function(s) {
|
||||
var xml = x.createXmlDom(s);
|
||||
var plstr = "";
|
||||
for (var i = 0; i < xml.getElementsByTagName("body")[0].childNodes.length; i++) {
|
||||
plstr += xml.getElementsByTagName("body")[0].childNodes[i].nodeValue;
|
||||
}
|
||||
$getE('pe100_' + sourcename).innerHTML = plstr;
|
||||
$getE('commentCount').innerHTML = xml.getElementsByTagName("total")[0].firstChild.data;
|
||||
updatepage(spanname, sourcename, xml);
|
||||
});
|
||||
}
|
||||
|
||||
//更新分页
|
||||
function updatepage(spanname, sourcename, xml) {
|
||||
if (parseInt(xml.getElementsByTagName("total")[0].firstChild.data) > 0) {
|
||||
var x = new AjaxRequest('XML', 'pe100_page_' + sourcename);
|
||||
x.labelname = spanname;
|
||||
x.sourcename = sourcename;
|
||||
x.total = xml.getElementsByTagName("total")[0].firstChild.data;
|
||||
x.currentpage = xml.getElementsByTagName("currentpage")[0].firstChild.data;
|
||||
x.pagesize = xml.getElementsByTagName("pagesize")[0].firstChild.data;
|
||||
x.post('updatepage', '{PE.SiteConfig.ajaxSitePath/}ajax.aspx', function(s) {
|
||||
var xml = x.createXmlDom(s);
|
||||
if ($getE('pe100_page_' + sourcename) != null) {
|
||||
var plstr = "";
|
||||
for (var i = 0; i < xml.getElementsByTagName("body")[0].childNodes.length; i++) {
|
||||
plstr += xml.getElementsByTagName("body")[0].childNodes[i].nodeValue;
|
||||
}
|
||||
$getE('pe100_page_' + sourcename).innerHTML = plstr;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//设置默用户信息
|
||||
function setCurrentUserInfo() {
|
||||
try {
|
||||
var x = new AjaxRequest('XML', '');
|
||||
x.post('logincheck', '{PE.SiteConfig.ajaxSitePath/}ajax.aspx', function(s) {
|
||||
var xml = x.createXmlDom(s);
|
||||
if (xml.getElementsByTagName("status")[0].firstChild.data == "ok") {
|
||||
if ($getE('commentUsername') != null) {
|
||||
$getE('commentUsername').value = xml.getElementsByTagName("username")[0].firstChild.data;
|
||||
$getE('commentEmail').value = xml.getElementsByTagName("email")[0].firstChild.data;
|
||||
$getE('commentUsername').disabled = true;
|
||||
$getE('commentEmail').disabled = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
//刷新验证码
|
||||
function refreshValidCode(obj) {
|
||||
obj.src = obj.src + '?code=' + randomNumber(10);
|
||||
}
|
||||
|
||||
function randomNumber(n) {
|
||||
var rnd = '';
|
||||
for (var i = 0; i < n; i++)
|
||||
rnd += Math.floor(Math.random() * 10);
|
||||
return rnd;
|
||||
}
|
||||
|
||||
//设置匿名
|
||||
function setAnonymous(obj) {
|
||||
if (obj.checked) {
|
||||
$getE('commentUsernameBlock').style.display = 'none';
|
||||
$getE('commentEmailBlock').style.display = 'none';
|
||||
$getE('commentIsAnonymous').value = 'true';
|
||||
}
|
||||
else {
|
||||
$getE('commentUsernameBlock').style.display = '';
|
||||
$getE('commentEmailBlock').style.display = '';
|
||||
$getE('commentIsAnonymous').value = 'false';
|
||||
}
|
||||
}
|
||||
|
||||
//设置私有
|
||||
function setPrivate(obj) {
|
||||
if (obj.checked) {
|
||||
$getE('commentIsPrivate').value = 1;
|
||||
}
|
||||
else {
|
||||
$getE('commentIsPrivate').value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//设置观点
|
||||
function setViewpoint(value) {
|
||||
for (i = -1; i < 2; i++) {
|
||||
if (i == value) {
|
||||
$getE('commentViewpointTab' + i).className = "current";
|
||||
}
|
||||
else {
|
||||
$getE('commentViewpointTab' + i).className = "";
|
||||
}
|
||||
}
|
||||
$getE('commentViewpoint').value = value;
|
||||
}
|
||||
|
||||
//设置按钮
|
||||
function changeBtnStyle(obj, className) {
|
||||
obj.className = className;
|
||||
}
|
||||
|
||||
//设置评分
|
||||
function changeRanking(index, isfixed) {
|
||||
var colStars = $getE("commentRankingBlock").getElementsByTagName("img");
|
||||
var k = isfixed ? parseInt($getE("commentRanking").value) : index;
|
||||
for (var i = 0; i < colStars.length; i++) {
|
||||
colStars[i].src = (i < k ? "{PE.SiteConfig.applicationpath/}Images/fstar.gif" : "{PE.SiteConfig.applicationpath/}Images/estar.gif");
|
||||
}
|
||||
}
|
||||
|
||||
function rankingClick(index) {
|
||||
$getE("commentRanking").value = index;
|
||||
}
|
||||
|
||||
function rankingMouseOver(index) {
|
||||
changeRanking(index, false);
|
||||
}
|
||||
|
||||
function rankingMouseOut() {
|
||||
changeRanking(0, true);
|
||||
}
|
||||
|
||||
//初始化评论
|
||||
commentInit();
|
||||
|
||||
</script>]]></LabelTemplate>
|
||||
</root>
|
||||
Reference in New Issue
Block a user