';
switch (this.UserLoginType.toLowerCase()) {
case "joins":
html += '중앙일보로 로그인';
break;
case "facebook":
html += '페이스북으로 로그인';
break;
case "twitter":
html += '트위터로 로그인';
break;
case "kakao":
html += '카카오톡으로 로그인';
break;
default:
html += '중앙일보로 로그인';
break;
}
html += '
';
html += '
';
html += '
';
if (this.IsReporter === true) {
html += '' + userID + '';
}
else {
html += '' + userID + '';
}
html += '' + this.RegistedDateTime.toDateISO8061().format('yyyy.MM.dd HH:mm') + '';
html += '';
html += '
';
//html += '작성자의 댓글 모아보기';
if (isMyWriting) {
//if (!delFlag) {
html += '삭제';
//}
}
else {
html += '신고하기';
}
html += '
';
$("#comment").removeClass();
$("#comment").addClass('cmt_wrap');
$("#comment").html(html);
if (type !== 'none') {
fnCommentItem(commentDatas);
$("#bd_comment").show();
}
if (config.sortType === "like") {
$("#li_sort_like").addClass("on");
} else {
$("#li_sort_new").addClass("on");
}
$('#head').find('.btn_cmt').html('댓글' + commentDatas.displayCount + '');
$("#cmt_total_count").text('댓글 ' + commentDatas.displayCount + '개');
// 아티클 하단 총 댓글 수 표시
if (commentDatas.displayCount > 0) {
$("#btn_comment").html('' + commentDatas.displayCount + '');
}
//article_cmt_cnt
// 로그인 처리
if (isLogin) {
switch (userInfo.type.toLowerCase()) {
case "joins":
$("#my_cmt").show();
$("#login_i_jb").addClass("on");
break;
case "facebook":
$("#login_i_fb").addClass("on");
break;
case "twitter":
$("#login_i_tw").addClass("on");
break;
case "kakao":
$("#login_i_kk").addClass("on");
break;
}
$(".cmt_write").removeClass("cmt_login");
$(".cmt_write").addClass("cmt_focus");
}
//간편로그인 열기
$(".cmt_login, .sns a").on('click', function () {
$("#layer_snslogin").toggleClass("layeron");
return false;
});
//레이어 닫기
$("#btn_close_comment").on('click touchstart', function () {
$(".fulllayer, .tooltip_box").removeClass("layeron");
return false;
});
//툴팁 레이어 오픈
$(".btn_tooltip").each(function () {
$(this).on('click', function () {
$(this).next().toggleClass("layeron");
return false;
});
});
////삭제 레이어 오픈
//$(".tooltip_box a[data-action='del']").each(function () {
// $(this).on('click touchstart', function () {
// $("#layer_cmtdel").toggleClass("layeron");
// return false;
// });
//});
//새로고침
$(".btn_refresh").on('click', function () {
location.reload();
});
////레이어 외 누르면 레이어 닫힘
//$(document).on('click touchstart', function (e) {
// if (e.target === undefined) return;
// var $target = $(e.target);
// if ($target.closest(".layer_login, .tooltip_box").length === 0) {
// $(this).find(".fulllayer, .tooltip_box").removeClass("layeron");
// }
//});
//textarea 입력 시
$("#txtcmt").keyup(function () {
//textarea 에 글을 입력하면 자동 리사이징
$(this).css("height", "1px").css("height", (4 + $(this).prop("scrollHeight")) + "px");
//textarea 에 글을 입력하면 스크롤 제거
$("body").find(".full_cmt .bd").removeClass("bd_scroll");
//textarea 글자 제한
if ($(this).val().length > 500) {
$(this).val($(this).val().substring(0, 500));
alert("500자를 초과 입력 할 수 없습니다.");
}
if ($(this).val().length !== 0 || $("#txtReplyId").val().length !== 0) {
$("#div_check_area").show();
}
if ($(this).val().length === 0 && $("#txtReplyId").val().length === 0) {
$("#div_check_area").hide();
$("body").removeAttr("style");
$(".bd").addClass("bd_scroll");
}
});
$("#txtcmt").change(function () {
//textarea 글자 제한
if ($(this).val().length > 500) {
$(this).val($(this).val().substring(0, 500));
alert("500자를 초과 입력 할 수 없습니다.");
}
if ($(this).val().length !== 0 || $("#txtReplyId").val().length !== 0) {
$("#div_check_area").show();
}
if ($(this).val().length === 0 && $("#txtReplyId").val().length === 0) {
$("#div_check_area").hide();
$("body").removeAttr("style");
$(".bd").addClass("bd_scroll");
}
});
}
function init(sort) {
if ($("#comment").length === 0) {
var html = '';
$("body").prepend(html);
}
if ($("#isReplyUserId").length === 0) {
var html = '';
$("#comment").before(html);
}
try {
config.referUrl = config.referUrl !== '' ? config.referUrl : REFER_URL[config.page];
config.perPage = 5;
config.sortType = sort;
} catch (e) { alert('잘못된 호출입니다.'); }
fnCommentList(commentDatas, 'none');
getCommentList({
callback: function (datas) {
updateCommentDatas(datas, true);
fnCommentList(datas, '');
}
});
//button events
$("#comment").unbind();
if (config.enabledCopy === false) {
$("#comment").on('copy', 'textarea', function () {
alert(commentLanguage.errorCopy);
return false;
});
}
if (config.enabledPaste === false) {
$("#comment").on('paste', 'textarea', function () {
alert(commentLanguage.errorPast);
return false;
});
}
$("#comment").on('click', '.btn_reply', function () {
var $reply = $(this);
$("#txtReplyId").val($reply.data('replyid'));
$("#emReplyId").html($reply.data('replyname'));
$("#div_check_area").show();
$("#txtcmt").focus();
return false;
}).on('click', '.btn_recomm', function () {
var $up = $(this);
commentVotePost({
type: 'like',
id: $up.data('voiteid'),
callback: function (res) {
var code = res.Code;
if (res.IsSuccess) {
var goodCount = parseInt($up.find('.good').text(), 10);
$up.find('.good').text(goodCount + 1);
} else {
switch (code) {
case 'Duplicated':
msg = '중복된 참여입니다.';
break;
case 'NotPeriod':
msg = '기간이 아닙니다.';
break;
default:
msg = '데이타 처리에 문제가 발생하였습니다.';
break;
}
alert(msg);
}
}
});
return false;
}).on('click', '.report', function () {
var $report = $(this);
var result = confirm(commentLanguage.reportMessage);
if (result === true) {
commentReportPost({ id: $report.data('reportid') });
}
return false;
}).on('click', '.delete', function () {
var $delete = $(this),
deleteId = $delete.data('deleteid');
var opts = {
id: deleteId,
callback: function () {
alert(commentLanguage.deleteComment);
commentDatas.displayCount = commentDatas.displayCount - 1;
var count = parseInt($("#sp_displayCount").text(), 10);
if (count > 0) {
$(".displayCount").text(count - 1);
$('#head').find('.btn_cmt').html('댓글' + (count - 1) + '');
}
if (commentDatas.displayCount == 0) {
$('#head').find('.btn_cmt').html('댓글0');
fnCommentList(commentDatas, 'none');
} else {
$("#li_" + deleteId).remove();
}
}
};
if (config.page === 'article') {
opts.totalid = $delete.data('targetid');
}
if (config.page === 'reporter') {
opts.reporterid = $delete.data('targetid');
}
commentDeletePost(opts);
return false;
}).on('click', '.btn_del', function () {
$("#txtReplyId").val('');
$("#emReplyId").html('');
$("#txtcmt").val('');
$("#txtcmt").css("height", "1px").css("height", (4 + $("#txtcmt").prop("scrollHeight")) + "px");
$("#txtcmt").focus();
$("#div_check_area").hide();
$("body").removeAttr("style");
$(".bd").addClass("bd_scroll");
return false;
}).on('focus', '#div_cmt_write', function () {
var $write = $(this);
$write.removeClass("cmt_focus");
$write.addClass("cmt_open cmt_writing");
//$("#div_check_area").show();
return false;
}).on('click', '.sns_login', function () {
commentUserInfo.logout(); //cookie remove
commentUserInfo.init(); // get cookie
}).on('click', '#sort_like', function () {
config.currentPage = 1;
init('like');
}).on('click', '#sort_new', function () {
config.currentPage = 1;
init('new');
}).on('submit', 'form', function () {
var value = $("#txtcmt").val();
var seq = $("#txtReplyId").val();
if (isWrite === false) {
alert(commentLanguage.errorWrite);
return false;
}
if (value.length === 0 || value.replace(/(^\s*)|(\s*$)/g, "").length === 0) {
emptyComment($("#txtcmt"));
return false;
}
if (seq === "") {
seq = 0;
}
submitComment({
seqId: seq,
content: value,
callback: function (resData) {
if (resData.IsSuccess == true) {
if (seq === 0) {
var html = '';
var userID = '';
if (resData.Item.UserLoginType.toLowerCase() === 'joins' && resData.Item.IsReporter === true) {
userID = resData.Item.UserName + ' ' + commentLanguage.isReporter;
} else if (resData.Item.UserLoginType.toLowerCase() === 'joins' && resData.Item.IsJplusJouralist === true) {
userID = resData.Item.UserName;
} else if (resData.Item.UserLoginType.toLowerCase() !== 'joins') {
userID = resData.Item.UserName;
} else {
userID = resData.Item.UserId;
}
if (resData.Item.IsReporter !== true) {
if (userID.length > 4) {
userID = userID.substring(0, 4) + "****";
} else {
var len = userID.length / 2;
userID = userID.substring(0, len) + "****";
}
}
html += '
';
html += '';
html += '
';
switch (resData.Item.UserLoginType.toLowerCase()) {
case "joins":
html += '중앙일보로 로그인';
break;
case "facebook":
html += '페이스북으로 로그인';
break;
case "twitter":
html += '트위터로 로그인';
break;
case "kakao":
html += '카카오톡으로 로그인';
break;
default:
html += '중앙일보로 로그인';
break;
}
html += '
';
html += '
';
html += '
';
html += '' + userID + '';
html += '' + resData.Item.RegistedDateTime.toDateISO8061().format('yyyy.MM.dd HH:mm') + '';
html += '';
html += '
';
$(".cmt_lst").prepend(html);
//툴팁 레이어 오픈
$("#btn_tooltip_" + resData.Item.Id).on('click', function () {
$("#btn_tooltip_" + resData.Item.Id).next().toggleClass("layeron");
return false;
});
$("#li_" + resData.Item.Id).on('click', '.delete', function () {
var $delete = $(this),
deleteId = $delete.data('deleteid');
var opts = {
id: deleteId,
callback: function () {
alert(commentLanguage.deleteComment);
commentDatas.displayCount = commentDatas.displayCount - 1;
var count = parseInt($("#sp_displayCount").text(), 10);
if (count > 0) {
$(".displayCount").text(count - 1);
$('#head').find('.btn_cmt').html('댓글' + (count - 1) + '');
}
if (commentDatas.displayCount == 0) {
$('#head').find('.btn_cmt').html('댓글0');
fnCommentList(commentDatas, 'none');
} else {
$("#li_" + deleteId).remove();
}
}
};
if (config.page === 'article') {
opts.totalid = $delete.data('targetid');
}
if (config.page === 'reporter') {
opts.reporterid = $delete.data('targetid');
}
commentDeletePost(opts);
return false;
}).on('click', '.btn_reply', function () {
var $reply = $(this);
$("#txtReplyId").val($reply.data('replyid'));
$("#emReplyId").html($reply.data('replyname'));
$("#txtcmt").focus();
return false;
});
} else {
var html = '';
var userID = '';
if (resData.Item.UserLoginType.toLowerCase() === 'joins' && resData.Item.IsReporter === true) {
userID = resData.Item.UserName + ' ' + commentLanguage.isReporter;
} else if (resData.Item.UserLoginType.toLowerCase() === 'joins' && resData.Item.IsJplusJouralist === true) {
userID = resData.Item.UserName;
} else if (resData.Item.UserLoginType.toLowerCase() !== 'joins') {
userID = resData.Item.UserName;
} else {
userID = resData.Item.UserId;
}
if (resData.Item.IsReporter !== true) {
if (userID.length > 4) {
userID = userID.substring(0, 4) + "****";
} else {
var len = userID.length / 2;
userID = userID.substring(0, len) + "****";
}
}
var isRelpyID = $("#emReplyId").html();
html += '
';
html += '';
html += '
';
switch (resData.Item.UserLoginType.toLowerCase()) {
case "joins":
html += '중앙일보로 로그인';
break;
case "facebook":
html += '페이스북으로 로그인';
break;
case "twitter":
html += '트위터로 로그인';
break;
case "kakao":
html += '카카오톡으로 로그인';
break;
default:
html += '중앙일보로 로그인';
break;
}
html += '
';
html += '
';
html += '
';
html += '' + userID + '';
html += '' + resData.Item.RegistedDateTime.toDateISO8061().format('yyyy.MM.dd HH:mm') + '';
html += '';
html += '