$(".sitenav li").removeclass("active"); $("#nav_news").addclass("active"); if ($(".bb_comment").attr("ismsg") == "0") { $(".bb_comment").html(""); } $("#replyuser").attr("replytoid", ""); $("#replyuser").html("点评一下吧:"); $("#txtcomment").val(""); inithispage(); getnewscomment(1); $(function () { ajaxfocuskeyword("getfocuskeyword", ""); }); //初始化页面 function inithispage() { $(".pl_list").html(""); $(".pagerhtml").html(""); $("#replyuser").attr("replytoid", ""); $("#replyuser").html("点评一下吧:"); $("#txtcomment").val(""); } function getnewscomment(pageno) { var newsid = $("#enshrinenews").attr("toid"); $.ajax({ type: "post", //此时,所有data数据,都默认加到url里 datatype: "html", data: "pageno=" + pageno, url: "/controls/tools/news.ashx?action=getnewscomment&newsid=" + newsid + "¶m=" + new date().gettime(), success: function(d) { var result = $(d).find(".result").text(); switch (result) { case '-1': alert($(d).find(".returnval").text()); break; case '1': $("#newsmsginfo").html($(d).find(".commenthtml")[0].innerhtml); break; default: alert($(d).find(".returnval").text()); break; } }, error: function(xmlhttprequest, textstatus, errorthrown) { if (errorthrown) { alert(textstatus + ":" + errorthrown); } } }); } function ldr_pager(obj) { var pageno = $(obj).attr("toid"); getnewscomment(pageno.length > 0 ? pageno : 1); } function limitlength(area, len) { if (area.value.length > len) area.value = area.value.substr(0, len); } //去评论 function replyparent(obj) { var toid = $(obj).attr("toid"); var tonickname = $(obj).attr("tonickname"); $("#replyuser").attr("replytoid", toid); $("#replyuser").html("回复@" + tonickname); $("#txtcomment").focus().select(); } //添加评论 function toreply(obj) { var coocomm = jscookie.getcookie("usercomment"); if (coocomm != "") { var lasttime = date.parse(coocomm); var curtime = new date(); var date3 = curtime - lasttime; //计算出相差天数 var days = math.floor(date3 / (24 * 3600 * 1000)) //计算出小时数 var leave1 = date3 % (24 * 3600 * 1000) //计算天数后剩余的毫秒数 var hours = math.floor(leave1 / (3600 * 1000)) //计算相差分钟数 var leave2 = leave1 % (3600 * 1000) //计算小时数后剩余的毫秒数 var minutes = math.floor(leave2 / (60 * 1000)) //计算相差秒数 var leave3 = leave2 % (60 * 1000) //计算分钟数后剩余的毫秒数 var seconds = math.round(leave3 / 1000) if (days == 0 && hours == 0 && minutes == 0 && seconds < 3) { alert("您操作过于频繁,请歇一歇再评论!"); return; } } var toid = $(obj).attr("toid"); var data = $("#txtcomment").val(); if (data.indexof("http://") > 0 || data.indexof("www.") > 0 || data.indexof(".com") > 0 || data.indexof(".net") > 0 || data.indexof(".cn") > 0 || data.indexof(".com.cn") > 0) { alert("您没有权限在评论里加入超链接!"); $("#txtcomment").focus().select(); return; } if (data.length > 200) { alert("评论内容不能超过200个字符!"); $("#txtcomment").focus().select(); } var parentid = $("#replyuser").attr("replytoid"); if (data.length < 3) { alert("的评价连三个字都不到哎,朋友会说你小气!"); return; } data = "comment=" + data; if (parentid && parentid.length > 0) { data += "&parentid=" + parentid; } newsajaxdo(toid, "savecomment", data); } function enshrineit(obj) { var toid = $(obj).attr("toid"); if ($(obj).attr("isenshrine") == "0") { newsajaxdo(toid, "enshrine", ""); } } //支持还是反对 function saveuserscore(objid, type) { var coo = jscookie.getcookie("newsremark"); if (coo.indexof("$" + objid + "$") >-1) { $(".showremarkprompt").text("您已经点评过这篇文章啦!"); return; } data = "opertype=" + type; newsajaxdo(objid, "savescore", data); } function newsajaxdo(toid, action, data) { $.ajax({ type: "post", datatype: "json", data: data, url: "/controls/ajax/ajax_news.aspx?action=" + action + "&newsid=" + toid + "¶m=" + new date().gettime(), success: function(d) { if (d.result == "-2") { _logindiv(); } if (d.result == "-1") { alert(d.returnval); } if (d.result == "1") { switch (action) { case "savescore": var coo = jscookie.getcookie("newsremark"); var cooval; if (coo == "") { cooval = "$" + toid+"$"; } else { cooval = coo + toid+ "$"; } jscookie.addcookie("newsremark", cooval, 12); if (data.indexof("support")>0) { $supportinfo = $("#supportinfo"); $supportinfo.text(parseint($supportinfo.text()) + 1); $(".showremarkprompt").text("您选择了支持ta的观点!+1"); } else { $againstinfo = $("#againstinfo"); $againstinfo.text(parseint($againstinfo.text()) + 1); $(".showremarkprompt").text("您选择了反对ta的观点!+1"); } break; case "enshrine": //该界面上不处理“删除收藏”操作 $("#enshrinenews")[0].innerhtml = "[已收藏]"; $("#enshrinenews").attr("isenshrine", "1"); break; case "savecomment": var coocomm = jscookie.getcookie("usercomment"); jscookie.addcookie("usercomment", new date(), 1); inithispage(); getnewscomment(1); break; case "eye_you": $(".eye_you_label")[0].innerhtml = "已关注"; break; case "addyoufriend": $(".addyoufriend_label")[0].innerhtml = "好友"; break; default: alert(d.returnval); break; } } }, error: function(xmlhttprequest, textstatus, errorthrown) { if (errorthrown) { alert(textstatus + ":" + errorthrown); } } }); }