PageSourceSearch

https://cheonan21.or.kr/module/board/board.js?v=260904

js cheonan21.or.kr collected 2026-09-27 05:13:05 UTC 90,227 bytes, 1,792 lines download raw bytes

1/**
2 * Created by quvsoftware on 2019-07-24.
3 */
4/**
5 * Created by Gram.Sim on 2018-03-07.
6 */
7
8/* BOARD */
9function initAllBoard() {
10    $.each($("body").find('table[class*="board-table-"]'), function() {
11        var boardBox = $(this).parents('.boardBox').first();
12        boardBox.addClass('board-loading');
13        boardBox.append('<div class="board-loading-mask"><div></div></div>');
14        callArticle(this, function() {
15            boardBox.removeClass('board-loading');
16            boardBox.find('.board-loading-mask').remove();
17        });
18    });
19    $.each($('.board-category'), function() {
20        if ($(this).children('.board-category-item.default').length > 0) {
21            $(this).children('.board-category-item.default').addClass('active');
22
23            /* 2020.02.21 재헌
24             * 게시판 - 카테고리 헤더 다국어적용
25             */
26            $(this).find('.board-category-item.default > div').text(lang.view_all);
27        }
28    });
29
30    /* 2020.02.21 재헌
31     * 게시판 - 검색옵션 다국어적용
32     */
33    $.each($('.board-search-select'), function() {
34        var select_options = '<option value="all">' + lang.all + '</option>' +
35            '<option value="subject">' + lang.subject + '</option>' +
36            '<option value="content">' + lang.contents + '</option>' +
37            '<option value="writer">' + lang.writer + '</option>';
38        $(this).html(select_options);
39    });
40
41    /* 2021.10.12 재헌
42     * autocomplete off
43     * https://stackoverflow.com/questions/15738259/disabling-chrome-autofill
44     */
45    $.each($('.board-search-input'), function() {
46        const html = '<form class="board-search-input-form"><input type="text" class="form-control board-search-input" autocomplete="false"></form>';
47        $(this).after(html);
48        $(this).remove();
49    });
50}
51initAllBoard();
52
53function callArticle(obj, callback) {
54    var view = $(obj).parents('.view').first();
55    var bid = $(obj).attr('data-bid');
56    var category = '';
57    var keyword = '';
58    var page = 1;
59    var size = parseInt(view.find('table').attr('data-pagesize'));
60    var language = $(obj).data('language');
61
62    // 2021.01.11
63    // 게시글로 이동 후 다시 되돌아 갈 때 게시판 카테고리, 페이지 유지
64    try {
65        var boardLocalStorage = window.localStorage.getItem('QuvBoard');
66        if (boardLocalStorage) {
67            boardLocalStorage = JSON.parse(boardLocalStorage);
68            if (boardLocalStorage.bid == bid)  {
69                category = boardLocalStorage.category;
70                page = parseInt(boardLocalStorage.page || 1);
71                keyword = boardLocalStorage.keyword || '';
72            }
73            window.localStorage.removeItem('QuvBoard')
74        }
75    }
76    catch (ex) {
77        console.log(ex)
78    }
79
80
81    if (bid == undefined) {
82        $(obj).parents('.boardBox').first().remove();
83        return;
84    }
85
86    qvjax_direct(
87        "select_board_info",
88        "/module/board/board.php",
89        'bid=' + bid,
90        function (data) {
91            if (data.length > 0) {
92                $.each(data, function() {
93                    if (this.use_recommend == 0) { $(obj).find('thead .board-thead-item-hits').remove() }
94                    if (this.use_views == 0) { $(obj).find('thead .board-thead-item-views').remove() }
95                    if (this.use_date == 0) { $(obj).find('thead .board-thead-item-date').remove() }
96                    if (this.use_writer == 0) { $(obj).find('thead .board-thead-item-writer').remove() }
97
98                    // 카테고리를 사용하는 사용자만 호출
99                    if (this.use_category == 1) {
100                        init_BoardCategoryItem(view, bid);
101                    }
102
103                    // 2019.04.23
104                    // DB 의존적으로 컬럼 생성
105                    // var lang = new Object();
106                    // if (language == 'en') {
107                    //     lang.NO = '글 번호';
108                    //     lang.CATEGORY = '카테고리';
109                    //     lang.TITLE = '제목';
110                    //     lang.WRITER = '작성자';
111                    //     lang.HITS = '추천수';
112                    //     lang.VIEWS = '조회수';
113                    //     lang.DATE = '작성일';
114                    // }
115                    // else {
116                    //     lang.NO = 'NO';
117                    //     lang.CATEGORY = 'CATEGORY';
118                    //     lang.TITLE = 'TITLE';
119                    //     lang.WRITER = 'WRITER';
120                    //     lang.HITS = 'HITS';
121                    //     lang.VIEWS = 'VIEWS';
122                    //     lang.DATE = 'DATE';
123                    // }
124                    // $(obj).find('thead .board-thead-item-hits').remove();
125                    // $(obj).find('thead .board-thead-item-views').remove();
126                    // $(obj).find('thead .board-thead-item-date').remove();
127                    // $(obj).find('thead .board-thead-item-writer').remove();
128                    //
129                    // if (this.use_writer == 1) {
130                    //     $(obj).find('thead > tr.board-thead-tr').append('<th class="board-thead-item-writer">' + lang.WRITER + '</th>');
131                    // }
132                    // if (this.use_recommend == 1) {
133                    //     $(obj).find('thead > tr.board-thead-tr').append('<th class="board-thead-item-hits">' + lang.HITS + '</th>');
134                    // }
135                    // if (this.use_views == 1) {
136                    //     $(obj).find('thead > tr.board-thead-tr').append('<th class="board-thead-item-views">' + lang.VIEWS + '</th>');
137                    // }
138                    // if (this.use_date == 1) {
139                    //     $(obj).find('thead > tr.board-thead-tr').append('<th class="board-thead-item-date">' + lang.DATE + '</th>');
140                    // }
141
142                });
143                setBoardArticle(view, bid, category, keyword, page, size, 0, function() {
144                    /* 2020.01.17 재헌
145                       일부 컬럼을 숨긴 게시판을 랜더링 시 IE에서 width 부분이 잘못 랜더링 됨
146                       display 값을 none -> table로 timeout을 두고 변경해주면 제대로 랜더링 됨
147                     */
148                    if (is_InternetExplorer()) {
149                        $('#' + bid).css('display', 'none');
150                        setTimeout(function() {
151                            $('#' + bid).css('display', 'table');
152                        }, 100);
153                    }
154
155                    callback();
156                });
157                boardPagingDelegateActivation();
158            }
159            else { $(obj).remove(); }
160        },
161        function(xhr) {
162            callback();
163        }
164    );
165}
166
167function moveWriteForm(obj) {
168    var board = $(obj).parents('.boardBox').first();
169    var bid = $(obj).siblings('table').data('bid');
170
171    if (board.find('.board-guide').length > 0 || bid == undefined) {
172        alert(lang.not_complete_board_creation);
173        return;
174    }
175    else {
176        var uri = encodeURI(window.location.href);
177        location.href = '/module/board/write_form.html?bid=' + encodeURIComponent(bid) + "&pn=" + encodeURIComponent(SITE_URL) + '&prev=' + encodeURIComponent(uri);
178    }
179}
180
181function setBoardArticle(view, bid, category, keyword, page, size, segment, callback) {
182    if (!callback) callback = function() {}
183    if (page <= 0 || size <= 0) {
184        callback();
185        return;
186    }
187    // 목록보기 권한 체크
188    qvjax_direct(
189        "check_board_auth",
190        "/module/board/board.php",
191        'bid=' + bid + '&auth_action=view',
192        function (data) {
193            if (data) {
194                init_BoardArticle();
195            }
196            else {
197                view.find('.board-tbody-tr').remove();
198                view.find('.pager').children().remove();
199                view.find('.board-noauth').remove();
200
201                var html = '<div class="board-noauth" style="height: 100px;width: 100%;border: 1px solid #000;"><div style="display: flex;justify-content: center;align-items: center;flex-direction: column;height: 100%; color: #494949;">권한이 없습니다.</div></div>';
202                view.find('table').after($(html));
203                callback();
204            }
205        },
206        function (xhr) {
207            callback();
208        }
209    );
210
211    function init_BoardArticle() {
212        var search_type = view.find('.board-search-select option:selected').val();
213
214        qvjax_direct(
215            "select_board_article_list",
216            "/module/board/board.php",
217            'bid=' + bid + '&category=' + category + '&search_type=' + search_type +'&keyword=' + keyword + '&page=' + page + '&size=' + size + '&segment=' + segment,
218            function (data) {
219                var json_data = $.parseJSON(data);
220                var totalCount = json_data.total;
221                var article_data = json_data.data;
222
223                // paging start //
224                var startNumber = totalCount-((page-1)*size);
225                buildPagingHtml(view, page, size, totalCount, keyword != '');
226
227                var box = view.parents('.boardBox').first();
228                box.data('total', totalCount);
229                // paging end //
230
231                if (view.find('tbody.board-tbody').children('tr').length > 0) {
232                    view.find('tbody.board-tbody').children('tr').remove();
233                }
234
235                var fid = view.parents('.frm')[0].id;
236                var tid = view.find('table')[0].id;
237                var html = '';
238
239                if (article_data.length > 0) {
240                    // PC
241                    $.each(article_data, function() {
242                        var user_type = 'm';
243                        if (this.writer_account == null) { user_type = 'nm'; }
244                        if (this.category_name == null) { this.category_name = ''; }
245
246                        // 일반 게시판 형
247                        if (view.find('table').hasClass('board-table-1')) {
248                            // 공지사항은 tr에 notice 클래스 추가
249                            if (parseInt(this.is_notice) > 0) {
250                                html += '<tr class="board-tbody-tr notice" id="' + this.aid + '" data-type="' + user_type + '">';
251                            }
252                            else {
253                                html += '<tr class="board-tbody-tr" id="' + this.aid + '" data-type="' + user_type + '">';
254                            }
255
256                            // 공지사항은 글번호 대신 notice
257                            if ($('#' + tid + ' thead tr').children('.board-thead-item-no').length > 0) {
258                                if (parseInt(this.is_notice) > 0) {
259                                    html += '<td class="board-tbody-item board-tbody-item-count" style="font-size: 11px;"><div>Notice</div></td>';
260                                }
261                                else {
262                                    html += '<td class="board-tbody-item board-tbody-item-count">' + startNumber-- + '</td>';
263                                }
264                            }
265
266                            // 카테고리
267                            if ($('#' + tid + ' thead tr').children('.board-thead-item-category').length > 0) {
268                                html += '<td class="board-tbody-item board-tbody-item-category">' + this.category_name + '</td>';
269                            }
270
271                            // 제목
272                            if ($('#' + tid + ' thead tr').children('.board-thead-item-title').length > 0) {
273                                // 댓글인 항목은 padding을 줘서 들여쓰기 함
274                                var padding = this.reply.length * 15 + 20 + 'px'; // 20은 default padding
275                                html += '<td class="board-tbody-item board-tbody-item-title" style="padding-left:' + padding + '">';
276                                // 댓글
277                                if (this.reply != '') {
278                                    html += '<i class="fa fa-mail-reply" aria-hidden="true" style="transform: rotate(180deg);"></i>';
279                                }
280                                // 비밀글
281                                if (parseInt(this.is_secret) > 0) {
282                                    html += '<i class="icon-lock" aria-hidden="true"></i>';
283                                }
284                                // 공지사항
285                                if (parseInt(this.is_notice) > 0) {
286                                    html += '<i class="icon-volume-2" aria-hidden="true"></i>';
287                                    // 공지사항은 제목 bold처리
288                                    html += '<div style="font-weight:bold;">' + this.subject + '</div>';
289                                }
290                                else {
291                                    // 새 글
292                                    var createDateTime = new Date(parseInt(this.reg_date) * 1000)
293                                    var currentDateTime = new Date();
294                                    var compareDateTime = currentDateTime.setDate(currentDateTime.getDate() - 1);
295                                    if (createDateTime > compareDateTime && this.reply == '') {
296                                        //html += '<span class="dot"></span>';
297                                        html += '<div class="new">' + this.subject + '</div>';
298                                    }
299                                    else {
300                                        html += '<div>' + this.subject + '</div>';
301                                    }
302                                }
303                                if (parseInt(this.fileCount) > 0) {
304                                    html += '<i class="icon-paper-clip" aria-hidden="true"></i>';
305                                }
306                                // if ($(this.content).find('img').length > 0) {
307                                if (this.content.indexOf('<img') > -1) {
308                                    html += '<i class="icon-picture" aria-hidden="true"></i>';
309                                }
310                                if (parseInt(this.comment) > 0) {
311                                    html += '<span><i class="icon-bubble" aria-hidden="true"></i>' + this.comment + '</span>';
312                                }
313                                html += '</td>';
314                            }
315
316                            if ($('#' + tid + ' thead tr').children('.board-thead-item-writer').length > 0) {
317                                html += '<td class="board-tbody-item board-tbody-item-writer">' + changeAdministratorNameLanguage(this.writer) + '</td>';
318                            }
319                            if ($('#' + tid + ' thead tr').children('.board-thead-item-hits').length > 0) {
320                                html += '<td class="board-tbody-item board-tbody-item-hits"><i class="icon-like" aria-hidden="true" style="display:none;"></i>' + this.hits + '</td>';
321                            }
322                            if ($('#' + tid + ' thead tr').children('.board-thead-item-views').length > 0) {
323                                html += '<td class="board-tbody-item board-tbody-item-views"><i class="icon-eye" aria-hidden="true" style="display:none;"></i>' + this.views + '</td>';
324                            }
325                            if ($('#' + tid + ' thead tr').children('.board-thead-item-date').length > 0) {
326                                // 게시된지 하루가 지나지 않은 항목은 ~~hours ago 형식
327                                // 게시된지 하루가 지난 항목은 yyyy-MM-dd 형식
328                                var createDateTime = new Date(parseInt(this.reg_date) * 1000);
329                                var currentDateTime = new Date();
330                                var compareDateTime = currentDateTime.setDate(currentDateTime.getDate() - 1);
331                                if (createDateTime > compareDateTime) {
332                                    html += '<td class="board-tbody-item board-tbody-item-date">' + getNiceTime(parseInt(this.reg_date) * 1000, new Date(), 1, true) +'</td>';
333                                }
334                                else {
335                                    html += '<td class="board-tbody-item board-tbody-item-date">' + $.datepicker.formatDate('yy-mm-dd', createDateTime) + '</td>';
336                                }
337                            }
338                            html += '</tr>';
339                        }
340                        // 썸네일 게시판 형
341                        else if (view.find('table').hasClass('board-table-2')) {
342                            var content = this.content.replace(/\n/g, '');
343
344                            // 공지사항은 tr에 notice 클래스 추가
345                            if (parseInt(this.is_notice) > 0) {
346                                html += '<tr class="board-tbody-tr notice" id="' + this.aid + '" data-type="' + user_type + '">';
347                            }
348                            else {
349                                html += '<tr class="board-tbody-tr" id="' + this.aid + '" data-type="' + user_type + '">';
350                            }
351                            html += '<td class="board-tbody-item board-tbody-item-title">';
352                            html += '<div class="board-tbody-item-img">';
353
354                            // 공지사항은 이미지 대신 아이콘, 이미지가 없으면 임시 이미지
355                            if (content.indexOf('qv-video') > 0 && parseInt(this.is_notice) == 0) {
356                                var id = /<iframe.*?class="qv-video".*?data-id=['"](.*?)['"]/.exec(content)[1];
357                                var type = /<iframe.*?class="qv-video".*?data-type=['"](.*?)['"]/.exec(content)[1];
358                                var thumbnail = /board-thumbnail.*?src=['"](.*?)['"]/.exec(content);
359
360                                if (thumbnail != null) {
361                                    var thumbnailUrl = thumbnail[1];
362                                    html += '<div class="gallery-board-image" style="background-image:url(' + thumbnailUrl + ')"></div>';
363                                }
364                                else if (type == 'youtube') {
365                                    var thumbnailUrl = 'https://img.youtube.com/vi/' + id + '/hqdefault.jpg';
366                                    html += '<div class="gallery-board-image" style="background-image:url(' + thumbnailUrl + ')">';
367                                    html += '<div class="gallery-board-image-overlay"><i class="icon-control-play"></i></div>';
368                                    html += '</div>';
369                                }
370                                else if (type == 'vimeo') {
371                                    $.getJSON('https://www.vimeo.com/api/v2/video/' + id + '.json?callback=?', {format: "json"}, function(data) {
372                                        $('.vimeo' + data[0].id).css('backgroundImage','url(' + data[0].thumbnail_large + ')');
373                                    });
374                                    html += '<div class="gallery-board-image vimeo' + id + '">';
375                                    html += '<div class="gallery-board-image-overlay"><i class="icon-control-play"></i></div>';
376                                    html += '</div>';
377                                }
378                            }
379                            else if (content.indexOf('img') > 0 && parseInt(this.is_notice) == 0) {
380                                // html += $(content).find('img')[0].outerHTML;
381                                /* 2020.02.11 재헌
382                                 * 첨부 이미지 프로세스 변경
383                                 */
384                                if (content.indexOf('board-thumbnail') > 0) {
385                                    var src = '';
386                                    var images = content.match(/<img(.*?)>/g);
387                                    $.each(images, function() {
388                                        if (this.indexOf('board-thumbnail') > 0) {
389                                            var regex = /src=['"](.*?)['"]/;
390                                            src = regex.exec(this)[1];
391                                            return false;
392                                        }
393                                    });
394                                    html += '<div class="gallery-board-image" style="background-image:url(' + src + ')"></div>';
395                                }
396                                else {
397                                    var first = content.match(/<img(.*?)\/>/g);
398                                    // 사용자 임의로 base64로 인코딩 이미지를 넣으면 정규식에 걸리지않는다
399                                    if (first == null) {
400                                        html += '<div class="gallery-board-image">';
401                                        html += '<div class="gallery-board-image-overlay"><i class="icon-picture" style="color: #e8e8e8 !important;"></i></div>';
402                                        html += '</div>';
403                                    }
404                                    else {
405                                        var regex = /<img.*?src=['"](.*?)['"]/;
406                                        var src = regex.exec(first[0])[1];
407                                        html += '<div class="gallery-board-image" style="background-image:url(' + src + ')"></div>';
408                                    }
409                                }
410                            }
411                            else if (parseInt(this.is_notice) > 0) {
412                                html += '<i class="icon-volume-2" aria-hidden="true"></i>';
413                            }
414                            else {
415                                // html += '<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRdzCFhx2amGylOL5hNmrDzZUiimjh8IEJhTN91zUPECwsqwHNu" style="max-width:100%;" class="mCS_img_loaded">';
416                                // html += '<div class="gallery-board-image" style="background-image:url(' + "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRdzCFhx2amGylOL5hNmrDzZUiimjh8IEJhTN91zUPECwsqwHNu" + ')"></div>'
417                                html += '<div class="gallery-board-image">';
418                                html += '<div class="gallery-board-image-overlay"><i class="icon-picture" style="color: #e8e8e8 !important;"></i></div>';
419                                html += '</div>';
420                            }
421                            html += '</div>';
422                            html += '<div class="board-tbody-item-contents">';
423                            html += '<div class="board-tbody-item-top">';
424
425                            // 공지사항은 카테고리 란에 Notice 로 치환
426                            if (parseInt(this.is_notice) > 0) {
427                                html += '<div class="board-tbody-item-category" style="font-weight: bold;">Notice</div>';
428                                html += '<div class="board-tbody-item-subject" style="font-weight: bold;">' + this.subject + '</div>';
429                            }
430                            else {
431                                if ($('#' + tid + ' thead tr').children('.board-thead-item-category').length > 0) {
432                                    if (this.category_name == '' && view.find('.theme-1').length > 0) {}
433                                    else {
434                                        html += '<div class="board-tbody-item-category">' + this.category_name + '</div>';
435                                    }
436                                }
437
438                                // 새 글
439                                var createDateTime = new Date(parseInt(this.reg_date) * 1000)
440                                var currentDateTime = new Date();
441                                var compareDateTime = currentDateTime.setDate(currentDateTime.getDate() - 1);
442                                if (createDateTime > compareDateTime && this.reply == '') {
443                                    html += '<div class="board-tbody-item-subject new">';
444                                }
445                                else {
446                                    html += '<div class="board-tbody-item-subject">';
447                                }
448                                // 비밀글
449                                if (parseInt(this.is_secret) > 0) {
450                                    html += '<i class="icon-lock" aria-hidden="true"></i>';
451                                }
452                                html += this.subject;
453
454                                if (parseInt(this.fileCount) > 0) {
455                                    html += '<i class="icon-paper-clip" aria-hidden="true"></i>';
456                                }
457                                // if ($(content).find('img').length > 0) {
458                                if (content.indexOf('<img') > -1) {
459                                    html += '<i class="icon-picture" aria-hidden="true"></i>';
460                                }
461                                html += '</div>';
462                            }
463                            if (parseInt(this.comment) > 0) {
464                                html += '<span><i class="icon-bubble" aria-hidden="true"></i>' + this.comment + '</span>';
465                            }
466
467                            // 2019.01.22
468                            if (view.find('table.board-table-2').hasClass('board-show-content')) {
469                                var content = $('<div>' + this.content + '</div>');
470                                if (content.find('preview').length > 0) {
471                                    // 본문이 표시될 때 깜빡이는 문제 때문에 content display:none -> inline-block (inline-style) 로 처리
472                                    html += '<div class="board-tbody-item-content" style="display: inline-block;">
472' + content.find('preview').not('style').html() + '</div>';
473                                }
474                                else {
475                                    var content_length = 700;
476                                    if (view.find('.board-theme').hasClass('theme-2')) { content_length = 280; }
477                                    html += '<div class="board-tbody-item-content" style="display: inline-block;">' + $(this.content).not('style').text().substring(0, content_length) + '</div>';
478                                }
479                            }
480
481                            html += '</div>';
482                            html += '<div class="board-tbody-item-bottom">';
483                            html += '<span class="board-tbody-item-bottom-writer">' + changeAdministratorNameLanguage(this.writer) + '</span>';
484                            html += '<span class="board-tbody-item-bottom-hits"><i class="icon-like" aria-hidden="true"></i>' + this.hits + '</span>';
485                            html += '<span class="board-tbody-item-bottom-views"><i class="icon-eye" aria-hidden="true"></i>' + this.views + '</span>';
486
487                            // 게시된지 하루가 지나지 않은 항목은 ~~hours ago 형식
488                            // 게시된지 하루가 지난 항목은 yyyy-MM-dd 형식
489                            var createDateTime = new Date(parseInt(this.reg_date) * 1000);
490                            var currentDateTime = new Date();
491                            var compareDateTime = currentDateTime.setDate(currentDateTime.getDate() - 1);
492                            if (createDateTime > compareDateTime) {
493                                html += '<span class="board-tbody-item-bottom-date">' + getNiceTime(parseInt(this.reg_date) * 1000, new Date(), 1, true) +'</span>';
494                            }
495                            else {
496                                html += '<span class="board-tbody-item-bottom-date">' + $.datepicker.formatDate('yy-mm-dd', createDateTime) + '</span>';
497                            }
498                            html += '</div>';
499                            html += '</div>';
500                            html += '</td>';
501                            html += '</tr>';
502                        }
503                        // Q&A 게시판 형
504                        else if (view.find('table').hasClass('board-table-3')) {
505                            // var content = this.content.replace(/\n/g, '');
506                            var createDateTime = new Date(parseInt(this.reg_date) * 1000);
507                            html += '<tr class="board-tbody-tr" id="' + this.aid + '" data-type="' + user_type + '">';
508                            html += '<td class="board-tbody-item">';
509                            html += '<div class="board-tbody-item-title"><i class="material-icons">add</i>' + this.subject;
510                            html += '<div class="board-tbody-item-bottom">';
511                            html += '<div class="board-tbody-item-writer">' + changeAdministratorNameLanguage(this.writer) + '</div>';
512                            html += '<div class="board-tbody-item-date">' +  $.datepicker.formatDate('yy-mm-dd', createDateTime); + '</div>'
513                            html += '</div></div>';
514                            html += '<div class="board-tbody-item-contents">';
515                            html += this.content;
516                            html += '</div>';
517                            html += '</td>';
518                            html += '</tr>';
519                        }
520                        else if (view.find('table').hasClass('board-table-4')) {
521                            var content = this.content.replace(/\n/g, '');
522                            var createDateTime = new Date(parseInt(this.reg_date) * 1000);
523                            html += '<tr class="board-tbody-tr" id="' + this.aid + '" data-type="' + user_type + '">';
524                            html += '<td class="board-tbody-item board-tbody-item-title" style="padding-left:20px !important">';
525                            html += '<div>';
526                            html += '<category>';
527                            html += this.is_notice === '1' ? 'Notice' : this.category_name;
528                            html += '</category>';
529                            html += '<span>';
530                            if (parseInt(this.is_secret) > 0) {
531                                html += '<i class="icon-lock" aria-hidden="true"></i>';
532                            }
533                            html += this.subject;
534                            if (parseInt(this.fileCount) > 0) {
535                                html += '<i class="icon-paper-clip" aria-hidden="true"></i>';
536                            }
537                            if (content.indexOf('<img') > -1) {
538                                html += '<i class="icon-picture" aria-hidden="true"></i>';
539                            }
540                            html += '</span>';
541                            html += '</div>';
542                            html += '</td>';
543                            html += '<td class="board-tbody-item board-tbody-item-date">' + $.datepicker.formatDate('mm-dd', createDateTime) + '</td>';
544                            html += '</tr>';
545                        }
546                    });
547                }
548                else {
549                    var colspan = view.find('.board-thead th').length
550                    html += '<tr style="border: 1px solid #eee;"><td colspan="' + colspan + '" style="height: 300px;">' + lang.no_result_found + '</td></tr>'
551                }
552
553                view.find('tbody.board-tbody').append(html);
554
555                if (category) {
556                    var categoryItem = view.find('.board-category > .board-category-item[data-category-id="' + category + '"]')
557                    if (!categoryItem.hasClass('active')) {
558                        view.find('.board-category > .board-category-item').removeClass('active');
559                        categoryItem.addClass('active');
560                    }
561                }
562
563
564                callback();
565
566                // 리턴받은 결과값 개수가 페이지 사이즈보다 작을 때 빈값을 넣어준다
567                // if (view.find('table').hasClass('board-table-1')
568                //     || (view.find('table').hasClass('board-table-2') && view.find('.board-theme').hasClass('theme-1'))) {
569                //     var td_empty = '';
570                //     $.each($('#' + tid + ' thead tr th'), function (i, val) {
571                //         td_empty += "<td></td>";
572                //     });
573                //
574                //     for (var i = 0; i < size - list.length; i++) {
575                //         if (i == size - list.length - 1) {
576                //             var tr_empty = "<tr class='board-tbody-tr board-tbody-tr-empty' style='border-bottom:1px solid #f1f1f1;'>" + td_empty + "</tr>";
577                //         }
578                //         else {
579                //             var tr_empty = "<tr class='board-tbody-tr board-tbody-tr-empty'>" + td_empty + "</tr>";
580                //         }
581                //         html += tr_empty;
582                //     }
583                // }
584                // view.find('tbody.board-tbody').append(html);
585                //
586                // if (view.find('.board-tbody-tr-empty').length > 0) {
587                //     var tr_empty_height = 40;
588                //     if (view.find('.board-tbody-tr').length > 0) {
589                //         if (view.find('.board-tbody-tr').first().height() > 40) {
590                //             tr_empty_height = view.find('.board-tbody-tr').first().height();
591                //         }
592                //     }
593                //     view.find('.board-tbody-tr-empty').height(tr_empty_height);
594                // }
595            },
596            function (xhr) { }
597        )
598    }
599}
600
601function init_BoardCategoryItem(view, bid) {
602    // category item
603    qvjax_direct(
604        'select_board_category',
605        "/module/board/board.php",
606        'bid=' + bid,
607        function(data) {
608            if (data.length > 0) {
609                view.find('.board-category').children().not('.default').remove();
610                var html = "";
611                $.each(data, function () {
612                    html += '<div class="col-sm-2 board-category-item" data-category-id="' + this.category_id + '"><div>' + this.category_name + '</div></div>';
613                });
614                view.find('.board-category').append(html);
615
616                view.undelegate('.board-category-item', 'click');
617                view.delegate('.board-category-item', 'click', function (e) {
618                    e.preventDefault();
619                    view.find('.board-category-item').not(this).removeClass('active');
620                    $(this).addClass('active');
621
622                    var table = $(this).parents('.view').first().find('table');
623                    var category = $(this).attr('data-category-id');
624                    var keyword = '';
625                    var page = 1;
626                    var size = parseInt(table.attr('data-pagesize'));
627                    setBoardArticle(view, bid, category, keyword, page, size, 0);
628                });
629            }
630        },
631        function(xhr) { }
632    );
633}
634
635// paging
636function buildPagingHtml(view, page, pageSize, totalCount, is_search) {
637    var html = '';
638    var paging_start;
639    var paging_end;
640
641    page = parseInt(page);
642    pageSize = parseInt(pageSize);
643    totalCount = parseInt(totalCount);
644
645    if (page - 2 <= 0) {
646        paging_start = 1;
647        paging_end = Math.ceil(totalCount/pageSize) >= paging_start + 4 ? 5 : Math.ceil(totalCount/pageSize);
648    }
649    else if (page + 2 >= Math.ceil(totalCount/pageSize)) {
650        paging_start = Math.ceil(totalCount/pageSize) - 4 <= 0 ? 1 : Math.ceil(totalCount/pageSize) - 4;
651        paging_end = Math.ceil(totalCount/pageSize);
652    }
653    else {
654        paging_start = page - 2;
655        paging_end = page + 2;
656    }
657
658    html += '<li class="paging-btn-group__item left">';
659    html += '<i class="i-chevron-left"></i>';
660    html += '</li>';
661    for(var i = paging_start; i <= paging_end; i ++) {
662        html += '<li class="paging-btn-group__item">';
663        html += '<button class="btn btn--basic" value="' + i + '"><span>' + i;
664        html += '</span></button></li>';
665    }
666
667    if (is_search) {
668        html += '<li class="paging-btn-group__item"><button class="btn btn--next-segment" value="0"><span>' + lang.find_next + '</span></button></li>';
669    }
670
671    html += '<li class="paging-btn-group__item right">';
672    html += '<i class="i-chevron-right"></i>';
673    html += '</li>';
674
675    view.find('.paging-btn-group').children('.paging-btn-group__item').remove();
676    view.find('.paging-btn-group').append(html);
677
678    view.find('.btn.btn--basic').filter(function() { return this.value==page; }).addClass('active');
679}
680
681var g_segment = 0;
682function searchBoardArticle(obj) {
683    var frm = $(obj).parents('.frm').first();
684    var view = $(obj).parents('.view').first();
685    var bid = view.find('table').attr('data-bid');
686    var category = view.find('.board-category-item.active').attr('data-category-id') == undefined ? "" : view.find('.board-category-item.active').attr('data-category-id');
687    var keyword = view.find('.board-search-input').first().val();
688    var page = 1;
689    var size = parseInt(view.find('table').attr('data-pagesize'));
690
691    g_segment = 0;
692    setBoardArticle(view, bid, category, keyword, page, size, g_segment);
693    boardPagingDelegateActivation();
694}
695
696// $('.board-search .board-search-input').keyup(function(event){
697//     // press enter in search bar
698//     if(event.keyCode == 13) { searchBoardArticle(this); }
699// });
700
701$('#main_container').delegate('.board-search-input', 'keypress', function(e) {
702    if (e.key === "Enter") {
703        e.preventDefault();
704        searchBoardArticle(this);
705    }
706});
707
708function boardPagingDelegateActivation() {
709    $('.boardBox .pager').undelegate('.btn.btn--basic', 'click');
710    $('.boardBox .pager').delegate('.btn.btn--basic', 'click', function (e) {
711        e.preventDefault();
712        var target = $(this).parents('.box').first();
713        var view = target.find('.view').first();
714        var table = target.find('table').first();
715        var bid = table.attr('data-bid');
716        var category = view.find('.board-category-item.active').attr('data-category-id') == undefined ? "" : view.find('.board-category-item.active').attr('data-category-id');
717        var keyword = view.find('.board-search-input').first().val();
718        // var page = parseInt($(this).children('span').text());
719        var page = $(this).val();
720        var size = table.data("pagesize");
721
722        setBoardArticle(view, bid, category, keyword, page, size, g_segment, function() {
723            // 페이지 이동 시 게시판 최상위로 스크롤한다.
724            var offsetTop = target.offset().top;
725            if (is_InternetExplorer()) { // IE에서는 offset(and position) 동작이 다름.
726                offsetTop = $('body').scrollTop() + offsetTop;
727            }
728            if ($('body').hasClass('headerFixed')) {
729                var headerHeight = $('.header > .header1').attr('data-hei');
730                headerHeight = headerHeight ? parseInt(headerHeight) : $('.header').height();
731                offsetTop -= headerHeight;
732            }
733            $("html, body").animate({scrollTop: offsetTop}, 300);
734        });
735    });
736    $('.boardBox .pager').undelegate('.paging-btn-group__item.left', 'click');
737    $('.boardBox .pager').delegate('.paging-btn-group__item.left', 'click', function(e) {
738        e.preventDefault();
739        var target = $(this).parents('.box').first();
740        var view = target.find('.view').first();
741        var table = target.find('table').first();
742        var bid = table.attr('data-bid');
743        var category = view.find('.board-category-item.active').attr('data-category-id') == undefined ? "" : view.find('.board-category-item.active').attr('data-category-id');
744        var keyword = view.find('.board-search-input').first().val();
745        var page = 1;
746        var size = table.data("pagesize");
747
748        setBoardArticle(view, bid, category, keyword, page, size, g_segment);
749    });
750    $('.boardBox .pager').undelegate('.paging-btn-group__item.right', 'click');
751    $('.boardBox .pager').delegate('.paging-btn-group__item.right', 'click', function(e) {
752        e.preventDefault();
753        var target = $(this).parents('.box').first();
754        var view = target.find('.view').first();
755        var table = target.find('table').first();
756        var bid = table.attr('data-bid');
757        var category = view.find('.board-category-item.active').attr('data-category-id') == undefined ? "" : view.find('.board-category-item.active').attr('data-category-id');
758        var search_type = view.find('.board-search-select option:selected').val();
759        var keyword = view.find('.board-search-input').first().val();
760        var size = table.data("pagesize");
761
762        var totalCount = target.data('total');
763        if (totalCount) {
764            var page = Math.ceil(parseInt(totalCount)/size);
765            setBoardArticle(view, bid, category, keyword, page, size, g_segment);
766        }
767        else { // 초기화가 정상적으로 되었다면 아래 로직 타지않음
768            qvjax_direct(
769                "count_board_article",
770                "/module/board/board.php",
771                'bid=' + bid + '&category=' + category + '&search_type=' + search_type + '&keyword=' + keyword,
772                function (data) {
773                    var page = Math.ceil(data / size);
774                    setBoardArticle(view, bid, category, keyword, page, size, g_segment);
775                },
776                function (xhr) {
777
778                }
779            );
780        }
781    });
782
783    $('.boardBox .pager').undelegate('.btn.btn--next-segment', 'click');
784    $('.boardBox .pager').delegate('.btn.btn--next-segment', 'click', function (e) {
785        e.preventDefault();
786        var target = $(this).parents('.box').first();
787        var view = target.find('.view').first();
788        var table = target.find('table').first();
789        var bid = table.attr('data-bid');
790        var category = view.find('.board-category-item.active').attr('data-category-id') == undefined ? "" : view.find('.board-category-item.active').attr('data-category-id');
791        var keyword = view.find('.board-search-input').first().val();
792        // var page = parseInt($(this).children('span').text());
793        var page = 1;
794        var size = table.data("pagesize");
795
796        setBoardArticle(view, bid, category, keyword, page, size, ++g_segment);
797    });
798
799}
800boardPagingDelegateActivation();
801
802function boardArticleClickEvent() {
803    $("#main_container").delegate('.board-table-1 tr.board-tbody-tr, .board-table-2 tr.board-tbody-tr, .board-table-4 tr.board-tbody-tr', 'click', function(e) {
804        e.preventDefault();
805        var table = $(this).parents('table').first();
806        var aid = this.id;
807        var bid = table.attr('data-bid');
808        var type = table.attr('data-type');
809        var _pn = table.attr('data-pn')?table.attr('data-pn'):SITE_URL;
810        var pn = "&pn=" + _pn;
811
812        __BID = bid;
813        __AID = aid;
814        __PN = SITE_URL;
815
816        // 2021.01.11
817        // 게시글로 이동 후 다시 되돌아 갈 때 게시판 카테고리, 페이지 유지
818        var category = table.prevAll('.board-category');
819        var categoryId = category ? category.find('.board-category-item.active').attr('data-category-id') : '';
820        var page = table.nextAll('.pager');
821        var pageNumber = page ? page.find('button.btn.active').val() : 1;
822        var keyword = table.prevAll('.board-search');
823        var keywordText = keyword.find('.board-search-input').val();
824        try {
825            window.localStorage.setItem('QuvBoard', JSON.stringify({
826                bid: bid,
827                page: pageNumber,
828                category: categoryId,
829                keyword: keywordText,
830            }));
831        }
832        catch (ex) {
833            console.log(ex)
834        }
835
836
837        switch(type) {
838            case "move":
839                checkAuth(bid, aid,
840                    function(obj) {
841                        var url = "/module/board/read_form.html?bid=" + bid + "&aid=" + aid + pn;
842                        location.href = url;
843                        //window.open(url, "_blank");
844                    },
845                    function(obj) {
846                        qvjax_direct(
847                            "check_board_auth",
848                            "/module/board/board.php",
849                            'bid=' + bid + '&aid=' + aid + '&auth_action=read',
850                            function (data) {
851                                if (data || $('tr#' + obj.parent).attr('data-type') == 'nm') {
852                                    // 부모객체의 작성자 유저 타입을 넘겨준다
853                                    var parent_user_type = obj.parent == "1" ? "" : "&put=" + $('tr#' + obj.parent).attr('data-type');
854                                    var url = "/module/board/read_form.html?bid=" + bid + "&aid=" + aid + pn + parent_user_type;
855                                    location.href = url;
856                                }
857                                else { alert(lang.no_permission); }
858                            },
859                            function (xhr) {  }
860                        );
861                    },
862                    function(obj) {
863                        // 부모객체의 작성자 유저 타입을 넘겨준다
864                        var parent_user_type = obj.parent == "1" ? "" : "&put=" + $('tr#' + obj.parent).attr('data-type');
865                        var url = "/module/board/read_form.html?bid=" + bid + "&aid=" + aid + pn + parent_user_type;
866                        location.href = url;
867                    }
868                );
869                break;
870            case "anchor":
871                var url = '/' + table.attr('data-pagenum') + '?bid=' + bid + '&aid=' + aid;
872                location.href = url;
873                break;
874            default:
875                checkAuth(bid, aid,
876                    function(obj) { initialize_currentLocation(bid, aid, obj, table); },
877                    function(obj) {
878                        qvjax_direct(
879                            "check_board_auth",
880                            "/module/board/board.php",
881                            'bid=' + bid + '&aid=' + aid + '&auth_action=read',
882                            function (data) {
883                                if (data) {
884                                    if ((obj.is_secret == 1 && obj.writer_account == null)
885                                        || (obj.is_secret == 1 && $('tr#' + obj.parent).attr('data-type') == 'nm')) {
886                                        $('.read-body').data('article', obj);
887                                        $('#ReadPasswordCheckModal').modal('show');
888                                        $('#ReadPasswordCheckModal').data('article', obj);
889                                        $('#ReadPasswordCheckModal').data('type', 'check_password');
890                                        $('#ReadPasswordCheckModal').data('aid', __AID);
891                                        $('#ReadPasswordCheckModal').data('init-type', type);
892                                        $('#ReadPasswordCheckModal').data('table', table);
893                                    }
894                                    else if (obj.is_secret == 1) {
895                                        alert(lang.no_permission);
896                                        // window.top.close();
897                                    }
898                                    else {
899                                        initialize_currentLocation(bid, aid, obj, table);
900                                    }
901                                }
902                                else { alert(lang.no_permission); }
903                            },
904                            function (xhr) { alert(lang.no_permission); }
905                        );
906                    },
907                    function(obj) {
908                        //if (obj.is_secret == 1 || obj.writer_account == null) {
909                        //if (obj.writer_account == null) {
910                        if ((obj.is_secret == 1 && obj.writer_account == null)
911                            || (obj.is_secret == 1 && obj.reply != '')) {
912                            $('#ReadPasswordCheckModal').modal('show');
913                            $('#ReadPasswordCheckModal').data('article', obj);
914                            $('#ReadPasswordCheckModal').data('type', 'check_password');
915                            $('#ReadPasswordCheckModal').data('aid', __AID);
916                            $('#ReadPasswordCheckModal').data('init-type', type);
917                            $('#ReadPasswordCheckModal').data('table', table);
918                        }
919                        else if (obj.is_secret == 1) {
920                            alert(lang.no_permission);
921                            return;
922                            // window.top.close();
923                        }
924                        else {
925                            initialize_currentLocation(bid, aid, obj, table);
926                        }
927                    }
928                );
929                break;
930        }
931    });
932}
933boardArticleClickEvent();
934
935function boardArticleClickEvent_QA() {
936    $('#main_container').undelegate('.board-table-3 tr.board-tbody-tr', 'click');
937    $('#main_container').delegate('.board-table-3 tr.board-tbody-tr', 'click', function(e) {
938        $(this).children('.board-tbody-item').toggleClass('unfold');
939    });
940}
941boardArticleClickEvent_QA();
942
943function ClearBoardModal(md) {
944    md.find('.board-config-interlock option[value=0]').prop('selected', true);
945    md.find('.board-config-title').val('');
946
947    md.find('.board-config-auth-group-input').children().remove();
948    md.find('.board-config-auth-view option[value=n]').prop('selected',true);
949    md.find('.board-config-auth-read option[value=n]').prop('selected',true);
950    md.find('.board-config-auth-write option[value=n]').prop('selected',true);
951    md.find('.board-config-auth-reply option[value=n]').prop('selected',true);
952    md.find('.board-config-auth-comment option[value=n]').prop('selected',true);
953
954    md.find('.board-config-pagesize option[value0]').prop('selected',true);
955    md.find('.board-config-category-list').children('li').remove();
956
957    md.find('.board-config-placeholder-subject').val('');
958    md.find('.board-config-placeholder-content').val('');
959}
960
961function checkAuth(bid, aid, success_callback, failure_callback, nonmember_callback, password) {
962    console.log('checkAuth', bid, aid)
963    qvjax_direct(
964        "select_board_article_check_auth",
965        "/module/board/board.php",
966        password ? 'bid=' + bid + '&aid=' + aid + '&password=' + password : 'bid=' + bid + '&aid=' + aid,
967        function (data) {
968            var result = $.parseJSON(data);
969            switch(result.type) {
970                case 'success':
971                    success_callback(result.data[0]);
972                    break;
973                case 'failure':
974                    failure_callback(result.data[0]);
975                    break;
976                case 'nonmember':
977                    nonmember_callback(result.data[0]);
978                    break;
979                case 'invalid':
980                    alert('해당 게시판이 존재하지 않습니다.\n주소를 다시 한 번 확인해주세요.');
981                    history.back();
982                    break;
983            }
984        },
985        function (xhr) {
986            console.log(xhr)
987        }
988    );
989}
990
991
992function initialize(data) {
993    initReadForm(__BID, __AID, data, function(data) {
994        initComment(__BID, __AID);
995        initAttachments(__BID, __AID, function() {});
996
997        if (data.writer_account == account ||
998            data.writer_account == null ||
999            isAdmin == 1) {
1000            var html = '<div class="read-content-options-admin">';
1001            html += '<div class="read-content-modify">' + lang.modify + '</div> ';
1002            html += '<div class="read-content-delete">' + lang.remove + '</div>';
1003            html += '</div>';
1004            $('.read-content-options').append(html);
1005        }
1006
1007        $('.read-body').data('article', data);
1008
1009        // 비회원
1010        if (account == "" || account == undefined) {
1011            var html = '<div class="read-comment-nonmember"><input id="read-comment-nonmember-writer" class="form-control read-comment-nonmember-writer" type="text" placeholder="' + lang.writer + '"><input id="read-comment-nonmember-password" class="form-control read-comment-nonmember-password" type="password" placeholder="' + lang.password + '"></div>'
1012            $('#read-comment-textarea').before(html);
1013            $('.read-comment-secret').remove();
1014            $('.read-body').data('type', 'nonmember');
1015        }
1016        // 회원
1017        else {
1018            $('.read-body').data('type', 'member');
1019        }
1020
1021        /* 2020.02.11 재헌
1022         * 이전글, 다음글 기능 추가
1023         */
1024        if (data.prev != null) {
1025            var prevUrl = location.href.replace(data.aid, data.prev);
1026            $('.read-content-prev').off('click.prevArticle');
1027            $('.read-content-prev').on('click.prevArticle', function() {
1028                location.href = prevUrl;
1029            });
1030            $('.read-content-prev').show();
1031        }
1032        if (data.next != null) {
1033            var nextUrl = location.href.replace(data.aid, data.next);
1034            $('.read-content-next').off('click.nextArticle');
1035            $('.read-content-next').on('click.nextArticle', function() {
1036                location.href = nextUrl;
1037            });
1038            $('.read-content-next').show();
1039        }
1040    });
1041}
1042
1043function initialize_currentLocation(bid, aid, data, table) {
1044    var html = '<div class="board-body">';
1045    html += '<div class="read-body">';
1046    html += '<div class="read-content-options top">';
1047    html += '<div class="read-content-options-user">';
1048    html += '<div class="read-content-list">';
1049    html += lang.list;
1050    html += '</div> ';
1051    html += '<div class="read-content-reply">';
1052    html += lang.reply;
1053    html += '</div>';
1054    html += '</div>';
1055    html += '</div>';
1056    html += '<div class="read-top">';
1057    html += '<div class="read-category"></div>';
1058    html += '<div class="read-title"></div>';
1059    html += '<div class="read-options">';
1060    html += '<div class="read-writer">' + lang.writer + ' <div class="read-writer-name"></div></div>';
1061    html += '<div class="read-hits">' + lang.hits + ' <div class="read-hits-count"></div></div>';
1062    html += '<div class="read-views">' + lang.views + ' <div class="read-views-count"></div></div>';
1063    html += '<div class="read-date"></div>';
1064    html += '</div>';
1065    html += '</div>';
1066    html += '<div class="read-content">';
1067    html += '<div class="read-content-inner">' + lang.contents + '</div>';
1068    html += '</div>';
1069
1070    if (account != undefined && account != '') {
1071        html += '<div class="read-recommend">';
1072        html += '<div class="recommend">';
1073        html += '<i class="fa fa-heart"></i>';
1074        html += '<div>' + lang.recommend + '</div>';
1075        html += '</div>';
1076        html += '</div>';
1077    }
1078
1079    html += '<div class="read-attachments">';
1080    html += '<div class="read-attachments-list"></div>';
1081    html += '</div>';
1082    html += '<div class="read-bottom">';
1083    html += '<ul class="read-comment-list">';
1084    html += '</ul>';
1085    html += '<div class="read-comment" id="read-comment">';
1086    html += '<textarea id="read-comment-textarea" class="form-control read-comment-textarea" type="text" placeholder="' + lang.comments + '"></textarea><div class="read-comment-add">' + lang.write_comment + '</div>';
1087    html += '<div class="read-comment-secret"><input type="checkbox" value="0"><div>' + lang.secret_article + '</div></div>';
1088    html += '</div>';
1089    html += '</div>';
1090    html += '<div class="read-content-options bottom">';
1091    html += '<div class="read-content-options-user">';
1092    html += '<div class="read-content-list">';
1093    html += lang.list;
1094    html += '</div> ';
1095    html += '<div class="read-content-prev" style="display: none;"><i class="icon-arrow-up" aria-hidden="true"></i>' + lang.prev_article + '</div> ';
1096    html += '<div class="read-content-next" style="display: none;"><i class="icon-arrow-down" aria-hidden="true"></i>' + lang.next_article + '</div> ';
1097    html += '<div class="read-content-reply">';
1098    html += lang.reply;
1099    html += '</div>';
1100    html += '</div>';
1101    html += '</div>';
1102    html += '</div>';
1103    html += '</div>';
1104
1105    var target = table.parents('.board-theme').first();
1106    var view = target.parents('.view').first();
1107    var columns = target.parents('.column');
1108    target.hide();
1109    view.append($(html));
1110    columns.addClass('table-column');
1111
1112    var scrolltop = view.offset().top - $('.header').height() - 25;
1113    scrolltop = is_InternetExplorer() ? scrolltop + $('body').scrollTop() : scrolltop;
1114    $('html, body').animate({
1115        scrollTop: scrolltop
1116    }, 500);
1117
1118    initReadForm_currentLocation(bid, aid, data, view, function() {
1119        initComment_currentLocation(bid, aid, view);
1120        initAttachments_currentLocation(bid, aid, view, function() {});
1121
1122        if (data.writer_account == account ||
1123            data.writer_account == null ||
1124            isAdmin == 1) {
1125            var html = '<div class="read-content-options-admin">';
1126            html += '<div class="read-content-modify">' + lang.modify + '</div> ';
1127            html += '<div class="read-content-delete">' + lang.remove + '</div>';
1128            html += '</div>';
1129            view.find('.read-content-options').append(html);
1130        }
1131
1132        view.find('.read-body').data('article', data);
1133
1134        // 비회원
1135        if (account == "" || account == undefined) {
1136            var html = '<div class="read-comment-nonmember"><input id="read-comment-nonmember-writer" class="form-control read-comment-nonmember-writer" type="text" placeholder="' + lang.writer + '"><input id="read-comment-nonmember-password" class="form-control read-comment-nonmember-password" type="password" placeholder="' + lang.password + '"></div>'
1137            view.find('.read-comment-textarea').before(html);
1138            view.find('.read-comment-secret').remove();
1139            view.find('.read-body').data('type', 'nonmember');
1140        }
1141        // 회원
1142        else {
1143            view.find('.read-body').data('type', 'member');
1144        }
1145
1146        /* 2020.02.11 재헌
1147         * 이전글, 다음글 기능 추가
1148         */
1149        if (data.prev != null) {
1150            view.find('.read-content-prev').off('click.prevArticle');
1151            view.find('.read-content-prev').on('click.prevArticle', function() {
1152                __BID = bid;
1153                __AID = data.prev;
1154                click_prev_next_currentLocation(this, bid, data.prev, data, table);
1155            });
1156            view.find('.read-content-prev').show();
1157        }
1158        if (data.next != null) {
1159            view.find('.read-content-next').off('click.nextArticle');
1160            view.find('.read-content-next').on('click.nextArticle', function() {
1161                __BID = bid;
1162                __AID = data.next;
1163                click_prev_next_currentLocation(this, bid, data.next, data, table);
1164            });
1165            view.find('.read-content-next').show();
1166        }
1167    });
1168}
1169
1170function initReadForm_currentLocation(bid, aid, article, target, callback) {
1171    qvjax_direct(
1172        "check_board_auth",
1173        "/module/board/board.php",
1174        'bid=' + bid + '&aid=' + aid + '&auth_action=read',
1175        function (data) {
1176            if (data || $('#ReadPasswordCheckModal').data('certification')) {
1177                qvjax_direct(
1178                    "select_board_info",
1179                    "/module/board/board.php",
1180                    'bid=' + bid,
1181                    function (data) {
1182                        if (data.length > 0) {
1183                            $.each(data, function() {
1184                                if (parseInt(this.use_category) == 1) {
1185                                    target.find('.read-category').addClass('read-category-show');
1186                                }
1187                                else {
1188                                    target.find('.read-category').removeClass('read-category-show');
1189                                    target.find('.read-category').remove();
1190                                }
1191
1192                                if (parseInt(this.use_recommend) == 0) {
1193                                    target.find('.read-hits').remove();
1194                                    target.find('.read-recommend').remove();
1195                                }
1196                                else {
1197                                    target.find('.read-hits').css('display', 'inline-block');
1198                                    target.find('.read-recommend').show();
1199                                }
1200
1201                                if (parseInt(this.use_views) == 0) { target.find('.read-views').remove(); } else { target.find('.read-views').css('display', 'inline-block'); }
1202                                if (parseInt(this.use_date) == 0) { target.find('.read-date').remove(); } else { target.find('.read-date').css('display', 'inline-block'); }
1203                                if (parseInt(this.use_writer) == 0) { target.find('.read-writer').remove(); } else { target.find('.read-writer').css('display', 'inline-block'); }
1204                            });
1205                        }
1206                    },
1207                    function (xhr) {}
1208                );
1209
1210                updateViewCount(bid, aid, function() {
1211                    /* 2020.01.23 재헌
1212                       IE에서 col-sm-12가 아니면서 '현재 게시판 위치에 표시' 타입인 게시물을 열 때 큰 이미지가 있으면
1213                       게시판이 한 줄 내려오는 문제
1214                       -> 각 이미지에 id 부여하고 이미지 로딩이 완료되면 width값을 계산해 다시 할당한다.
1215                     */
1216                    /* 2020.06.02 재헌
1217                     * 이미지가 특정 태그 내에 존재할 때 width를 계산해도 해당 크기가 맞지않는 케이스가 있어서
1218                     * 일단 img태그인 항목을 모두 hide시키고 게시글 렌더링이 완료되고 나면 show로 전환
1219                     * show로 전환할 때 max-width 를 parent 기준으로 맞춘다
1220                     */
1221                    if (is_InternetExplorer() && // only ie
1222                        target.parents('.boardBox').length > 0 && // type:default
1223                        $(article.content).find('img').length > 0) {
1224                        var html = '';
1225                        var clone = $(article.content).clone();
1226                        var width = target.width();
1227                        $.each(clone.find('img'), function(i, val) {
1228                            $(this).hide();
1229                        });
1230
1231                        $.each(clone, function() {
1232                            if (this.outerHTML) {
1233                                html += this.outerHTML;
1234                            }
1235                        });
1236
1237                        article.content = html;
1238                    }
1239
1240                    target.find('.read-title').text(article.subject);
1241                    target.find('.read-content-inner').html(article.content);
1242                    target.find('.read-category').text(article.category_name);
1243                    target.find('.read-writer-name').text(changeAdministratorNameLanguage(article.writer));
1244                    target.find('.read-hits-count').text(article.hits);
1245                    target.find('.read-views-count').text(parseInt(article.views) + 1);
1246                    target.find('.read-date').text($.datepicker.formatDate('yy-mm-dd', new Date(article.reg_date*1000)));
1247
1248                    if (article.category_name == '' || article.category_name == null) {
1249                        target.find('.read-category').remove();
1250                    }
1251
1252                    target.find('.read-content-inner img').each(function() {
1253                        var box = $(target).parents('.box').first();
1254                        var margin = parseInt(box.css('margin-left')) + parseInt(box.css('margin-right'));
1255                        var parentWidth = $(this).parents('.box').width() - margin - 30;
1256                        if (parentWidth > 0 && $(this).width() > parentWidth) {
1257                            this.style.setProperty('max-width', parentWidth + 'px', 'important');
1258                        }
1259                        if (parentWidth <= $(this).width()) {
1260                            this.style.setProperty('width', '100%');
1261                        }
1262                        $(this).show();
1263                    });
1264
1265                    callback(article);
1266                });
1267                $('#ReadPasswordCheckModal').removeData('certification');
1268            }
1269            else {
1270                if (article.writer_account == null) {
1271                    $('#ReadPasswordCheckModal').modal('show');
1272                    $('#ReadPasswordCheckModal').data('article', article);
1273                    $('#ReadPasswordCheckModal').data('type', 'check_password');
1274                    $('#ReadPasswordCheckModal').data('aid', aid);
1275                    $('#ReadPasswordCheckModal').data('init-type', 'default');
1276                    $('#ReadPasswordCheckModal').data('table', target.find('table').first());
1277                    target.find('.board-body').remove();
1278                }
1279                else {
1280                    alert(lang.no_permission);
1281                    location.href="/";
1282                }
1283            }
1284        },
1285        function (xhr) {}
1286    );
1287}
1288
1289function initComment_currentLocation(bid, aid, target) {
1290    // comment 작성 폼 초기화
1291    target.find('.read-comment-nonmember-writer').val('');
1292    target.find('.read-comment-nonmember-password').val('');
1293    target.find('.read-comment-textarea').val('');
1294
1295    // 답글 권한이 없으면 답글버튼 삭제
1296    qvjax_direct(
1297        "check_board_auth",
1298        "/module/board/board.php",
1299        'bid=' + bid + '&aid=' + aid + '&auth_action=reply',
1300        function(data) {
1301            if (data || $('#ReadPasswordCheckModal').data('certification')) {
1302                target.find('.read-content-reply').css('display', 'inline-block');
1303            }
1304            else {
1305                target.find('.read-content-reply').remove();
1306            }
1307        },
1308        function (xhr) {
1309            console.log(xhr);
1310        }
1311    );
1312
1313    // 댓글쓰기 권한이 없으면 댓글작성 창 제거
1314    qvjax_direct(
1315        "check_board_auth",
1316        "/module/board/board.php",
1317        'bid=' + bid + '&aid=' + aid + '&auth_action=comment',
1318        function(data) {
1319            if (data || $('#ReadPasswordCheckModal').data('certification')) {
1320                target.find('.read-comment').show();
1321            }
1322            else {
1323                target.find('.read-comment').remove();
1324            }
1325        },
1326        function (xhr) {
1327            console.log(xhr);
1328        }
1329    );
1330
1331    qvjax_direct(
1332        "select_board_comment",
1333        "/module/board/board.php",
1334        'bid=' + bid + '&aid=' + aid,
1335        function (data) {
1336            if (data.length > 0) {
1337                target.find('.read-comment-list').children().remove();
1338
1339                $.each(data, function() {
1340                    var padding = this.comment_reply.length * 20 + 'px';
1341                    var recomment = this.comment_reply.length > 0 ? 're' : '';
1342                    var html = '<li class="' + recomment + '" id="' + this.aid + '" style="padding-left:' + padding + '">';
1343
1344
1345                    var createDateTime = new Date(parseInt(this.reg_date) * 1000);
1346                    var currentDateTime = new Date();
1347                    var compareDateTime = currentDateTime.setDate(currentDateTime.getDate() - 1);
1348                    if (createDateTime > compareDateTime) {
1349                        var date = getNiceTime(parseInt(this.reg_date) * 1000, new Date(), 1, true);
1350                    }
1351                    else {
1352                        var date = $.datepicker.formatDate('yy-mm-dd', createDateTime);
1353                    }
1354                    // var today = new Date();
1355                    // var updateDate = new Date(this.up_date);
1356                    // if (today.toDateString() == updateDate.toDateString()) { var date = '<b>' + this.up_date + '</b>' }
1357                    // else { var date = $.datepicker.formatDate('yy-mm-dd', new Date(this.up_date*1000));}
1358
1359                    html += '<div class="read-comment-top">';
1360                    if (this.is_secret == "1") {
1361                        html += '<div class="read-comment-secret"><i class="icon-lock" aria-hidden="true"></i><span>[' + lang.secret_article + ']</span></div>';
1362                    }
1363                    html += '<div class="read-comment-writer">' + changeAdministratorNameLanguage(this.writer) + '</div>';
1364                    html += '<div class="read-comment-date">' + date + '</div>';
1365                    html += '<div class="read-comment-options">';
1366                    html += '<div class="read-comment-recomment">' + lang.write_comment + '</div>';
1367                    html += '<div class="read-comment-modify">' + lang.modify + '</div>';
1368                    html += '<div class="read-comment-delete">' + lang.remove + '</div>';
1369                    html += '</div></div>';
1370
1371                    var content = this.content.replace(/\n/g, "<br />");
1372                    if (this.is_secret == "1") {
1373                        html += '<div class="read-comment-content"></div>';
1374                        var article_id = this.aid;
1375                        checkAuth(bid, article_id,
1376                            function() { $('#' + article_id + ' .read-comment-content').html(content); },
1377                            function() { $('#' + article_id + ' .read-comment-content').html(lang.is_secret_article); },
1378                            function() {
1379                                $('#' + article_id + ' .read-comment-content').text(lang.is_secret_article);
1380                                $('#' + article_id + ' .read-comment-content').addClass('nm').addClass('secret')
1381                            }
1382                        )
1383                    }
1384                    else {
1385                        html += '<div class="read-comment-content">' + content + '</div>';
1386                    }
1387                    html += '</li>';
1388                    target.find('.read-comment-list').append(html);
1389                });
1390            }
1391        },
1392        function (xhr) {}
1393    );
1394}
1395
1396function initAttachments_currentLocation(bid, aid, target, callback) {
1397    qvjax_direct(
1398        "select_board_file",
1399        "/module/board/board.php",
1400        'bid=' + bid + '&aid=' + aid,
1401        function (data) {
1402            if (data.length > 0) {
1403                var html = '';
1404                $.each(data, function() {
1405                    var textoverflow = (this.file_name.length > 15) ? 'textoverflow' : '';
1406                    html += '<div class="col-sm-2 read-attachments-item ' + textoverflow + '" id=' + this.file_id + '>'
1407                        + '<div class="read-attachments-icon col-sm-3">'
1408                        + '<i class="fa fa-download"></i>'
1409                        + '</div>'
1410                        + '<div class="read-attachments-fileinfo col-sm-9">'
1411                        + '<div class="read-attachments-filename">' + this.file_name + '</div>'
1412                        + '<div class="read-attachments-filesize">' + bytesToSize(this.file_size) + '</div>'
1413                        + '</div>'
1414                        + '</div>';
1415                });
1416
1417                target.find('.read-attachments-list').append(html);
1418            }
1419            callback();
1420        },
1421        function (xhr) {}
1422    );
1423}
1424
1425
1426function checkArticlePassword(array, success_callback, failure_callback) {
1427    checkAuth(array[0].bid, array[0].aid,
1428        function (obj) {
1429            $('.write-body').data('article', obj);
1430            $('.read-body').data('article', obj);
1431
1432            $('#ReadPasswordCheckModal').data('article', obj);
1433
1434            success_callback();
1435        },
1436        function() {
1437            failure_callback();
1438        },
1439        function() {
1440            failure_callback();
1441        },
1442        array[0].password
1443    );
1444    // qvjax_direct(
1445    //     "check_board_article_password",
1446    //     "/module/board/board.php",
1447    //     'json_result=' + encodeURIComponent(JSON.stringify(array)),
1448    //     function (data) {
1449    //         if (data > 0) {
1450    //             success_callback();
1451    //         }
1452    //         else {
1453    //             failure_callback();
1454    //         }
1455    //     },
1456    //     function (xhr) { failure_callback(); }
1457    // );
1458}
1459// function checkAuth(bid, aid, success_callback, failure_callback, nonmember_callback) {
1460//     qvjax_direct(
1461//         "select_board_article",
1462//         "/module/board/board.php",
1463//         'bid=' + bid + '&aid=' + aid,
1464//         function (data) {
1465//             if (data.length > 0) {
1466//                 $.each(data, function () {
1467//                     var article = this;
1468//                     // 관리자
1469//                     var arr_auth = auth.split(',');
1470//                     if ($.inArray('1', arr_auth) >= 0           // 소유자
1471//                         || $.inArray('2', arr_auth) >= 0        // 모든권한
1472//                         || $.inArray('30', arr_auth) >= 0) {    // 게시판관리자
1473//                         success_callback(article);
1474//                     }
1475//                     // 비회원
1476//                     else if (this.writer_account == null) {
1477//                         nonmember_callback(article);
1478//                     }
1479//                     // 일반회원
1480//                     else {
1481//                         qvjax_direct(
1482//                             "check_board_article_owner",
1483//                             "/module/board/board.php",
1484//                             'bid=' + bid + '&aid=' + aid,
1485//                             function (data) {
1486//                                 if (data) { success_callback(article); }
1487//                                 else { failure_callback(article); }
1488//                             },
1489//                             function (xhr) { failure_callback(article); }
1490//                         );
1491//                     }
1492//                 });
1493//             }
1494//         },
1495//         function (xhr) {}
1496//     );
1497// }
1498
1499
1500
1501// 댓글형 게시판
1502function initBoardCommentsBox() {
1503    $.each($('#main_container .boardCommentsBox'), function() {
1504        var bid = 'cmt';
1505        var aid = $(this).attr('data-id');
1506        var target = $(this).find('.view').first();
1507        var pagesize = $(this).attr('data-pagesize');
1508        var reverse = $(this).attr('data-reverse') === "1" ? true : false;
1509        pagesize = pagesize == undefined ? 10 : pagesize;
1510
1511        qvjax_direct(
1512            "select_board_article_contentless",
1513            "/module/board/board.php",
1514            'bid=' + bid + '&aid=' + aid,
1515            function (data) {
1516                if (data.length > 0) {
1517                    target.find('.read-body').data('article', data[0]);
1518
1519                    if (account == "" || account == undefined) {
1520                        var html = '<div class="read-comment-nonmember"><input id="read-comment-nonmember-writer" class="form-control read-comment-nonmember-writer" type="text" placeholder="' + lang.writer + '"><input id="read-comment-nonmember-password" class="form-control read-comment-nonmember-password" type="password" placeholder="' + lang.password + '"></div>'
1521                        target.find('.read-comment-textarea').before(html);
1522                        target.find('.read-body').data('type', 'nonmember');
1523                    }
1524                    else {
1525                        target.find('.read-body').data('type', 'member');
1526                    }
1527                }
1528            },
1529            function(xhr) {}
1530        );
1531
1532        initBoardComments(bid, aid, 1, pagesize, target, reverse);
1533
1534        // Paging num
1535        target.find('.pager').delegate('.btn.btn--basic', 'click', function() {
1536            initBoardComments(bid, aid, parseInt($(this).children('span').text()), pagesize, target, reverse);
1537        });
1538
1539        // Paging left
1540        target.find('.pager').delegate('.paging-btn-group__item.left', 'click', function() {
1541            initBoardComments(bid, aid, 1, pagesize, target, reverse);
1542        });
1543
1544        // Paging right
1545        target.find('.pager').delegate('.paging-btn-group__item.right', 'click', function() {
1546            qvjax_direct(
1547                "count_board_comment",
1548                "/module/board/board.php",
1549                'aid=' + aid,
1550                function (data) {
1551                    initBoardComments(bid, aid, Math.ceil(data/pagesize), pagesize, target, reverse);
1552                },
1553                function (xhr) {}
1554            );
1555        });
1556
1557        // Language
1558        target.find('.read-comment-add').html(lang.write_comment);
1559        target.find('.read-comment-secret > div').html(lang.secret_article);
1560    });
1561}
1562initBoardCommentsBox();
1563
1564function initBoardComments(bid, aid, page, size, target, reverse) {
1565    const method = reverse
1566        ? 'select_comments_board_article_reverse'
1567        : 'select_comments_board_article';
1568
1569    qvjax_direct(
1570        method,
1571        "/module/board/board.php",
1572        'bid=' + bid + '&aid=' + aid + '&page=' + page + '&size=' + size,
1573        function (data) {
1574            target.find('.read-comment-textarea').val('');
1575            target.find('.read-comment-list').children().remove();
1576            target.find('.pager').show();
1577            if (data.length > 0) {
1578                $.each(data, function() {
1579                    var padding = this.comment_reply.length * 20 + 'px';
1580                    var recomment = this.comment_reply.length > 0 ? 're' : '';
1581                    var html = '<li class="' + recomment + '" id="' + this.aid + '" style="padding-left:' + padding + '">';
1582
1583
1584                    var createDateTime = new Date(parseInt(this.reg_date) * 1000);
1585                    var currentDateTime = new Date();
1586                    var compareDateTime = currentDateTime.setDate(currentDateTime.getDate() - 1);
1587                    if (createDateTime > compareDateTime) {
1588                        var date = getNiceTime(parseInt(this.reg_date) * 1000, new Date(), 1, true);
1589                    }
1590                    else {
1591                        var date = $.datepicker.formatDate('yy-mm-dd', createDateTime);
1592                    }
1593
1594                    html += '<div class="read-comment-top">';
1595                    if (this.is_secret == "1") {
1596                        html += '<div class="read-comment-secret"><i class="icon-lock" aria-hidden="true"></i><span>[' + lang.secret_article + ']</span></div>';
1597                    }
1598                    html += '<div class="read-comment-writer">' + changeAdministratorNameLanguage(this.writer) + '</div>';
1599                    html += '<div class="read-comment-date">' + date + '</div>';
1600                    html += '<div class="read-comment-options">';
1601                    html += '<div class="read-comment-recomment">' + lang.write_comment + '</div>';
1602                    html += '<div class="read-comment-modify">' + lang.modify + '</div>';
1603                    html += '<div class="read-comment-delete">' + lang.remove + '</div>';
1604                    html += '</div></div>';
1605
1606                    var content = this.content.replace(/\n/g, "<br />");
1607                    if (this.is_secret == "1") {
1608                        html += '<div class="read-comment-content"></div>';
1609                        var article_id = this.aid;
1610                        checkAuth(bid, article_id,
1611                            function() { $('#' + article_id + ' .read-comment-content').html(content); },
1612                            function() { $('#' + article_id + ' .read-comment-content').html(lang.is_secret_article); },
1613                            function() {
1614                                $('#' + article_id + ' .read-comment-content').text(lang.is_secret_article);
1615                                $('#' + article_id + ' .read-comment-content').addClass('nm').addClass('secret')
1616                            }
1617                        )
1618                    }
1619                    else {
1620                        html += '<div class="read-comment-content">' + content + '</div>';
1621                    }
1622                    html += '</li>';
1623                    target.find('.read-comment-list').append(html);
1624                });
1625            }
1626            else {
1627                target.find('.read-comment-list').append('<div class="read-comment-list-empty">' + lang.no_posts + '</div>');
1628                target.find('.pager').hide();
1629            }
1630
1631            qvjax_direct(
1632                "count_board_comment",
1633                "/module/board/board.php",
1634                'aid=' + aid,
1635                function (data) {
1636                    buildPagingHtml(target, page, size, data, false);
1637                },
1638                function (xhr) {}
1639            );
1640        },
1641        function (xhr) {}
1642    );
1643}
1644
1645function click_prev_next_currentLocation(_this, bid, aid, data, table) {
1646    var view = $(_this).parents('.view').first();
1647    var target = view.find('.board-body');
1648
1649    if ($(_this).parents('.bottom').length > 0) {
1650        $('html, body').animate({
1651            scrollTop: view.offset().top - $('.header').height()
1652        }, 300);
1653    }
1654
1655    $('.table-column').removeClass('table-column');
1656    target.remove();
1657    view.find('.board-theme').show();
1658
1659    checkAuth(bid, aid,
1660        function(obj) { initialize_currentLocation(bid, aid, obj, table); },
1661        function(obj) {
1662            qvjax_direct(
1663                "check_board_auth",
1664                "/module/board/board.php",
1665                'bid=' + bid + '&aid=' + aid + '&auth_action=read',
1666                function (data) {
1667                    if (data) {
1668                        if ((obj.is_secret == 1 && obj.writer_account == null)
1669                            || (obj.is_secret == 1 && $('tr#' + obj.parent).attr('data-type') == 'nm')) {
1670                            $('.read-body').data('article', obj);
1671                            $('#ReadPasswordCheckModal').modal('show');
1672                            $('#ReadPasswordCheckModal').data('article', obj);
1673                            $('#ReadPasswordCheckModal').data('type', 'check_password');
1674                            $('#ReadPasswordCheckModal').data('aid', __AID);
1675                            $('#ReadPasswordCheckModal').data('init-type', type);
1676                            $('#ReadPasswordCheckModal').data('table', table);
1677                        }
1678                        else if (obj.is_secret == 1) {
1679                            alert(lang.no_permission);
1680                            // window.top.close();
1681                        }
1682                        else {
1683                            initialize_currentLocation(bid, aid, obj, table);
1684                        }
1685                    }
1686                    else { alert(lang.no_permission); }
1687                },
1688                function (xhr) { alert(lang.no_permission); }
1689            );
1690        },
1691        function(obj) {
1692            //if (obj.is_secret == 1 || obj.writer_account == null) {
1693            //if (obj.writer_account == null) {
1694            if (obj.is_secret == 1 && obj.writer_account == null) {
1695                $('#ReadPasswordCheckModal').modal('show');
1696                $('#ReadPasswordCheckModal').data('article', obj);
1697                $('#ReadPasswordCheckModal').data('type', 'check_password');
1698                $('#ReadPasswordCheckModal').data('aid', __AID);
1699                $('#ReadPasswordCheckModal').data('init-type', type);
1700                $('#ReadPasswordCheckModal').data('table', table);
1701            }
1702            else if (obj.is_secret == 1) {
1703                alert(lang.no_permission);
1704                return;
1705                // window.top.close();
1706            }
1707            else {
1708                initialize_currentLocation(bid, aid, obj, table);
1709            }
1710        }
1711    );
1712}
1713
1714function changeAdministratorNameLanguage(writer) {
1715    if (writer != '관리자' && writer != '소유자') return writer;
1716    if (LANG && LANG == 'ko') return writer;
1717
1718    return 'Administrator';
1719}
1720
1721
1722function initBoardShare() {
1723    $('.read-body').delegate('.read-share', 'click', function() {
1724        var shareDialog = '';
1725        shareDialog += '<div class="share-dialog">';
1726        shareDialog += '<div class="share-close"></div>';
1727        shareDialog += '<div class="share-media">';
1728        // shareDialog += '<div class="share-media-item" data-media="kakao"><img src="/img/sc/sns/icon/Square-Color/KakaoTalk.png"></div>';
1729        shareDialog += '<div class="share-media-item" data-media="naver"><img src="/img/sc/sns/icon/Square-Color/Naver.png"></div>';
1730        shareDialog += '<div class="share-media-item" data-media="band"><img src="/img/sc/sns/icon/Square-Color/NaverBand.png"></div>';
1731        shareDialog += '<div class="share-media-item" data-media="twitter"><img src="/img/sc/sns/icon/Square-Color/Twitter.png"></div>';
1732        shareDialog += '<div class="share-media-item" data-media="facebook"><img src="/img/sc/sns/icon/Square-Color/Facebook.png"></div>';
1733        shareDialog += '</div>';
1734        shareDialog += '<div class="share-address">';
1735        shareDialog += '<input type="text" id="share-url" readonly/>';
1736        shareDialog += '<div class="share-address-copy">Copy</div>';
1737        shareDialog += '</div>';
1738        shareDialog += '</div>';
1739        $(this).after(shareDialog);
1740
1741        $('.share-address input').val(location.href);
1742    });
1743
1744    $('.read-body').delegate('.share-address-copy', 'click', function() {
1745        var obShareUrl = document.getElementById("share-url");
1746        obShareUrl.select();
1747        document.execCommand("copy");
1748        obShareUrl.blur();
1749
1750        $('.share-address-copy').text('Copied!');
1751    });
1752
1753    $('.read-body').delegate('.share-media-item', 'click', function() {
1754        var media = $(this).attr('data-media');
1755        var title = encodeURIComponent($('.read-title').text());
1756        var url = encodeURIComponent(location.href);
1757
1758        switch(media) {
1759            case 'kakao':
1760                break;
1761            case 'naver':
1762                var redirect = 'https://share.naver.com/web/shareView.nhn?url={0}&title={1}'.format(url, title);
1763                break;
1764            case 'band':
1765                var redirect = 'http://band.us/plugin/share?route={0}&body={1}'.format(url, title);
1766                break;
1767            case 'twitter':
1768                var redirect = 'https://twitter.com/intent/tweet?via=quv&url={0}&text={1}'.format(url, title);
1769                break;
1770            case 'facebook':
1771                var redirect = 'https://www.facebook.com/sharer/sharer.php?u={0}'.format(url);
1772                break;
1773        }
1774        console.log(redirect);
1775        window.open(redirect, '_blank');
1776    });
1777
1778    $('.read-body').delegate('.share-close', 'click', function() {
1779        $('.share-dialog').remove();
1780    });
1781}
1782initBoardShare();
1783
1784
1785$('.read-comment-list').delegate('.read-comment-content.nm.secret', 'click', function() {
1786    var target = $(this).parents('li').first();
1787    var aid = target[0].id;
1788    __BID = 'cmt';
1789    $('#ReadPasswordCheckModal').modal('show');
1790    $('#ReadPasswordCheckModal').data('type', 'update_comment');
1791    $('#ReadPasswordCheckModal').data('aid', aid);
1792});

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.