PageSourceSearch

https://es.re.kr/assets/js/comment.js

js es.re.kr collected 2026-10-01 12:30:38 UTC 8,009 bytes, 221 lines download raw bytes

1if (typeof(COMMENT_JS) === 'undefined') {
2
3    var COMMENT_JS = true;
4    var is_submit_comment = false;
5
6    function view_comment(id, post_id, page, opt, message) {
7        if (opt) {
8            $('html, body').animate({
9                scrollTop: $('#' + id).offset().top - 100
10            }, 0);
11        }
12
13        var comment_url = cb_url + '/comment_list/lists/' + post_id + '?page=' + page;
14        var hash = window.location.hash;
15
16        $('#' + id).load(comment_url, function() {
17            if (message) {
18                $('.alert-comment-list-message-content').html(message);
19                $('.alert-comment-list-message').addClass('alert-success').removeClass('alert-warning').show(0).delay(2500).hide(0);
20            }
21            if (hash) {
22                var st = $(hash).offset().top;
23                $('html, body').animate({ scrollTop: st }, 200); //200ms duration
24            }
25            if (typeof(SyntaxHighlighter) !== 'undefined') {
26                SyntaxHighlighter.highlight();
27            }
28        });
29    }
30
31    function view_comment_password(cmt_id, post_id) {
32        var comment_url = cb_url + '/comment_list/password/' + cmt_id + '/' + post_id;
33        document.location.href=comment_url;
34    }
35
36    function add_comment(f, post_id) {
37
38        if (is_submit_comment === true) {
39            return false;
40        }
41
42        is_submit_comment = true;
43
44        if ($('#char_count')) {
45            if (char_min > 0 || char_max > 0) {
46                var cnt = parseInt(check_byte('cmt_content', 'char_count'));
47                if (char_min > 0 && char_min > cnt) {
48                    alert('내용은 ' + char_min + '글자 이상 쓰셔야 합니다.');
49                    f.cmt_content.focus();
50                    is_submit_comment = false;
51                    return false;
52                } else if (char_max > 0 && char_max < cnt) {
53                    alert('내용은 ' + char_max + '글자 이하로 쓰셔야 합니다.');
54                    f.cmt_content.focus();
55                    is_submit_comment = false;
56                    return false;
57                }
58            }
59        }
60
61        $('#fcomment').validate();
62        if ($('#fcomment').valid()) // check if form is valid
63        {
64            // do some stuff
65        }
66        else
67        {
68            is_submit_comment = false;
69            return false;
70            // just show validation errors, dont post
71        }
72
73        var content = '';
74        $.ajax({
75            url: cb_url + '/postact/filter_spam_keyword',
76            type: 'post',
77            data: {
78                title: '',
79                content: f.cmt_content.value,
80                csrf_test_name: cb_csrf_hash
81            },
82            dataType: 'json',
83            async: false,
84            cache: false,
85            success: function(data) {
86                content = data.content;
87            }
88        });
89        if (content) {
90            alert('내용에 금지단어(\'' + content + '\')가 포함되어있습니다');
91            f.cmt_content.focus();
92            is_submit_comment = false;
93            return false;
94        }
95
96        $.ajax({
97            url : cb_url + '/comment_write/update',
98            type : 'POST',
99            cache : false,
100            data : $('#fcomment').serialize(),
101            dataType : 'json',
102            success : function(data) {
103                is_submit_comment = false;
104                if (data.error) {
105                    $('.alert-comment-message-content').html(data.error);
106                    $('.alert-comment-message').addClass('alert-warning').removeClass('alert-success').show(0).delay(2500).hide(0);
107                    return false;
108                } else if (data.success) {
109                    $('.alert-comment-message-content').html(data.success);
110                    $('.alert-comment-message').addClass('alert-success').removeClass('alert-warning').show(0).delay(2500).hide(0);
111                    view_comment('viewcomment', post_id, '', '')
112                    if ($('#char_count')) {
113                        if (char_min > 0 || char_max > 0) {
114                                check_byte('cmt_content', 'char_count');
115                        }
116                    }
117                    init_comment_box();
118                }
119            },
120            error : function(data) {
121                is_submit_comment = false;
122                alert('오류가 발생하였습니다.');
123                return false;
124            }
125        });
126    }
127
128    function delete_comment(cmt_id, post_id, page) {
129        if (confirm("정말 삭제 하시겠습니까?\n\n삭제하신 후에는 복구가 불가능합니다.")) {
130            $.ajax({
131                url : cb_url + '/postact/delete_comment',
132                type : 'POST',
133                cache : false,
134                data : {cmt_id:cmt_id, csrf_test_name: cb_csrf_hash},
135                dataType : 'json',
136                success : function(data) {
137                    if (data.error) {
138                        $('.alert-comment-list-message-content').html(data.error);
139                        $('.alert-comment-list-message').addClass('alert-warning').removeClass('alert-success').show();
140                        return false;
141                    } else if (data.password) {
142                        $('.alert-comment-list-message-content').html(data.password);
143                        $('.alert-comment-list-message').addClass('alert-warning').removeClass('alert-success').show();
144                        view_comment_password(post_id, cmt_id);
145                        return false;
146                    } else if (data.success) {
147                        view_comment('viewcomment', post_id, '', '', data.success);
148                        init_comment_box();
149                    }
150                },
151                error : function(data) {
152                    alert('오류가 발생하였습니다.');
153                    return false;
154                }
155            });
156        }
157    }
158
159    function comment_page(post_id, page) {
160        view_comment('viewcomment', post_id, page, '');
161        comment_cur_page = page;
162    }
163
164    function init_comment_box() {
165        $('#cmt_nickname').val('');
166        $('#cmt_password').val('');
167        $('#cmt_content').val('');
168        $('#captcha').trigger('click');
169        $('#captcha_key').val('');
170        $('#cmt_btn_submit').prop('disabled', false);
171        check_byte('cmt_content', 'char_count');
172        comment_box('', 'c');
173    }
174
175    var save_before = '';
176    var save_html = document.getElementById('comment_write_box').innerHTML;
177    function comment_box(cmt_id, work) {
178        var el_id;
179        // 댓글 아이디가 넘어오면 답변, 수정
180        if (cmt_id) {
181            if (work === 'c') {
182                el_id = 'reply_' + cmt_id;
183            } else {
184                el_id = 'edit_' + cmt_id;
185            }
186        } else {
187            el_id = 'comment_write_box';
188        }
189
190        if (save_before !== el_id) {
191            if (save_before) {
192                 $('#' + save_before).css('display', 'none');
193                $('#' + save_before).html('');
194            }
195
196            $('#' + el_id).css('display', '');
197            $('#' + el_id).html(save_html);
198            // 댓글 수정
199            if (work === 'cu') {
200                $('#cmt_content').val($('#save_comment_' + cmt_id).val());
201                if (typeof char_count !== 'undefined') {
202                    check_byte('cmt_content', 'char_count');
203                }
204                if ($('#secret_comment_' + cmt_id).val() === '1') {
205                    $('#cmt_secret').prop('checked', true);
206                } else {
207                    $('#cmt_secret').prop('checked', false);
208                }
209            }
210
211            $('#cmt_id').val(cmt_id);
212            $('#mode').val(work);
213
214            if (save_before) {
215                $('#captcha').trigger('click');
216            }
217            save_before = el_id;
218        }
219    }
220    comment_box('', 'c');
221}

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.