(.*?)<\/div>/igm, "\n$1") //
text
-> \ntext
.replace(/
(.*?)<\/p>/igm, "\n$1"); //
text
-> \ntext
return res;
}
function stripTags(el, tagName) {
var els = el.getElementsByTagName(tagName.toUpperCase());
for (var i = 0; i < els.length; i++) {
while (els[i].firstChild)
els[i].parentNode.insertBefore(els[i].removeChild(els[i].firstChild), els[i]);
els[i].parentNode.removeChild(els[i--]);
}
}
if(typeof String.prototype.trim !== 'function') {
String.prototype.trim = function() {
return this.replace(/^\s+/, '').replace(/\s+$/, '');
};
}
function cmt4_getCleanText(ele) {
var clone = ele.cloneNode(true);
clone.innerHTML = cmt4_html2txt(clone.innerHTML);
stripTags(clone, '*');
return clone.innerHTML.replace(/(?:\s| )*$/g, '');
}
// 清除评论内容
function cmt4_cleanContent(textarea) {
textarea.value = '';
textarea.removeAttribute('data-submit');
var ifr = textarea.parentNode.getElementsByTagName('iframe');
if(!ifr || ifr.length < 1) return;
ifr = ifr[0];
getIframeBody(ifr).innerHTML = '';
}
function cmt4_vote(relEle) {
cmt4_usejq(function(){
var $ele = $(relEle),
id = $ele.attr('data-id'),
$num = $ele.find('.cmtSupportNum'),
cur = parseInt($num.text(), 10);
var postUrl = '//cmt.pcauto.com.cn/action/comment/support.jsp';
var postData = {
version:2,
cid: id,
sp: 1,
r: Math.random()
};
var successHandle = function(data) {
if(data.code == 1) { // success
$num.text(cur + 1);
$ele.data('done', '1');
$ele.find('.like-icon').addClass('have_vote');
cmt4_voteSuccess($ele);
} else { // false
if(data.msg) {
alert(data.msg);
} else {
alert('+1 失败');
}
}
};
postCORS(postUrl, function(data) {
try {
data = data.replace(/\\/g,"\\\\");
data = eval('('+data+')');
successHandle(data);
} catch(e) {
alert("咦,好像出错了,再试下或刷新看看?!");
}
}, postData, {withCookie: true});
});
}
function cmt4_voteSuccess($ele) {
var pos = $ele.offset(),
top = pos.top,
left = pos.left,
$plus = $('J-plus1'),
w = $plus.width(),
h = $plus.height(),
dl = ($ele.width() - w) / 2;
$('#J-plus1').stop().hide(0)
.css({
top: top - 10,
left: left + dl
})
.show(0)
.animate({
top: top - 10 - 50,
opacity: 0
}, 1000, function(){
$('#J-plus1').hide().css('opacity', 1);
});
$ele.css({
'color': '#ccc',
'text-decoration': 'none',
'cursor': 'default'
});
}
// 这个函数写死了form表单里元素的name
function cmt4_checkFrm(f){
if(f.content.value=='') { f.content.focus(); alert('评论内容不能为空!'); return false; }
if(f.content.value==cmt4_getAuditInfo()){ f.content.focus(); alert('请先输入您的评论!'); return false; }
if(f.content.value.length>1000) { f.content.focus(); alert('评论内容字数超过1000!'); return false; }
if(f.title.value=='') f.title.value=document.title;
if(f.title.value=='') f.title.value='[无标题]';
f.username.value=document.getElementById('usernameInput').value;
document.getElementById('Submit').disabled=true;
return true;
}
function reply(item, floor, showName, createTime) {
if(!(Get_Cookie('common_session_id') && Get_Cookie('cmu'))) {
alert('登录后才能回复~');
showFB('login');
return false;
}
// if opened, hide it
var $parentNext = $(item).parent().parent().next(),
$operateOptions = $(item).parent();
$('.cmtMain .cmtOperateOptions').css('visibility', '');
if($parentNext.attr('id') == 'pl_add' && $parentNext.css('display') == 'block') {
$('#pl_add').slideUp();
$operateOptions.css('visibility', '');
return;
}
$operateOptions.css('visibility', 'visible');
document.getElementById('replyFloor').value= floor;
var preContent ="精彩评论将会增加您在论坛的影响力,恶意灌水用户将面临锁号处理。希望广大车友共同维护论坛的友好回复氛围。";
//var auditInfo = "注:所有评论通过审核后才会被公开。";
var auditInfo = preContent;
//document.getElementById('content_pop').focus();
//document.getElementById('pop_info').value = auditInfo;
document.getElementById('replyShowName').value = preContent;
cmt4_showAuditInfo2(auditInfo,1);
var td = $(item).parent().parent().parent();
var content = td.find('>.commentContent').html();
var preReply = td.find('.reply').html();
var replyContent = document.getElementById('replyContent');
replyContent.value = "";
if(preReply != null) {
replyContent.value = '
' + preReply + '
';
}
replyContent.value += '
' + floor + '楼' + showName + '' + createTime + '
';
showFB('add', item);
return false;
}
function cmt4__comment_show_entry_(placeHolder) {
var div = document.createElement('div');
if(placeHolder == null) placeHolder = document.getElementById("_comment_tag_");
if(placeHolder == null) placeHolder = document.getElementById("comment_tag");
if(placeHolder == null) {
alert(placeHolder);
return div;
}
div.id = placeHolder.id;
placeHolder.parentNode.replaceChild(div,placeHolder);
return div;
}
if(!window.jQuery){
var js=document.createElement("script");
js.src="//js.3conline.com/min/temp/v1/lib-jquery1.10.2.js";
document.getElementsByTagName("head")[0].appendChild(js);
}
function cmt4_cleanMsg(){
//$('#msg').html("");
var _msg = document.getElementById("msg");
if(_msg){
_msg.innerHTML = "";
}
}
function cmt4_putFace(img, win){
var ifr = $(img).parents('form').find('.cmtEditor').get(0);
var html = '
';
var prefix = '{';
var postfix = '}';
cmt4_insert_code(prefix, postfix, html, ifr, win);
}
function cmt4_insert_code(prefix, postfix, value, iframe, win){
// 如果是默认文字,先移掉
if(iframe.id == 'cmtEditor_pop') {
cmt4_showAuditInfo2(3, 0);
} else {
cmt4_showAuditInfo(0, iframe.id);
}
insertToCursor(iframe, value);
$(".cmtfaceList").hide();
}
function cmt4_hideCaptcha() {
$("input[name='needCaptcha']").each(function(index, item) {
item.value = "0";
});
$(".captcha_line").hide();
}
function cmt4_chgCap() {
// var c = document.getElementById("captchax");
// if(c) c.src="//captcha.pcauto.com.cn/captcha/v.jpg?"+new Date().getTime();
var src = "//captcha.pcauto.com.cn/captcha/v.jpg?"+new Date().getTime();
$("img[id='captchax']").each(function(index,item){
item.src = src;
});
}
function cmt4_chgCap_pop() {
var c = document.getElementById("captchax_pop");
if(c) c.src="//captcha.pcauto.com.cn/captcha/v.jpg?"+new Date().getTime();
}
cmt4_firstcaptcha=true;
function cmt4_textLimitCheck(thisArea, maxLength){
if (thisArea.value.length > maxLength){
alert('你只能输入' + maxLength + '字。 \r超出的将自动去除。');
thisArea.value = thisArea.value.substring(0, maxLength);
thisArea.focus();
}
document.getElementById('cmtCountNum').innerHTML = thisArea.value.length;
}
function cmt4_getCookie(name) {
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr != null) return (arr[2]); return null;
}
function cmt4_loadSessionId() {
return cmt4_getCookie('common_session_id');
}
function cmt4_checkForm() {
var usernameInput = document.getElementById('usernameInput2').value;
if (usernameInput == ""){
document.getElementById("msg").innerHTML = "请输入用户名";
return false;
}
var passwordInput = document.getElementById('passwordInput').value;
if (passwordInput == ""){
document.getElementById("msg").innerHTML = "请输入密码";
return false;
}
return true;
}
function cmt4_checkLogin() {
cmt4_cleanMsg();
var time=0;
var checker = setInterval(function(){
if(time++ < 30 && !document.cookie.match(/(^|; )common_session_id=[^;]+/)) return; //3秒钟
if(document.cookie.match(/(^|; )common_session_id=[^;]+/)) {
clearInterval(checker);
var cmu = decodeURIComponent(cmt4_getCookie('cmu'));
var sessionId = cmt4_loadSessionId();
var resp_enc = 'gbk';
if(cmu != "" && cmu != "null" && cmu != "undefined" && sessionId!=null){
$.getJSON("//my.pcauto.com.cn/intf/getLogedUser.jsp?resp_enc=" + resp_enc + "&callback=?",function(data){
var spanLogin = document.getElementById("loginSpan");
var spanPopLogin = document.getElementById("loginSpan_pop");
var showName = data.nickName || cmu;
var logindHtml = cmt4_getLoginedHTML(showName);
if(spanLogin && logindHtml!=''){
$("span[name='loginSpan']").each(function(index,item){
item.innerHTML = logindHtml.replaceAll('usernameInput','usernameInput_'+ index);
});
}
if(spanPopLogin && logindHtml!='') spanPopLogin.innerHTML = logindHtml;
flushFace(data);
// cmt4_prepareSync(data.id);
});
cmt4_changeAuditInfoAfterLogin();
cmt4_hideCaptcha();
hiddenFB(); //关闭登录弹窗
fetchUserCard(1);//更改信息页面
}
}else{
var _msg = document.getElementById("msg");
if(_msg){
clearInterval(checker);
_msg.innerHTML = "
登录失败! 请检查帐号密码并输入验证码。";
$("#popCaptchaImg").attr("src","//captcha.pcauto.com.cn/captcha/v.jpg?"+ new Date().getTime());
$("#captcha-tpl").show();
}
}
},100);
}
function cmt4_needJS(fn,src,callback) {
if(typeof callback == 'undefined' || callback == null) callback = function(){};
if(typeof fn != 'undefined' && fn != null && fn != '') return callback();
var status = typeof _needJS_ == 'undefined' ? _needJS_ = {loaded:[],loading:[]} : _needJS_;
for(var i=0; i < status.loaded.length; i++) {
if(status.loaded[i] == src) return callback();
}
function idx(src) { //供后面的代码调用
for(var i=0; i < status.loading.length;i++) if(status.loading[i].src==src) return i;
}
var loading = status.loading[idx(src)];
if(loading != null) {
loading.callbacks.push(callback);
return;
}
status.loading.push(loading = {src:src,callbacks:[callback]});
var js = document.createElement('script');
js.src = src;
js.onload = js.onreadystatechange = function() {
if(typeof js.readyState == 'undefined' || js.readyState == 'loaded' || js.readyState == 'complete') {
js.onload = js.onreadystatechange = null;
status.loaded.push(loading.src);
var callbacks = loading.callbacks;
status.loading.splice(idx(src),1);
for(var i = 0; i < callbacks.length; i++) {
loading.callbacks[i]();
}
}
}
document.getElementsByTagName('head')[0].appendChild(js);
}
function Get_Cookie( check_name ) {
check_name = escape( check_name );
// first we'll split this cookie up into name/value pairs
// note: document.cookie only returns name=value, not the other components
var a_all_cookies = document.cookie.split( ';' );
var a_temp_cookie = '';
var cookie_name = '';
var cookie_value = '';
var b_cookie_found = false; // set boolean t/f default f
var i = '';
var len = a_all_cookies.length;
for ( i = 0; i < len; i++ )
{
// now we'll split apart each name=value pair
a_temp_cookie = a_all_cookies[i].split( '=' );
// and trim left/right whitespace while we're at it
cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
// if the extracted name matches passed check_name
if ( cookie_name == check_name )
{
b_cookie_found = true;
// we need to handle case where cookie has no value but exists (no = sign, that is):
if ( a_temp_cookie.length > 1 )
{
cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
}
// note that in cases where cookie is initialized but no value, null is returned
return cookie_value;
break;
}
a_temp_cookie = null;
cookie_name = '';
}
if ( !b_cookie_found )
{
return null;
}
}
function Set_Cookie( name, value, expires, path, domain, secure ) {
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );
// if the expires variable is set, make the correct expires time, the
// current script below will set it for x number of days, to make it
// for hours, delete * 24, for minutes, delete * 60 * 24
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
//alert( 'today ' + today.toGMTString() );// this is for testing purpose only
var expires_date = new Date( today.getTime() + (expires) );
//alert('expires ' + expires_date.toGMTString());// this is for testing purposes only
document.cookie = escape( name ) + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + //expires.toGMTString()
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
//use id as the cookie name
function setCookie(cookieName, commentId, domain, expires) {
// get cookie
var cookie = Get_Cookie(cookieName);
if(!expires) {
expires = 90; // 默认90天
}
if(cookie) { // exist cookie
cookie = cookie.split('#'); // covert to array
cookie.push(commentId);
Set_Cookie(cookieName, cookie.join("#") , expires, '/', domain, '');
} else { // first to set cookie
Set_Cookie(cookieName, commentId , expires, '/', domain, '');
}
}
// conPostfix : 用来区分 #contentxxx
function cmt4_comment(conPostfix) {
conPostfix = conPostfix || '';
cmt4_getArea();
cmt4_usejq(function () {
var $ = window.jQuery;
cmt4_cleanMsg();
var postUrl = "//cmt.pcauto.com.cn/action/comment/create.jsp";
var postData = {
isEncode: 1,
content: encodeURI($('#content' + conPostfix).val()),
id: $('#id').val(),
captcha: $('#captcha' + conPostfix).val(),
needCaptcha: $("#needCaptcha").val(),
username: encodeURI($("#usernameInput").val()),
url: $("#url").val(),
title: encodeURI($("#title").val()),
columnId: '',
area: encodeURI($("#area").val()),
replyFloor2: $("#replyFloor").val(),
partId: $("#partIdq").val() || "",
syncsites: cmt4_getSyncStrVal()
};
var successHandle = function (data) {
var res = data.resultMsg;
if (data.resultCode >= 0) {
var afterAudit = (data.resultCode == 0);
if (data.userType) {
var kol_type = 'class="kol_type"';
var horn_icon = '
'
}
var nc = "
" + $('#newComment').html() + "";
var userJump = '//my.pcauto.com.cn';
if (data.userId > 0 && userJump != '') {
nc = nc.replace('
', '
' + data.showName +
'');
}
// replace avatar
var userAvatarStr = '';
if (data.userId > 0 && userJump != '') {
nc = nc.replace('', '
' + data.showName + '');
userAvatarStr = '
' + (
data.userType ? '' : '') + '';
} else {
nc = nc.replace('', '
' + data.showName + '');
userAvatarStr =
'
';
}
nc = nc.replace('', userAvatarStr);
nc = nc.replaceAll("", data.floor);
nc = nc.replaceAll("", data.commentId);
// nc = nc.replace("", data.createTime.substring(data.createTime.indexOf("-")+1));
nc = nc.replace("", "刚刚");
nc = nc.replace("", data.userType ? horn_icon + '
' + data.brief +
'' : '
' + data.brief + '');
var quoteSpan = document.getElementById("quoteSpan");
if (quoteSpan) {
if ('pconline' == 'pcauto') { //for pcauto
nc = nc.replaceAll("", quoteSpan.innerHTML);
} else {
if (data.brief == '') {
nc = nc.replaceAll("", quoteSpan.innerHTML);
}
}
}
nc = nc.replaceAll("", "");
if (quoteSpan) quoteSpan.innerHTML = "";
if (afterAudit) { //先审后出不能引用和回复
// 添加先审后出提示
nc = nc.replaceAll("",
'
(感谢参与评论,您的评论内容将在审核后公开。)
');
// 把未审的写到cookie里
//setCookie(UN_AUDIT_COOKIE_NAME + data.topicId, data.commentId, '.pcauto.com.cn');
} else { // 先出后审
nc = nc.replaceAll("",
"
回复0");
// add comment_total
var a = $("#comment_total").html();
a++;
$("#comment_total").html(a);
$("#comment_total2").html(a);
$("#comment_total").length && $('#icon-remark-b').length && $('#icon-remark-b')
.html(a);
}
if (conPostfix == '_pop') {
var reply_tpl = document.getElementById('replyContent').value;
//reply_tpl = reply_tpl.replaceAll('
', "")
nc = nc.replace("", "
" + reply_tpl +
"
");
}
$('#commentTable').prepend(nc);
if (!afterAudit) {
bindVoteEventNew(); //add new comment vote bind
}
//$('#content').val("");
//cmt4_cleanContent(document.getElementById('content' + conPostfix));
var contentArea = document.getElementById('content' + conPostfix);
if (contentArea) {
cmt4_cleanContent(contentArea);
}
res = res + cmt4_getExtraAuditInfo();
$("#replyFloor").val('');
}
if (document.getElementById("needAlert")) {
alert(res);
}
//是否显示验证码(当用户在1分钟内发表5条以上评论,第6条评论将需要输入验证码,输入验证码提交成功后,下次默认不需输入验证码,以此循环。)
// alert(data.commentCount+"...."+5);
var captcha = false || data.resultCode == -9;
if (captcha) {
$("input[name='needCaptcha']").each(function (index, item) {
item.value = "1";
});
$(".captcha_line").each(function (index, item) {
$(item).show();
});
} else {
if (data.commentCount > global.max_comment_count) {
$("input[name='needCaptcha']").each(function (index, item) {
item.value = "1";
});
$(".captcha_line").each(function (index, item) {
$(item).show();
});
cmt4_chgCap();
} else {
$("input[name='needCaptcha']").each(function (index, item) {
item.value = "0";
});
$(".captcha_line").each(function (index, item) {
$(item).hide();
});
}
}
if (data.resultCode != -8 && data.resultCode != 1 && data.resultCode != 0) {
alert(res);
}
//变换验证码
if (document.getElementById("captcha")) {
$("input[name='captcha']").each(function (index, item) {
$(item).attr("value", "");
});
cmt4_chgCap();
}
var hideTag = 1;
if (data.resultCode >= 0) { //发表成功,锚点回到newestCmt
hideTag = 2;
}
hiddenFB(hideTag);
return false;
};
var errorHandle = function () {
alert('数据提交失败 ╮(╯_╰)╭ ,尝试重新提交或刷新');
};
var completeHandle = function () {
if (document.getElementById('Submit')) document.getElementById('Submit').disabled =
false;
if (document.getElementById('Submit2')) document.getElementById('Submit2').disabled =
false;
if (document.getElementById('Submit_pop')) document.getElementById('Submit_pop').disabled =
false;
if (document.getElementById('content' + conPostfix)) {
document.getElementById('content' + conPostfix).removeAttribute('data-submit');
}
};
postCORS(postUrl, function (data) {
data = data.replace(/\\/g, "\\\\");
try {
data = eval('(' + data + ')');
successHandle(data);
} catch (e) {
errorHandle();
}
completeHandle();
}, postData, {
withCookie: true
});
return false;
});
}
function cmt4_showAuditInfo(tag, editorId){
editorId = editorId || 'cmtEditor1';
var auditInfo = cmt4_getAuditInfo();
var ifr = document.getElementById(editorId);
var doc = ifr.contentWindow.document || ifr.contentDocument;
var obj = doc.body;
if(obj){
var v = cmt4_getCleanText(obj);
if(tag == 1){//显示
if(v == ""){
obj.innerHTML = auditInfo;
obj.style.color="#aaa";
}
}else{//不显示
if(v == auditInfo){
obj.innerHTML = "";
obj.style.color="#aaa";
}
}
}
}
function cmt4_showAuditInfo2(str,tag){
var s = str;
if(s=="0"||s=="2"||s=="3"){
s = document.getElementById("replyShowName").value;
}
var ifr = document.getElementById("cmtEditor_pop");
var doc = ifr.contentWindow.document || ifr.contentDocument;
var obj2 = doc.body;
if(obj2){
var v = cmt4_getCleanText(obj2);
if(tag == 1){//显示
if(v == "") {
obj2.innerHTML = s;
obj2.style.color="#aaa";
}
}else{//不显示
//alert('obj2.value='+v+'==s='+s+'flag'+(v == s));
if(v == s){
obj2.innerHTML = "";
obj2.style.color="#aaa";
}
if(s=="3"){
if(v == s){
obj2.innerHTML = "";
obj2.style.color="#aaa";
}
}
}
}
}
function cmt4_getExtraAuditInfo(){
var _extra_audit_info_ = "";
if("false"=="true"){ // todo: "false" 这里用了 OPEN_EXTRA_AUDIT_INFO 这个 jsp 变量
var sessionId = cmt4_loadSessionId();
if(sessionId!=null){ //登录
_extra_audit_info_ = "";
}else{
_extra_audit_info_ = "温馨Tips:登录后评论可直接发表。";
}
}
return _extra_audit_info_;
}
function cmt4_changeAuditInfoAfterLogin(){
var ifr = document.getElementById("cmtEditor1");
var doc = ifr.contentWindow.document || ifr.contentDocument;
var obj = doc.body,
v;
if(obj){
v = cmt4_getCleanText(obj);
if(v == "精彩评论将会增加您在论坛的影响力,恶意灌水用户将面临锁号处理。希望广大车友共同维护论坛的友好回复氛围。" || v == "评论内容10字以上可获1金币,30字以上可获3金币。切记!评论灌水将被关小黑屋" || v == "温馨Tips:登录后评论可直接发表,匿名评论须通过审核后才会被公开。" || v == "共建和谐社会,留言中请勿恶意攻击国家、党及其他用户或工作人员;请勿发布任何广告留言,我们将会予以删除或者冻结ID、封锁IP。营造文明友善、观点鲜明、顺畅沟通的良好评论环境,有赖您的支持与配合。"){
obj.innerHTML = cmt4_getAuditInfo();
}
}
}
// todo: 下面的 "false" == "true" 的判断是从后台写的?
function cmt4_getAuditInfo(){
var auditInfo = "精彩评论将会增加您在论坛的影响力,恶意灌水用户将面临锁号处理。希望广大车友共同维护论坛的友好回复氛围。";
if("false"=="true"){
var sessionId = cmt4_loadSessionId();
if(sessionId!=null){ //登录
auditInfo = "共建和谐社会,留言中请勿恶意攻击国家、党及其他用户或工作人员;请勿发布任何广告留言,我们将会予以删除或者冻结ID、封锁IP。营造文明友善、观点鲜明、顺畅沟通的良好评论环境,有赖您的支持与配合。";
}else{
auditInfo = "温馨Tips:登录后评论可直接发表,匿名评论须通过审核后才会被公开。";
}
}
//alert(auditInfo);
return auditInfo;
}
//初始化
cmt4_showAuditInfo(1);
if(document.getElementById('cmtEditor2')) {
cmt4_showAuditInfo(1, 'cmtEditor2');
}
String.prototype.replaceAll = function(s1,s2){
return this.replace(new RegExp(s1,"gm"),s2);
}
function cmt4_getLoginedHTML(accountName){
return "
欢迎您,\"/> | 退出 ".replaceAll("",accountName);
}
function cmt4_loadAccountName(){
var cmu = decodeURIComponent(cmt4_getCookie('cmu'));
var sessionId = cmt4_loadSessionId();
var resp_enc = 'gbk';
if(cmu != "" && cmu != "null" && cmu != "undefined" && sessionId!=null){
cmt4_usejq(function(){
$.getJSON("//my.pcauto.com.cn/intf/getLogedUser.jsp?resp_enc=" + resp_enc + "&callback=?",function(data){
var spanLogin = document.getElementById("loginSpan");
var spanPopLogin = document.getElementById("loginSpan_pop");
var showName = data.nickName || cmu;
var logindHtml = cmt4_getLoginedHTML(showName);
if(spanLogin && logindHtml!=''){
$("span[name='loginSpan']").each(function(index,item){
item.innerHTML = logindHtml.replaceAll('usernameInput','usernameInput_'+ index);
});
}
if(spanPopLogin && logindHtml!='') spanPopLogin.innerHTML = logindHtml;
flushFace(data);
// cmt4_prepareSync(data.id);
});
});
}
}
function flushFace(data){
$(".cmt4_myface").each(function(index,item){
item.src = cmt4_getAvatar(data.id);
$(item).parent().attr("href",$(item).parent().attr("href")+data.id);
});
}
var cmt4_fmComment983000089 = document.getElementById('fmComment983000089');
if(cmt4_fmComment983000089){
cmt4_loadAccountName();
}
// ===============================地区获取================================
var COOKIE_NAME_IP = "CMT4_IP_AREA";
function cmt4_getArea() {
var cookie = Get_Cookie(COOKIE_NAME_IP);
if(cookie) { // 存在cookie
// 直接把cookie值不为1时,传到input.area里。
if(cookie != 1 && document.getElementById("area")) {
document.getElementById("area").value = cookie;
if (document.getElementById("area1")) {
document.getElementById("area1").value = cookie;
}
}
} else { // 不存在
var script = document.createElement('script');
script.src = "//whois.pconline.com.cn/ipJson.jsp?callback=cmt4_getAreaBack";
document.getElementsByTagName('head')[0].appendChild(script);
}
}
function cmt4_getAreaBack(location) {
var area = "";
if(location.pro == location.city) {
area = location.city;
} else {
area = location.pro + location.city;
}
// 无论area是否获取,都应该写一个cookie标识。
if(!area) {
area = 1;
} else {
// 把结果写到input.area里
if(document.getElementById("area")){
document.getElementById("area").value = area;
if (document.getElementById("area1")) {
document.getElementById("area1").value = cookie;
}
}
}
// 把结果写到cookie
Set_Cookie(COOKIE_NAME_IP, area, 90, '/', '.pcauto.com.cn', '');
}
//这里要预先取一次,因为是ajax异步方式取用户IP所在地区,不能在用户提交表单的时候调用
cmt4_getArea();
// ===============================================================
// ===============================获取评论总数=======================
function getTopicTotal(){
return 0;
}
// ===============================获取查看评论的链接地址(即评论列表页)=======================
function getTopicUrl(){
return "//cmt.pcauto.com.cn/topic/a0/r0/p1/ps30/t.html"+('' == '' ? "?url=http://www.aryapackersandmovers.com/qcyp/fbm/wg/0708/576520.html&columnId=" : "");
}
// http://zzsvn.pcauto.com.cn/svn/pclady/lady2011/jp/showPopBox.html
function mergeObj(a, b) {
for (var c in b) {
a[c] = b[c]
}
return this
}
function stopBubble(a) {
if (a && a.stopPropagation) {
a.stopPropagation()
} else {
window.event.cancelBubble = true
}
}
function stopDefault(a) {
if (a && a.preventDefault) {
a.preventDefault()
} else {
window.event.returnValue = false
}
return false
}
var popBox = function(a) {
this.option = {
title: null,
content: "提示而已",
width: "350px",
closeable: true,
closeText: "close",
closeDelay: 0,
boxClass: "popBox",
okText: "确定",
cancelText: "取消",
okButton: false,
cancelButton: false,
focusOk: false,
focusCancel: false,
withLayer: true,
overlayIndex: 900,
boxIndex: 950
};
if (a) {
mergeObj(this.option, a)
}
this.init()
};
popBox.prototype = {
init: function() {
this.create();
this.bind();
this.show()
},
bind: function() {
var a = this,
c = a.option;
if (c.okEle) {
c.okEle.onclick = function(d) {
d = d || window.event;
a.ok();
stopDefault(d)
}
}
if (c.cancelEle) {
c.cancelEle.onclick = function(d) {
d = d || window.event;
a.cancel();
stopDefault(d)
}
}
if (c.closeEle) {
c.closeEle.onclick = function(d) {
d = d || window.event;
a.close();
stopDefault(d)
}
}
if (c.closeDelay) {
var b = parseInt(c.closeDelay, 10);
setTimeout(function() {
a.close()
},
b)
}
},
create: function() {
var k = this,
f = k.option;
if (f.withLayer) {
f.overlay = document.createElement("div");
f.overlay.className = "overlay";
f.overlay.style.zIndex = f.overlayIndex
}
var m = document.createElement("div");
m.className = f.boxClass;
var e = "";
if (f.title) {
e += '
'
}
e += '
' + f.content + "
";
if (f.okButton || f.cancelButton) {
var b = f.focusOk ? "aBtn iOk": "iOk",
j = f.focusCancel ? "aBtn iCancel": "iCancel";
e += '
';
if (f.cancelButton) {
e += '' + f.cancelText + ""
}
if (f.okButton) {
e += '' + f.okText + ""
}
e += "
"
}
e += "
";
m.innerHTML = e;
f.ele = m;
var g = m.getElementsByTagName("a");
for (var d = 0, c = g.length; d < c; d++) {
var h = g[d];
if (h.className.indexOf("close") != - 1) {
f.closeEle = h
} else {
if (h.className.indexOf("iOk") != - 1) {
f.okEle = h
} else {
if (h.className.indexOf("iCancel") != - 1) {
f.cancelEle = h
}
}
}
}
},
close: function() {
var a = this.option;
document.body.removeChild(a.ele);
a.overlay && document.body.removeChild(a.overlay)
},
ok: function() {
var a = this,
b = a.option;
if (b.okCallback) {
b.okCallback()
}
a.close()
},
cancel: function() {
var a = this,
b = a.option;
if (b.cancelCallback) {
b.cancelCallback()
}
a.close()
},
show: function() {
var g = this.option,
c, b, a = (document.compatMode && document.compatMode.toLowerCase() == "css1compat") ? document.documentElement: document.body;
if (window.innerWidth) {
c = window.innerWidth
} else {
if (a) {
c = a.clientWidth
}
}
if (window.innerHeight) {
b = window.innerHeight
} else {
if (a) {
b = a.clientHeight
}
}
if (g.overlay) {
document.body.appendChild(g.overlay)
}
document.body.appendChild(g.ele);
var f = document.documentElement.scrollTop ? document.documentElement.scrollTop: document.body.scrollTop;
var e = f + (b - g.ele.offsetHeight) / 2;
var d = (c - g.ele.offsetWidth) / 2;
g.ele.style.position = "absolute";
g.ele.style.zIndex = g.boxIndex;
g.ele.style.top = e + "px";
g.ele.style.left = d + "px"
}
};
function openLink(enName) {
var loginBind = "//my.pcauto.com.cn/passport/opens/bind_done.jsp";
window.open("https://passport3.pcauto.com.cn/passport3/api/open_oauth2.jsp?loginBind=" + loginBind + "&type=" + enName + "&return=https://www1.pcauto.com.cn/global/2013/blank.html", "oauth");
}
// 网站标识,个人中心需要,截去 pc
var siteName = 'auto';
// 网站连接状态,1表示已连接,0表示未连接
var siteLinkStatus = {};
//当前选择的同步分享状态,默认应和网站连接状态相同
var siteSyncSelect = {};
var cmt_accountId;
function cmt4_prepareSync(id) {
cmt_accountId = id;
cmt4_getBindStatus(id, function() {
$('.cmtSync').show();
});
}
function cmt4_getBindStatus(id, cb) {
var types = ['qzone', 'sina'];
for (var i = 0, l = types.length; i < l; i++) {
types[i] += '_' + siteName;
}
var url = 'https://passport3.pcauto.com.cn/passport3/api/bind_status.jsp?id=' + id + '&callback=cmt4_parseBindStatus&type=' + types.join(',');
var head = document.getElementsByTagName('head')[0];
var scr = document.createElement('script');
scr.charset = 'gbk';
scr.src = url;
if (cb) {
scr.onload = scr.onreadystatechange = function() {
if ((!this.readyState || this.readyState === "loaded" || this.readyState === "complete")) {
cb();
// 防止IE内在溢出
scr.onload = scr.onreadystatechange = null;
if (head && scr.parentNode) head.removeChild(scr);
}
};
}
head.appendChild(scr);
}
function cmt4_parseBindStatus(status) {
if (status.status == - 1) {
return;
}
var data = status.data,
name;
for (var i = 0, l = data.length; i < l; i++) {
name = data[i]['enName'];
name = name.slice(0, name.indexOf('_' + siteName));
siteLinkStatus[name] = data[i];
}
}
// 把当前同步选择变成字符串已发送到后台,由后台来实现同步发送到微博等
function cmt4_getSyncStr() {
return 'syncsites=' + cmt4_getSyncStr();
}
function cmt4_getSyncStrVal() {
var str = '',
arr = [];
for(var i in siteSyncSelect) {
if (siteSyncSelect[i]) {
arr.push(i);
}
}
return arr.join(',');
}
function cmt4_syncShareStatus() {
$('.cmtSite').each(function() {
var $this = $(this);
var site = $this.attr('data-site');
if (siteSyncSelect[site]) {
$this.addClass(site + 'on');
} else {
$this.removeClass(site + 'on');
}
});
}
cmt4_usejq(function() {
var siteText = {
'sina': '新浪微博',
'qzone': 'QQ'
};
$('.cmtSite').click(function() {
var $this = $(this),
site = $this.attr('data-site');
if (!siteLinkStatus[site].isBand) {
var lpox = new popBox({
//title: '提示',
boxClass: 'cmtPopBox',
content: '获取绑定状态中……'
});
cmt4_getBindStatus(cmt_accountId, function() {
lpox.close();
if (siteLinkStatus[site].isBand) {
siteSyncSelect[site] = siteSyncSelect[site] == 1 ? 0: 1;
cmt4_syncShareStatus();
} else {
showBindNotice(site);
}
});
return;
}
siteSyncSelect[site] = siteSyncSelect[site] == 1 ? 0: 1;
cmt4_syncShareStatus();
});
function showBindNotice(site) {
var msg = '您的账号还没与' + siteText[site] + '账号进行绑定,是否现在进行绑定?';
new popBox({
boxClass: 'cmtPopBox',
title: '提示',
content: msg,
okButton: true,
cancelButton: true,
focusOk: true,
okCallback: function() {
openLink(site + '_' + siteName);
}
});
}
});
// 把 iframe 变成编辑模式,同时和其兄弟节点 textarea 进行关联,用于最后拷贝内容过去
cmt4_usejq(function(){
$(document).on('click', '.cmtCover', function(event) {
event.preventDefault();
if(!(Get_Cookie('common_session_id') && Get_Cookie('cmu'))) {
showFB('login');
return false;
}else{
$('.cmtCover').hide();
}
});
})
function initEditor(ifr) {
if (ifr.id=='cmtEditor2' || ifr.id=='cmtEditor1') {
$(ifr).parent().css({
position:'relative',
overflow:'hidden'
}).append('
')
}
var textarea = $(ifr).siblings('.tbxCmt').get(0);
var doc = ifr.contentDocument || ifr.contentWindow.document;
var cw = ifr.contentWindow;
doc.designMode = 'on';
var defaultHtml = '';
doc.open();
doc.write(defaultHtml);
doc.close();
doc.body.contenteditable = 'true';
// firefox 使用 jQuery 1.2.6 在 body 上 bind 有问题
// ie6 下 onkeypress 时 传递的 event 有问题,导致 cmt4_keypress 异常
if(navigator.userAgent.indexOf('Firefox') !== -1) {
doc.body.onkeypress = function(e){
e = e || window.event;
cw.parent.cmt4_keypress(textarea, e);
};
doc.body.onfocus = function() {
if(ifr.id == 'cmtEditor_pop') {
cw.parent.cmt4_showAuditInfo2(3, 0);
} else {
cw.parent.cmt4_showAuditInfo(0, ifr.id);
}
doc.body.style.color = '#000';
};
doc.body.onblur = function(){
if(ifr.id == 'cmtEditor_pop') {
cw.parent.cmt4_showAuditInfo2(2, 1);
} else {
cw.parent.cmt4_showAuditInfo(1, ifr.id);
cw.parent.cmt4_copyContent(textarea);
}
};
} else {
$(doc.body).bind('keypress',function(e){
e = e || window.event;
cw.parent.cmt4_keypress(textarea, e);
})
.bind('focus', function(){
if(ifr.id == 'cmtEditor_pop') {
cw.parent.cmt4_showAuditInfo2(3, 0);
} else {
cw.parent.cmt4_showAuditInfo(0, ifr.id);
}
doc.body.style.color = '#000';
})
.bind('blur', function(){
if(ifr.id == 'cmtEditor_pop') {
cw.parent.cmt4_showAuditInfo2(2, 1);
} else {
cw.parent.cmt4_showAuditInfo(1, ifr.id);
cw.parent.cmt4_copyContent(textarea);
}
});
}
// 默认状态
if(ifr.id == 'cmtEditor_pop') {
cw.parent.cmt4_showAuditInfo2(2, 1);
} else {
cw.parent.cmt4_showAuditInfo(1, ifr.id);
cw.parent.cmt4_copyContent(textarea);
}
if(navigator.userAgent.indexOf('MSIE') !== -1) {
var bookmark;
//记录IE的编辑光标
$(ifr).bind("beforedeactivate",function(){//在文档失去焦点之前
var range = doc.selection.createRange();
bookmark = range.getBookmark();
});
//恢复IE的编辑光标
$(ifr).bind("activate",function(){
if(bookmark){
var range = doc.body.createTextRange();
range.moveToBookmark(bookmark);
range.select();
bookmark = null;
}
});
}
}
function insertToCursor(iframe, html){
iframe.contentWindow.focus();
var iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
if(iframeDocument.selection){
/****这里需要解决IE丢失光标位置的问题,详见核心代码四**************/
iframeDocument.selection.createRange().pasteHTML(html);
}else{
var selection = iframe.contentWindow.getSelection();
var range;
if (selection) {
if(selection.rangeCount < 1) return;
range = selection.getRangeAt(0);
}else {
range = iframeDocument.createRange();
}
var oFragment = range.createContextualFragment(html),
oLastNode = oFragment.lastChild ;
range.insertNode(oFragment) ;
range.setEndAfter(oLastNode ) ;
range.setStartAfter(oLastNode );
selection.removeAllRanges();//清除选择
selection.addRange(range);
}
}
function bindHoverReply() {
$('.reply').bind('mouseenter', function(e) {
$(this).parents('.cmtMainIn').find('.reply .cmtOperate').css('visibility', 'hidden');
$(this).children('.tbTB').children('.cmtOperate').css('visibility', 'visible');
})
.bind('mouseleave', function(e) {
$(this).children('.tbTB').children('.cmtOperate').css('visibility', 'hidden');
var $p = $(this).parent();
if($p.hasClass('reply')) {
$p.children('.tbTB').children('.cmtOperate').css('visibility', 'visible');
} else if($p.hasClass('tbTB')) {
$p.children('.cmtOperate').css('visibility', 'visible');
}
});
}
function bindHoverShare() {
$('.cmtOperate .share').hoverIntent({
over: toggleShare,
out: toggleShare,
timeout: 300
});
}
function toggleShare() {
$(this).toggleClass('shareOn');
}
function cmt4_getAvatar(id) {
id = '' + id; // make sure is string
// 每两位用 / 分割,最后可能剩一位
var ret = [], i = 0, l = id.length;
while(i + 2 <= l) {
ret.push(id.slice(i, i+2));
i += 2;
}
if(i < l) {
ret.push(id.charAt(i));
}
return '//i6.3conline.com/images/upload/upc/face/' + ret.join('/') + '/' + id + '_50x50';
}
function bindVoteEvent() {
cmtAddEvent(document.body,'click',function(e){
e = window.event || e;
var target = e.target || e.srcElement,el;
if(el = cmtGetParent(target,'cmtVote')){
e.preventDefault ? e.preventDefault() : (e.returnValue = false);
if($(el).data('done') != '1'){
cmt4_vote(el);
}
}
})
}
//new comment add bind
function bindVoteEventNew(){
$('.cmtOperate .cmtNew').bind('click', function(e){
if($(this).data('done') != '1'){
cmt4_vote(this);
}
e.preventDefault();
});
$('.cmtOperate .cmtNew').attr('class','cmtVote');
}
// 点击登录