1/************************************************** 2 COMMENT SCRIPT FILE 3 4 AUTHOR : DOTI 5 FILE : /fine_home/comment/comment.js 6 NOTE : ëê¸ ì¬ì©ì ìí 기본ì ì¸ ì¤í¬ë¦½í¸ íì´ì§ 7 8 **************************************************/ 9 10var $comment = { 11 12 member_check : '' // íìì¬ë¶ 13 , service_code : '' // íì¬ ì´ì© ìë¹ì¤ 14 , bbs_table : '' // ê²ìí ì´ì©ì ê²ìí í ì´ë¸ëª 15 , list_exc_idxno : '' // BEST ëê¸ ë ¸ì¶ë¡ ëê¸ì ì ì¸í idxno ë²í¸ ( 콤ë§(,) 구ë¶) 16 , best_container : $('#comment-list .best-content') // BEST ëê¸ ë¦¬ì¤í¸ íì ê°ì²´ 17 , list_container : $('#comment-list .normal-content') // ëê¸ ë¦¬ì¤í¸ íì ê°ì²´ 18 , list_total_count : $('#comment .comment-count') // ëê¸ ì´ ê°¯ì íì ê°ì²´ 19 , btn_cmt_more : $('#comment .btn-comment-more') // ëê¸ ë보기 ë²í¼ ê°ì²´ 20 , btn_cmt_save : $('#comment .btn-comment-save') // ëê¸ ë±ë¡ ë²í¼ ê°ì²´ 21 , reveal_delete : $('#comment-reveal-delete') // ëê¸ ìì ëª¨ë¬ ì°½ ê°ì²´ 22 , reveal_modify : $('#comment-reveal-modify') // ëê¸ ìì ëª¨ë¬ ì°½ ê°ì²´ 23 24 25 // ëê¸ ì¤ì ë¶ë¬ì¤ê¸° 26 , commentConfigSet:function(){ 27 $.ajax({ 28 url:'/comment/commentConfig.ajax.php', 29 method:'GET', 30 data:{service_code:$comment.service_code, bbs_table:$comment.bbs_table}, 31 dataType:'JSON', 32 cache: true, 33 success:function(data){ 34 // config set 35 for (var key in data) $comment[key] = data[key]; 36 //console.log('%cCOMMENT :: %c'+$comment.ver+'', 'background:black; color:yellow', 'background:black; color:white;'); 37 38 // Best Comment 39 if($comment.best_comment[0]) $comment.bestComment($comment.best_comment[1], $comment.best_comment[2]); 40 41 // List Comment 42 setTimeout(function(){ 43 $comment.commentList('load', 1, $comment.default_order_by); 44 }, ($comment.best_comment[0])?$comment.load_delay_time:0); // ë² ì¤í¸ ëê¸ ë¡ë©ì´ íìí ê²½ì° ë² ì¤í¸ ëê¸ idxno ê°ì ì»ê¸° ìí´ ì§ì°ìí´ 45 } 46 /* 47 ,error : function(request, status, error) { 48 alert("code: "+request.status+"\n"+"message: "+request.responseText+"\n"+"error: "+error); 49 } 50 */ 51 }); 52 53 return true; 54 } 55 56 57 // ëê¸ ê°¯ì íì 58 , TotalCount:function(str){ // íì 문ì 59 $comment.list_total_count.text(str); 60 } 61 62 63 // ë² ì¤í¸ ëê¸ ë¶ë¬ì¤ê¸° 64 , bestComment:function(num, limit){ // num:ëµê¸+ì¶ì² ì«ì | limit: 1~3 íì 65 $.ajax({ 66 url:'/comment/bestComment.ajax.php', 67 method:'GET',
68 data:{member_check:$comment.member_check, service_code:$comment.service_code, bbs_table:$comment.bbs_table, parent_idxno:$comment.parent_idxno, num:num, limit:limit}, 69 dataType:'HTML', 70 cache:true, 71 success:function(data){ 72 $comment.best_container.prepend(data); 73 $comment.list_exc_idxno = $comment.best_container.find('#list-exc-idxno').val(); 74 } 75 }); 76 } 77 78 79 // ëê¸ ëª©ë¡ ë¶ë¬ì¤ê¸° 80 , commentList:function(mode, comment_page, order_by){ // mode:load(ê°±ì ) or add(ì¶ê°) | comment_page:íì´ì§ë²í¸ | order_by:I(ìµì ì¶) or C(ì¶ì²ì) or R(ëµê¸ì) 81 $.ajax({ 82 url:'/comment/commentList.ajax.php', 83 method:'GET', 84 data:{member_check:$comment.member_check, service_code:$comment.service_code, bbs_table:$comment.bbs_table, parent_idxno:$comment.parent_idxno, comment_page:comment_page, order_by:order_by, list_exc_idxno:$comment.list_exc_idxno, mode:mode}, 85 dataType:'HTML', 86 cache:true, 87 success:function(data){ 88 if(mode == 'load') $comment.list_container.html(data); 89 else if(mode == 'add') $comment.list_container.append(data); 90 91 $('#comment .btn-comment-orderby').removeClass('secondary').addClass('nd-gray'); 92 $('#comment .btn-comment-orderby-'+order_by).toggleClass('secondary nd-gray'); 93 } 94 }); 95 } 96 97 98 // ëµê¸ ëª©ë¡ ë¶ë¬ì¤ê¸° 99 , commentSubList:function(reply_parent_idxno, mode){ // reply_parent_idxno:ë¶ëª¨ëê¸ë²
99í¸ 100 101 var sub_item = $('#comment #comment-item-'+reply_parent_idxno+'-sub'), 102 sub_page = sub_item.find('.comment-sub-page').val(), 103 order_by = sub_item.find('.comment-sub-orderby').val(); 104 105 if(mode == 'add') sub_page++; 106 if(mode == 'input') order_by = 'D'; 107 108 $.ajax({ 109 url:'/comment/commentSubList.ajax.php', 110 method:'GET', 111 data:{member_check:$comment.member_check, service_code:$comment.service_code, bbs_table:$comment.bbs_table, parent_idxno:$comment.parent_idxno, reply_parent_idxno:reply_parent_idxno, sub_page:sub_page, order_by:order_by, mode:mode}, 112 dataType:'HTML', 113 cache:true, 114 success:function(data){ 115 116 if(mode == 'reload'){ 117 sub_item.find('.comment-item-sub-body').html(data); 118 sub_item.find('.btn-sub-comment-orderby').removeClass('secondary'); 119 sub_item.find('.btn-sub-comment-orderby-'+order_by).addClass('secondary'); 120 } 121 122 if(mode == 'input'){ 123 sub_item.find('.comment-item-sub-body').html(data); 124 sub_item.find('.btn-sub-comment-orderby').removeClass('secondary'); 125 sub_item.find('.btn-sub-comment-orderby-D').addClass('secondary'); 126 sub_item.find('.comment-sub-orderby').val('D'); 127 } 128 129 if(mode == 'load'){ 130 sub_item.find('.comment-item-sub-body').html(data); 131 sub_item.find('.btn-sub-comment-orderby').removeClass('secondary'); 132 sub_item.find('.btn-sub-comment-orderby-A').addClass('secondary'); 133 134 if(sub_item.is(':visible') == false){ 135 if($comment.auto_sub_comment) sub_item.show(); 136 else sub_item.slideDown(); 137 } else { 138 sub_item.find('.comment-item-sub-body').html(''); 139 sub_item.find('.comment-sub-page').val(1); 140 sub_item.find('.comment-sub-orderby').val('A'); 141 sub_item.hide(); 142 } 143 } 144 145 if(mode == 'add'){ 146 sub_item.find('.comment-item-sub-body').append(data); 147 sub_item.find('.comment-sub-page').val(sub_page); 148 149 if($comment.auto_sub_comment) sub_item.show(); 150 else sub_item.slideDown(); 151 } 152 } 153 }); 154 } 155 156 157 // ëê¸ / ëµê¸ ë보기 ë²í¼ 158 , btnMore:function(mode, moreBtn){ // mode:show(ë³´ì´ê¸°) or hide(ì¨ê¸°ê¸°) | ë보기 ë²í¼ ê°ì²´ 159 if(!moreBtn) moreBtn = $comment.btn_cmt_more; 160 161 if(mode == 'show') moreBtn.html('<div class="more-info"><span>ë보기</span></div>').show(); 162 else if(mode == 'none') moreBtn.hide(); 163 else if(mode == 'hide') { 164 if($comment.more_btn_slow_hide == true){ // ë²í¼ì´ ììí ì¬ë¼ì§ê¸°ë¥¼ ìíë ê²½ì° 165 moreBtn.html('<div class="more-info-text"><i class="icon-error-o"></i> ëì´ì ëê¸ì´ ì¡´ì¬íì§ ììµëë¤</div>'); 166 setTimeout(function(){ 167 moreBtn.fadeOut(); 168 moreBtn.hide(); 169 }, 2000); // ëìì¸ ìì í ì¤í 170 } else { // ë²í¼ì´ ììí ì¬ë¼ì§ê¸°ë¥¼ ìíì§ ìë ê²½ì° 171 moreBtn.hide(); // ëìì¸ ìì í ì¤í 172 } 173 } 174 } 175 176 177 // ëê¸ ì°ê¸° 178 , commentWrite:function(f){ // f:í¼ ê·¸ë£¹ 179 180 var writeFormErr = false; 181 182 //// ì´ë¦ ë° ëê¸ ìì± íì¸ 183 if( !f.find('input[name="user_id"]').val() && !f.find('input[name="password"]').val() ){ 184 f.find('input[name="password"]').focus() 185 writeFormErr = 'ë¹ë°ë²í¸ë¥¼'; 186 } 187 if( !f.find('input[name="name"]').val() ){ 188 f.find('input[name="name"]').focus() 189 writeFormErr = 'ì´ë¦ì'; 190 } 191 if( !f.find('textarea[name="content"]').val() ){ 192 f.find('textarea[name="content"]').focus() 193 writeFormErr = '본문ì'; 194 } 195 196 if(writeFormErr){ 197 $('.recaptcha-view').remove(); 198 alert('[Error.8] '+writeFormErr+' ë°ë¥´ê² ì ë ¥íì¸ì.'); 199 return false; 200 201 } 202 203 //// ìº¡ì± íì¸ 204 if( $comment.captcha_view == 'Y' && $comment.captcha_enable == true && !f.find('input[name="captcha"]').val() ){ 205 206 $('.recaptcha-view').remove(); 207 208 $.ajax({ 209 url:'/comment/recaptcha.ajax.php', 210 dataType:'HTML', 211 cache: false, 212 success:function(data){ 213 f.find('.recaptcha-container').append('<div class="recaptcha-view">'+data+'</div>'); 214 } 215 }); 216 217 return false; 218 } 219 220 //// ì ì¥ 221 $.ajax({
222 url:'/comment/commentWrite.ajax.php', 223 method:'POST', 224 data:f.serialize()+'&captcha_view='+$comment.captcha_view, 225 dataType:'JSON', 226 cache: false, 227 success:function(data){ 228 229 if(data['result'] == true){ 230 $comment.commentWriteAdd(data['mode'], data['idxno'], data['reply_parent_idxno']); 231 if($comment.member_check == 'GUEST') f.find('.name, .password, .comment-content, .nomember-captcha').val(''); 232 else f.find('.password, .comment-content, .nomember-captcha').val(''); 233 f.find('.comment-text-cur').text('0'); 234 $('.recaptcha-view').remove(); 235 236 if(data['mode'] == 'sub_input'){ 237 var cmt_sub_count = ($('#comment-item-'+data['reply_parent_idxno']+' .comment-sub-count').text() == "ìì±")? 1:Number($('#comment-item-'+data['reply_parent_idxno']+' .comment-sub-count').text()) + 1; 238 $('#comment-item-'+data['reply_parent_idxno']+' .comment-sub-count').html('<small>'+cmt_sub_count+'</small>'); 239 } 240 241 } else if(data['result'] == false) { 242 alert(data['msg']); 243 f.find('#nomember-captcha').val(''); 244 $('.recaptcha-view').remove(); 245 } 246 } 247 }); 248 } 249 250 251 // ëê¸ ìì± í ì¶ê° 252 , commentWriteAdd:function(mode, idxno, reply_parent_idxno){ // mode:reply or sub_reply | idxno:ëê¸ë²í¸ | reply_parent_idxno:ë¶ëª¨ëê¸ë²
252í¸ 253 $.ajax({ 254 url:'/comment/commentWriteAdd.ajax.php', 255 method:'GET', 256 data:{member_check:$comment.member_check, service_code:$comment.service_code, bbs_table:$comment.bbs_table, parent_idxno:$comment.parent_idxno, mode:mode, idxno:idxno}, 257 dataType:'HTML', 258 cache: true, 259 success:function(data){ 260 // ëê¸ ì¶ê° 261 if(mode == 'input'){ 262// addElm = $comment.list_container; 263// addElm.prepend(data); // ìì± ëê¸ ì¶ê° 264 $comment.commentList('load', $comment.comment_page, $comment.comment_orderby='I'); // ëê¸ ë¶ë¬ì¤ê¸° 265 $comment.moveScroll($comment.list_container); // ìì± ëê¸ë¡ ì´ë 266 } 267 268 // ëµê¸ ì¶ê° 269 if(mode == 'sub_input'){ 270 $comment.commentSubList(reply_parent_idxno, 'input'); 271 $comment.moveScroll($('#comment #comment-item-'+reply_parent_idxno)); // ìì± ëê¸ë¡ ì´ë 272 } 273 } 274 }); 275 } 276 277 278 // ëê¸ ìì 279 , commentModify:function(f){ // f:í¼ ê·¸ë£¹ 280 var result = ''; 281 $.ajax({ 282 url:'/comment/commentOption.ajax.php', 283 method:'POST', 284 data:f.serialize(), 285 dataType:'JSON', 286 cache: false, 287 success:function(data){ 288 if(data['result'] == 'OK'){ 289 $('#comment-textbox-'+data['idxno']+' .comment-content-view').html(data['modify_content'].replace(/\n/g,'<br>')); 290 $comment.reveal_modify.foundation('close'); // ìì ëª¨ë¬ ë«ê¸° 291 $('.user-delete').hide(); 292 } else { 293 alert(data['msg']); 294 } 295 } 296 }); 297 } 298 299 300 // ëê¸ ìì 301 , commentDelete:function(f){ // f:í¼ ê·¸ë£¹ 302 $.ajax({ 303 url:'/comment/commentOption.ajax.php', 304 method:'POST', 305 data:f.serialize(), 306 dataType:'JSON', 307 cache: false, 308 success:function(data){ //console.log(data); 309 if(data['result'] == true) { 310 if (typeof data['referer']!="undefined" && data['referer']==true) { 311 window.parent.location.reload(); 312 return false; 313 } 314 315 if(data['mode'] == 'delete') $('#comment-item-'+data['idxno']).slideUp('slow'); 316 else if(data['mode'] == 'sub-delete'){ 317 var cmt_sub_count = Number($('#comment-item-'+data['reply_parent_idxno']+' .comment-sub-count').text()) - 1; 318 if(cmt_sub_count > 0) $('#comment-item-'+data['reply_parent_idxno']+' .comment-sub-count').html('<small>'+cmt_sub_count+'</small>'); 319 else $('#comment-item-'+data['reply_parent_idxno']+' .comment-sub-count').html(''); 320 $('#comment-item-'+data['idxno']).slideUp('slow'); 321 } 322 323 if(data['total_count']) $comment.TotalCount(data['total_count']); // ëê¸ ì´ ê°ì ë³ê²½ 324 325 $comment.reveal_delete.foundation('close'); // ìì ëª¨ë¬ ë«ê¸° 326 } else { 327 alert('ë¹ë°ë²í¸ íì¸ í ë¤ì ìëíì기 ë°ëëë¤.'); 328 } 329 } 330 }); 331 } 332 333 334 // ëê¸ ì¶ì²/ë°ë 335 , commentVote:function(elm, mode, idxno){ // elm:ì¶ì²/ë°ë ë²í¼ ê°ì²´ | mode:vote_up(ì¶ì²) or vote_down(ë°ë) | idxno:ëê¸ë²í¸ 336 var commentVoteCheck = false; 337 338 if($comment.comment_vote_check[0] == 'S'){ // ì¤í ë¦¬ì§ ë°©ì 339 var nowTimestamp = nowTime = Math.floor(+ new Date() / 1000); 340 var voteCheckName = 'comment_'+$comment.service_code+'_'+idxno; 341 var voteCheckTime = nowTime + ($comment.comment_vote_check[2] * 3600); 342// var voteCheckTime = nowTime + 10; // test 343 var setCheckData = [mode,voteCheckTime]; 344 var getCheckData = (localStorage[voteCheckName] !== undefined) ? JSON.parse(localStorage.getItem(voteCheckName)) : []; 345 346 if(getCheckData[1]){ // ì¤í 리ì§ì ê°ì´ ì¡´ì¬íë©´ 347 if(nowTimestamp < getCheckData[1]){ // ì²´í¬ìê°ì´ ì§ëì§ ììì¼ë©´ 348 if($comment.comment_vote_check[1]){ // ì¶ì² í´ì íì± ì 349 if(getCheckData[0] != mode) commentVoteCheck = 'A'; // ì¶ì² ìíìì ë°ë를 í ê²½ì° >> ì¬ì¶ì² ê²½ê³ ë¬¸êµ¬ íì 350 else commentVoteCheck = 'U'; // ì¶ì² ìíìì ë¤ì ì¶ì²ì í ê²½ì° >> ì¶ì² í´ì ì²ë¦¬ 351 } else commentVoteCheck = 'A'; // ì¶ì² í´ì ë¹íì± ì >> ì¬ì¶ì² ê²½ê³ ë¬¸êµ¬ íì 352 } else commentVoteCheck = 'Y'; // ì²´í¬ìê°ì´ ì§ë¬ì¼ë©´ >> ì¬ì¶ì² ì¤í 353 } else commentVoteCheck = 'Y';
353 // ì¤í 리ì§ì ê°ì´ ì¡´ì¬íì§ ìì¼ë©´ >> ì¶ì² ì¤í 354 355 if(!$comment.nd_check && $comment.member_nd) commentVoteCheck = 'Y'; // ND ì²´í¬ìí¨ ì¤ì ì && ND ì´ë©´ ì¶ì² ì²´í¬ ìí¨ 356 if(!$comment.admin_check && $comment.member_check == 'ADMIN') commentVoteCheck = 'Y'; // ê´ë¦¬ì ì²´í¬ìí¨ ì¤ì ìí && ê´ë¦¬ì ì´ë©´ ì¶ì² ì²´í¬ ìí¨ 357 358 } else if($comment.comment_vote_check[0] == 'C'){ // ì¿ í¤ë°©ì 359 commentVoteCheck = 'Y'; // ì¶ì² ì¤í (PHPìì ì²´í¬ ì²ë¦¬) 360 } 361 362 if(commentVoteCheck != false){ 363 $.ajax({ 364 url:'/comment/commentOption.ajax.php', 365 method:'POST', 366 data:{member_check:$comment.member_check, service_code:$comment.service_code, bbs_table:$comment.bbs_table, list_per_page:$comment.list_per_page, parent_idxno:$comment.parent_idxno, mode:mode, idxno:idxno, vote_check_val:commentVoteCheck}, 367 dataType:'JSON', 368 cache: false, 369 success:function(data){ 370 if(data['result'] == 'OK'){ 371 if($comment.comment_vote_check[0] == 'S') localStorage.setItem(voteCheckName, JSON.stringify(setCheckData)); // ì²´í¬ ë°ì´í°ë¥¼ ì¤í 리ì§ì ì ì¥ 372 elm.closest('.user-vote').find('.'+mode+'-off').hide(); 373 elm.closest('.user-vote').find('.'+mode+'-on .text-vote').text(data['vote_num']); 374 elm.closest('.user-vote').find('.'+mode+'-on').slideDown(); 375 376 } else if(data['result'] == 'UNSET'){ 377 if($comment.comment_vote_check[0] == 'S') localStorage.removeItem(voteCheckName); // ì¤í ë¦¬ì§ ì ê±° 378 // alert(data['msg']); 379 elm.closest('.user-vote').find('.'+mode+'-on').hide(); 380 elm.closest('.user-vote').find('.'+mode+'-off .text-vote').text(data['vote_num']); 381 elm.closest('.user-vote').find('.'+mode+'-off').slideDown(); 382 383 } else if(data['result'] == 'BLOCK') alert(data['msg']); 384 } 385 }); 386 } 387 } 388 389 390 // ê¸ìì ì²´í¬ 391 , textLength:function(elm){ // elm:ê¸ìì ì²´í¬í ê°ì²´ 392 var content = elm.val(); 393 394 if (content.length > $comment.max_length){ 395 alert('ìµë '+$comment.max_length+'ìê¹ì§ ì ë ¥ ê°ë¥í©ëë¤.'); 396 elm.val(content.substring(0, $comment.max_length)); 397 elm.closest('form').find('.comment-text-cur').text($comment.max_length); 398 elm.height(1).height( elm.prop('scrollHeight')+10 ) 399 400 return false; 401 402 } else { 403 elm.closest('form').find('.comment-text-cur').text(content.length); 404 elm.height(1).height( elm.prop('scrollHeight')+10 ) 405 406 return true; 407 } 408 } 409 410 // ì¤í¬ë¡¤ ì´ë 411 , moveScroll:function(elm, force = false, sp = 600){ // elm:ìì¹ ì´ë ê°ì²´ | force:true(ì¬ì©) or false(ë¹ì¬ì©) | sp:ì´ë ìë 412 if (!$comment.auto_scroll && !force) return false; // $comment.auto_scroll íê²½ ì¤ì ìì 미ì¬ì©ììë forceê° true ì´ë©´ ì¬ì© 413 414 const isIframe = window.self !== window.top; 415 const isAdmin = document.querySelector("#admin-wrap") || window.parent.document.querySelector("#admin-wrap"); 416 let topMargin = 0; 417 418 if ($('#sticky-header .titles').is(':visible')) topMargin += $('#sticky-header .titles').height(); 419 420 if (isAdmin) { 421 if (isIframe) { 422 if ($("#article-preview").is(":visible")) topMargin += $("#article-preview").outerHeight(); 423 } else { 424 if ($("#admin-header").is(":visible")) topMargin += $("#admin-header").outerHeight(); 425 } 426 topMargin += parseInt(elm.closest(".grid-view").css("padding-top"), 10); 427 428 let gridContent = null; 429 let getParentClass = node => { 430 if (typeof node=="undefined") return ''; 431 return node.parentNode.classList.value; 432 }; 433 434 if (getParentClass(elm.closest(".grid-view")[0]).indexOf('grid-snb')!=-1) { 435 gridContent = elm.closest('.grid-snb'); 436 } else { 437 gridContent = elm.closest('.grid-content'); 438 } 439 440 const scrollPosition = elm.offset().top - gridContent.offset().top + gridContent.scrollTop() - topMargin; 441 442 gridContent.animate({ scrollTop: scrollPosition }, sp); 443 } else { 444 $('html, body').animate({ scrollTop: parseInt($("#comment-list").offset().top) - topMargin }, sp); 445 } 446 } 447 // 리ì¤í¸ ì¶ì² ON ì²ë¦¬ 448 , voteViewCheck:function(idxno){ 449 var nowTimestamp = nowTime = Math.floor(+ new Date() / 1000); 450 var voteCheckTime = nowTime + ($comment.comment_vote_check[2] * 3600); 451 var voteCheckName = 'comment_'+$comment.service_code+'_'+idxno; 452 var getCheckData = (localStorage[voteCheckName] !== undefined) ? JSON.parse(localStorage.getItem(voteCheckName)) : []; 453 454 if(getCheckData[1] && nowTimestamp < getCheckData[1]){ 455 $('#comment-item-'+idxno).find('button.'+getCheckData[0]+'-off').hide(); 456 $('#comment-item-'+idxno).find('button.'+getCheckData[0]+'-on').show(); 457 } 458 } 459 460 461 // ì ì ëê¸ ì ë³´ 462 , userCommentInfo:function(user_id){ 463 $.ajax({
464 url:'/comment/userCommentInfo.ajax.php', 465 method:'GET', 466 data:{user_id:user_id, service_code:$comment.service_code}, 467 dataType:'HTML', 468 cache: true, 469 success:function(data){ 470 $('body').append(data); 471 $('#userCommentInfo').show(); 472 } 473 }); 474 } 475 476}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.