'
return pageHtml;
}
$("[id^=commentregist]").on('click', function () {
$(".loginMain").hide()
$("#loginFloat").show();
setTimeout(function(){
$(".loginMain").show()
$(".loginMain .Maincont .register_btn").trigger("click")
},100)
});
function jianchaStatus(){
window.location.reload();
}
//是否登录
function getUserContent(flag,obj){
var html = "";
html += '
';
html += '';
html += '
';
//已经登录
if(flag){
html += '发表评论';
html += '请填写评论内容';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += ''
html += '';
html += '
';
//未登录
}else{
html += '合作帐号:登录';
html += '注册|忘记密码?';
html += '
';
}
return html;
}
//时间转换
function tranTime(t){
var time = new Date(t*1000);
return time.Format("yyyy-MM-dd hh:mm:ss");
}
//获取cookie
function getCookie(name) {
var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
if (arr = document.cookie.match(reg)) return unescape(arr[2]);
else return null
}
var passwordkey = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o",
"p","q","r","s","t","u","v","w","x","y","z","A","B","C","D",
"E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S",
"T","U","V","W","X","Y","Z","0","1","2","3","4","5","6","7","8","9"
];
function passkey(length){
var Str = "";
for(var i = 0 ; i0&&commentLength<=300){
$(this).parent().parent().find("#comment_jiaoyan").eq(0).attr('class','wtips');
$(this).parent().parent().find("#comment_jiaoyan").eq(0).html('还可输入' + (limit - commentLength ) + '字' );
}else if(commentLength>300){
$(this).parent().parent().find("#comment_jiaoyan").eq(0).attr('class','tips');
$(this).parent().parent().find("#comment_jiaoyan").eq(0).html('请将评论内容限制在300字以内');
}else if(commentLength==0){
$(this).parent().parent().find("#comment_jiaoyan").eq(0).attr('class','tips');
$(this).parent().parent().find("#comment_jiaoyan").eq(0).html('请填写评论内容');
}
});
//插入表情
$(".discuss_comment .embox img").unbind("click").click(function(){
var content = $(this).attr('alt');
$(this).parent().parent().parent().parent().find('textarea').eq(0).val($(this).parent().parent().parent().parent().find('textarea').eq(0).val()+content);
});
//复制
$(".discuss_comment .copy").click(function(){
$(".discuss_tips").show();
$(".discuss_tips .cont p").eq(1).hide();
$(".discuss_tips .cont p").eq(0).show();
$(".discuss_tips .button").eq(1).hide();
$(".discuss_tips .button").eq(0).show();
});
$(".discuss_tips .button a").eq(0).click(function(){
if(copy2Clipboard(pageUrl)!=false){
$(".discuss_tips .cont p").eq(0).hide();
$(".discuss_tips .cont p").eq(1).show();
$(".discuss_tips .button").eq(0).hide();
$(".discuss_tips .button").eq(1).show();
}
});
$(".discuss_tips .button a").eq(1).click(function(){
$(".discuss_tips").hide();
});
$(".discuss_tips .button a").eq(2).click(function(){
$(".discuss_tips").hide();
});
}
//合作、注册、忘记密码链接初始化
function initUrl(){
//合作账号初始化
$("[id^=comment_qq]").attr('href','//oauth.passport.cctv.cn/OAuthQzoneClient/OAuthQZoneClientServlet.do?method=login&cntv_callback='+nowUrl);
//$("[id^=comment_rr]").attr('href','//oauth.passport.cctv.cn/OAuthRenRenClient/OAuthRenRenClientServlet.do?method=login&cntv_callback='+nowUrl);
//$("[id^=comment_kx]").attr('href','//oauth.passport.cctv.cn/OAuthKaixinClient/connect/index.jsp?cntv_callback='+nowUrl);
//注册
//忘记密码
$("[id^=comment_forget]").attr('href','https://user.cctv.cn/findPassword/index.shtml');
}
//替换图片
function tranMessage(message){
for(var i=1;i<=30;i++){
if(message.indexOf('[em:' + i + ':]')!=-1){
var tmp = '[em:' + i + ':]';
var reg=new RegExp("\\"+tmp,"g");
message = message.replace(reg, "");
}
}
return message;
}
$(function(){
getData(parseInt(page));
$("#copy_content").html(decodeURI(title) + ' '+pageUrl+'');
function tipsposition(){
var ww=$(window).width(),
hh=$(window).height(),
st=$(window).scrollTop(),
tw=$(".discuss_tips").width(),
th=$(".discuss_tips").height(),
tl=(ww-tw)/2,
tt=st+(hh-th)/2;
$(".discuss_tips").css({left:tl,top:tt});
}
window.onload=window.onscroll=window.onresize=tipsposition;
});
//登录
function commentLogin(){ $('#loginFloat').show()
}
//退出
function commentLogout(){
var url = 'https://reg.cctv.cn/login/logout.action?callback=?&service=client_transaction&from='+pageUrl;
$.getJSON(url,function(data){
var msg = data.errMsg;
if(msg!='成功'){
alert(msg);
}
if(data!=null){
var ssoArray = data.sso;
for(var i=0;i0&&commentLength<=300){
$("#comment_jiaoyan").attr('class','wtips');
$("#comment_jiaoyan").html('还可输入' + (commentLimit - commentLength ) + '字' );
}else if(commentLength>300){
$("#comment_jiaoyan").attr('class','tips');
$("#comment_jiaoyan").html('请将评论内容限制在300字以内');
}else if(commentLength==0){
$("#comment_jiaoyan").attr('class','tips');
$("#comment_jiaoyan").html('请填写评论内容');
}
}
//发表留言
function commentSubmitMessage(){
var message = $("#comment_content").val();
if(message==null||message=="" || message =="根据法律法规要求,请您绑定手机号完成后台实名认证后发表评论。感谢您的理解和支持!"){//兼容ieplaceholder
alert("留言不能为空!");
return;
}
if(message.length>300){
alert("留言字数太长!");
return;
}
var url = "https://newcomment.cctv.cn/comment/post";
url += "/app/"+app +"/itemid/"+itemid+"/itemtype/"+itemtype;
url += "?message="+encodeURI(message)+"&authorid="+authorid+"&author="+encodeURI(author)+"&jsonp_callback=?";
$.getJSON(url,function(data){
var code = data.code;
if(code=="20927"){
var jUrl = "//reg.cctv.cn/authentication?service="+window.location.href;
var jUrl1 = jUrl.split("=")[1];
window.location.href= "//reg.cctv.cn/authentication?formFlag=3&userSeqId="+userSeqId+"&service="+jUrl1;
}else if(code=='0')
{
alert("留言成功");
}
else{
alert(data.msg);
}
});
$("#comment_content").val('')
}
//发表回复评论
function fabiaohuifuliuyan(obj){
var tid = $(obj).attr('tid');
var replyid = $(obj).attr('pid');
var message = $(obj).parent().parent().parent().find('textarea').eq(0).val();
if(message==null||message==""){//兼容ieplaceholder
alert("留言不能为空!");
return;
}
if(message.length>300){
alert("留言字数过长!");
return;
}
var url = "https://newcomment.cctv.cn/comment/post";
url += "/app/"+app +"/itemid/"+itemid+"/itemtype/"+itemtype;
url += "?tid="+tid+"&replyid="+replyid+"&message="+encodeURI(message)+"&authorid="+authorid+"&author="+encodeURI(author)+"&jsonp_callback=?";
$.getJSON(url,function(data){
var code = data.code;
if(code=="20927"){
var jUrl = "//reg.cctv.cn/authentication?service="+window.location.href;
var jUrl1 = jUrl.split("=")[1];
window.location.href= "//reg.cctv.cn/authentication?formFlag=3&userSeqId="+userSeqId+"&service="+jUrl1;
}else if(code=='0')
{
alert("留言成功");
}
else{
alert(data.msg);
}
})
$(obj).parent().parent().parent().find('textarea').eq(0).val("");
}
//实名认证
function realName(){
var verifycode=getCookie("verifycode")
var userSeqId=getCookie("userSeqId")
if (verifycode == null){
return;
}else{
$.ajax({
type: "post",
url: "//reg.cctv.cn/openapi/v2/user/isAuth",
dataType: "json",
data:{
"timestamp":timestamp, //当前时间戳
"appid":"dgtGyfXwN9Gcr7ow" //管理员分配给业务线应用的唯一标识
},
xhrFields: {
withCredentials: true
},
crossDomain: true, //添加跨域参数是为了将登录标识(token)带过去验证
success:function(data){
if (data.data == 0){//不是
alert("根据法律法规要求,请您绑定手机号完成后台实名认证后发表评论。感谢您的理解和支持!");
var jUrl = "//reg.cctv.cn/authentication?service="+window.location.href;
var jUrl1 = jUrl.split("=")[1];
window.location.href= "//reg.cctv.cn/authentication?formFlag=3&userSeqId="+userSeqId+"&service="+jUrl1;
//window.open("//reg.cctv.cn/authentication?service="+window.location.href);
}else{
commentSubmitMessage();
return;
}
},
error: function (data) {
alert("ajax失败:"+data.errtype)
}
});
}
}
function huifurealName(obj){
var verifycode=getCookie("verifycode")
var userSeqId=getCookie("userSeqId")
if (verifycode == null){
return;
}else{
$.ajax({
type: "post",
url: "//reg.cctv.cn/openapi/v2/user/isAuth",
dataType: "json",
data:{
"timestamp":timestamp, //当前时间戳
"appid":"dgtGyfXwN9Gcr7ow" //管理员分配给业务线应用的唯一标识
},
xhrFields: {
withCredentials: true
},
crossDomain: true, //添加跨域参数是为了将登录标识(token)带过去验证
success:function(data){
if (data.data == 0){//不是
alert("根据法律法规要求,请您绑定手机号完成后台实名认证后发表评论。感谢您的理解和支持!");
var jUrl = "//reg.cctv.cn/authentication?service="+window.location.href;
var jUrl1 = jUrl.split("=")[1];
window.location.href= "//reg.cctv.cn/authentication?formFlag=3&userSeqId="+userSeqId+"&service="+jUrl1;
//window.open("//reg.cctv.cn/authentication?service="+window.location.href);
}else{
fabiaohuifuliuyan(obj);
return;
}
},
error: function (data) {
alert("ajax失败:"+data.errtype)
}
});
}
}
function realName1(){
var verifycode=getCookie("verifycode")
var userSeqId=getCookie("userSeqId")
if (verifycode == null){
return;
}else{
$.ajax({
type: "post",
url: "//reg.cctv.cn/openapi/v2/user/isAuth",
dataType: "json",
data:{
"timestamp":timestamp, //当前时间戳
"appid":"dgtGyfXwN9Gcr7ow" //管理员分配给业务线应用的唯一标识
},
xhrFields: {
withCredentials: true
},
crossDomain: true, //添加跨域参数是为了将登录标识(token)带过去验证
success:function(data){
if (data.data == 0){//不是
alert("根据法律法规要求,请您绑定手机号完成后台实名认证后发表评论。感谢您的理解和支持!");
var jUrl = "//reg.cctv.cn/authentication?service="+window.location.href;
var jUrl1 = jUrl.split("=")[1];
window.location.href= "//reg.cctv.cn/authentication?formFlag=3&userSeqId="+userSeqId+"&service="+jUrl1;
//window.open("//reg.cctv.cn/authentication?service="+window.location.href);
}else{
return;
}
},
error: function (data) {
alert("ajax失败:"+data.errtype)
}
});
}
}
//点击判断实名制
$("#comment_content").click(function(){
realName1();
})
//兼容ie的placeholder效果
function placeholder(target){
$(target).attr("placeholder","")
$(target).attr("datavalue","根据法律法规要求,请您绑定手机号完成后台实名认证后发表评论。感谢您的理解和支持!")
$(target).val($(target).attr("datavalue")).addClass("inp");
$(target).css("color","#757575")
$(target).focus(function() {
if($(this).val() == $(this).attr("datavalue")) {
$(this).val("").removeClass("inp");
$(target).css("color","#000")
}
})
$(target).blur(function(){
if($(this).val() == "" || $(this).val() == $(this).attr("datavalue")) {
$(this).val($(target).attr("datavalue")).addClass("inp");
$(target).css("color","#757575")
}
})
}
$(function(){
//页面初始化
commentInit();
//调用兼容ie的placeholder
placeholder("#comment_content")
//合作账号初始化
$("[id^=comment_qq]").attr('href','//oauth.passport.cctv.cn/OAuthQzoneClient/OAuthQZoneClientServlet.do?method=login&cntv_callback='+encodeURI(pageUrl));
//$("[id^=comment_rr]").attr('href','//oauth.passport.cctv.cn/OAuthRenRenClient/OAuthRenRenClientServlet.do?method=login&cntv_callback='+encodeURI(pageUrl));
//$("[id^=comment_kx]").attr('href','//oauth.passport.cctv.cn/OAuthKaixinClient/connect/index.jsp?cntv_callback='+encodeURI(pageUrl));
//注册
$(".emotion").click(function(){
var commentIframe = $("#comment_iframe",parent.document.body);
var height = commentIframe.attr('height');
if(height=='239'){
commentIframe.attr('height','300');
}else if(height=='0'){
commentIframe.attr('height','239');
}else{
commentIframe.attr('height','239');
}
});
$("#comment_embox img").click(function(){
if ($("#comment_content").val() == "根据法律法规要求,请您绑定手机号完成后台实名认证后发表评论。感谢您的理解和支持!")
{ $("#comment_content").val("");}
var img = $(this).attr('alt');
$("#comment_content").val($("#comment_content").val()+img);
var commentIframe = $("#comment_iframe",parent.document.body);
commentIframe.attr('height','0');
});
});