function setCookie(c_name, value, expiredays) { var exdate=new Date(); exdate.setDate(exdate.getDate() + expiredays); document.cookie=c_name+ "=" + escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString()); } function getCookie(name) { var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)"); if(arr=document.cookie.match(reg)) { return (arr[2]); } else { return null; } } function subComment(that) { var dataId = $("#data_id").val(); var commContent = $(that).parent().siblings(".comment-textarea").html(); var commContentTxt = $(that).parent().siblings(".comment-textarea").text(); var commentId = $(that).parent(".publish").parent(".reply-commert").parent(".re-reply-lists").siblings(".replay-head").attr('netid'); commentId = typeof(commentId) === 'undefined' ? 0 : commentId; var url = $("#data_id").parent().attr('action'); if (commContentTxt == "" && commContent != "") { alert("纯表情会让人误以为您是表情帝,还是说点实在的吧!"); return; } if (commContentTxt == "" || commContentTxt.length < 5 || commContentTxt.length > 500) { alert("评论内容长度为5~500个字!"); return; } if ($("#data_time").val() == "1") { setTimeout(function () { $("#data_time").val("0"); }, 60000) alert("水也不是这么灌的,请您休息一分钟再发表评论!"); return; } if (getCookie("timeC" + dataId) == "succ") { alert("不好意思,您已经评价了!"); return; } $.post(url, {data_id: dataId, commcontent: commContent, comment_id: commentId}, function (data) { if (data.code == 0) { alert("评论添加成功,请等待审核"); $("#data_time").val("1") setCookie("timeC" + dataId, "succ"); $(that).parent().siblings(".comment-textarea").html(''); } else { alert(data.msg); return false; } }, 'json'); } function softVote(softId, pingjia) { if( $("#check_soft_vote").val() == "1" ) { alert("您已经评价过,请不要重复评价!"); return false; } $.ajax({ type:"POST", url:apiConfig.mBaseUrl + "/softcomment/softvote/", data:{soft_id:softId, pingjia:pingjia}, dataType:"json", success:function(response){ if( response.code == '0' ) { if( pingjia == 1 ) { var likeNumber = parseInt($("#soft_like").html()); likeNumber = likeNumber + 1; $("#soft_like").html(likeNumber); $("#check_soft_vote").val("1"); } else { var dislikeNumber = parseInt($("#soft_dislike").html()); dislikeNumber = dislikeNumber + 1; $("#soft_dislike").html(dislikeNumber); $("#check_soft_vote").val("1"); } alert('投票成功'); } else { alert(response.msg); } } }); } function commentVote(softId, commId) { $.ajax({ type:"POST", url:apiConfig.mBaseUrl + "/softcomment/commentvote/", data:{soft_id:softId,comm_id:commId}, dataType:"json", success:function(response){ if( response.code == '0' ) { var num = parseInt($("div[netid='"+ commId +"'] a.like")[0].innerHTML); $("div[netid='"+ commId +"'] a.like")[0].innerHTML = num+1; $("div[netid='"+ commId +"'] a.like").attr('onclick', ''); $("div[netid='"+ commId +"'] a.like").attr('disabled',true); } else { alert(response.msg); } } }); }