PageSourceSearch

https://www.vkusnyblog.com/wp-content/plugins/wpdiscuz/assets/js/wpdiscuz.js?ver=4.0.2.19

js vkusnyblog.com collected 2026-10-03 21:26:37 UTC 51,178 bytes, 1,126 lines download raw bytes

1var onloadCallback = function() {
2    grecaptcha.render('recaptcha-0_0', {'sitekey' : '6LdvVSckAAAAAEcKOJVTVbVY7KzhEKx2QbK6Pe2h', 'theme' : 'light' });
3};
4
5jQuery(document).ready(function ($) {
6    $('body').addClass('wpdiscuz_' + wpdiscuzAjaxObj.wpdiscuz_options.version);
7
8    var isUserLoggedIn = wpdiscuzAjaxObj.wpdiscuz_options.is_user_logged_in;
9    var isShowCaptchaForGuests = wpdiscuzAjaxObj.wpdiscuz_options.wc_captcha_show_for_guest == 1 && !isUserLoggedIn;
10    var isShowCaptchaForMembers = wpdiscuzAjaxObj.wpdiscuz_options.wc_captcha_show_for_members == 1 && isUserLoggedIn;
11    var isCaptchaInSession = wpdiscuzAjaxObj.wpdiscuz_options.isCaptchaInSession;
12    var wpdiscuzRecaptcha = wpdiscuzAjaxObj.wpdiscuz_options.wpDiscuzReCaptcha;
13    var isGoodbyeCaptchaActive = wpdiscuzAjaxObj.wpdiscuz_options.isGoodbyeCaptchaActive;
14    var commentListLoadType = wpdiscuzAjaxObj.wpdiscuz_options.commentListLoadType;
15    var wordpressIsPaginate = wpdiscuzAjaxObj.wpdiscuz_options.wordpressIsPaginate;
16    var wpdiscuzPostId = wpdiscuzAjaxObj.wpdiscuz_options.wc_post_id;
17    var commentListUpdateType = wpdiscuzAjaxObj.wpdiscuz_options.commentListUpdateType;
18    var commentListUpdateTimer = wpdiscuzAjaxObj.wpdiscuz_options.commentListUpdateTimer;
19    var disableGuestsLiveUpdate = wpdiscuzAjaxObj.wpdiscuz_options.liveUpdateGuests;
20    var loadLastCommentId = wpdiscuzAjaxObj.wpdiscuz_options.loadLastCommentId;
21    var wpdiscuzCommentOrder = wpdiscuzAjaxObj.wpdiscuz_options.wordpress_comment_order;
22    var commentsVoteOrder = wpdiscuzAjaxObj.wpdiscuz_options.commentsVoteOrder;
23    var storeCommenterData = wpdiscuzAjaxObj.wpdiscuz_options.storeCommenterData;
24    var wpdiscuzLoadCount = 1;
25    var wpdiscuzCommentOrderBy = 'comment_date_gmt';
26    var wpdiscuzReplyArray = [];
27    var wpdiscuzCommentArray = [];
28    var wpdiscuzUploader = wpdiscuzAjaxObj.wpdiscuz_options.uploader;
29    var commentTextMaxLength = wpdiscuzAjaxObj.wpdiscuz_options.commentTextMaxLength;
30    var wpdGoogleRecaptchaValid = true;
31    var wpdiscuzReplyButton = '';
32
33    loginButtonsClone();
34    displayShowHideReplies();
35    if (commentsVoteOrder) {
36        $('.wpdiscuz-vote-sort-up').addClass('wpdiscuz-sort-button-active');
37        wpdiscuzCommentOrderBy = 'by_vote';
38    } else {
39        $('.wpdiscuz-date-sort-' + wpdiscuzCommentOrder).addClass('wpdiscuz-sort-button-active');
40    }
41    $('#wc_unsubscribe_message').delay(4000).fadeOut(1500, function () {
42        $(this).remove();
43        location.href = location.href.substring(0, location.href.indexOf('subscribeAnchor') - 1);
44    });
45
46    if ($('.wc_main_comm_form').length) {
47        setCookieInForm();
48        wpdiscuzReplaceValidationUI($('.wc_main_comm_form')[0]);
49    }
50    $(document).delegate('.wc-reply-button', 'click', function () {
51        wpdiscuzReplyButton = $(this);
52        if ($(this).hasClass('wpdiscuz-clonned')) {
53            $('#wc-secondary-form-wrapper-' + getUniqueID($(this), 0)).slideToggle(700);
54        } else {
55            cloneSecondaryForm($(this));
56        }
57        $(this).toggleClass('wc-cta-active');
58        setCookieInForm();
59    });
60
61    $(document).delegate('.wc-comment-img-link', 'click', function () {
62        $(this).parents('.wc-comment-img-link-wrap').find('span').toggleClass('wc-comment-img-link-show');
63    });
64
65    $(document).delegate('textarea.wc_comment', 'focus', function () {
66        var parent = $(this).parents('.wc-form-wrapper');
67        $('.commentTextMaxLength', parent).show();
68        $('.wc-form-footer', parent).slideDown(700);
69    });
70
71    $(document).delegate('#wpcomm textarea', 'focus', function () {
72        if (!($(this).next('.autogrow-textarea-mirror').length)) {
73            $(this).autoGrow();
74        }
75    });
76
77    $(document).delegate('textarea.wc_comment', 'blur', function () {
78        var parent = $(this).parents('.wc-form-wrapper');
79        $('.commentTextMaxLength', parent).hide();
80    });
81
82    $(document).delegate('textarea.wc_comment', 'keyup', function () {
83        setTextareaCharCount($(this), commentTextMaxLength);
84    });
85
86    $.each($('textarea.wc_comment'), function () {
87        setTextareaCharCount($(this), commentTextMaxLength);
88    });
89
90    $(document).delegate('.wc-share-link', 'click', function () {
91        var parent = $(this).parents('.wc-comment-right');
92        $('.share_buttons_box', parent).slideToggle(1000);
93        $(this).toggleClass('wc-cta-active');
94    });
95
96    $(document).delegate('.wpdiscuz-nofollow,.wc_captcha_refresh_img,.wc-toggle,.wc-load-more-link', 'click', function (e) {
97        e.preventDefault();
98    });
99
100    $(document).delegate('.wc-toggle', 'click', function () {
101        var uniqueID = getUniqueID($(this), 0);
102        var toggleSpan = $(this);
103        $('#wc-comm-' + uniqueID + '> .wc-reply').slideToggle(700, function () {
104            if ($(this).is(':hidden')) {
105                toggleSpan.html('<i class="fa fa-chevron-down" aria-hidden="true"  title="' + wpdiscuzAjaxObj.wpdiscuz_options.wc_show_replies_text + '"></i>');
106            } else {
107                toggleSpan.html('<i class="fa fa-chevron-up" aria-hidden="true"  title="' + wpdiscuzAjaxObj.wpdiscuz_options.wc_hide_replies_text + '"></i>');
108            }
109        });
110    });
111
112    $(document).delegate('.wc-new-loaded-comment', 'mouseenter', function () {
113        if ($(this).hasClass('wc-reply')) {
114            $('>.wc-comment-right', this).css('backgroundColor', wpdiscuzAjaxObj.wpdiscuz_options.wc_reply_bg_color);
115        } else {
116            $('>.wc-comment-right', this).css('backgroundColor', wpdiscuzAjaxObj.wpdiscuz_options.wc_comment_bg_color);
117        }
118    });
119    //============================== CAPTCHA ============================== //
120    $(document).delegate('.wc_captcha_refresh_img', 'click', function () {
121      //  changeCaptchaImage($(this));
122    });
123    function changeCaptchaImage(reloadImage) {
124        if (!wpdiscuzRecaptcha && !isGoodbyeCaptchaActive && (isShowCaptchaForGuests || isShowCaptchaForMembers)) {
125            var form = reloadImage.parents('.wc-form-wrapper');
126            var keyField = $('.wpdiscuz-cnonce', form);
127            if (isCaptchaInSession) {
128                var uuId = getUUID();
129                var captchaImg = $(reloadImage).prev().children('.wc_captcha_img');
130                var src = captchaImg.attr('src');
131                var fileUrl = src.substring(0, src.indexOf('=') + 1);
132                captchaImg.attr('src', fileUrl + uuId + '&r=' + Math.random());
133                keyField.attr('id', uuId);
134                keyField.attr('value', uuId);
135            } else {
136                var data = new FormData();
137                data.append('action', 'generateCaptcha');
138                var isMain = form.hasClass('wc-secondary-form-wrapper') ? 0 : 1;
139                var uniqueId = getUniqueID(reloadImage, isMain);
140                data.append('wpdiscuz_unique_id', uniqueId);
141                var ajaxObject = getAjaxObj(data);
142                ajaxObject.done(function (response) {
143                    try {
144                        var obj = $.parseJSON(response);
145                        if (obj.code == 1) {
146                            var captchaImg = $(reloadImage).prev().children('.wc_captcha_img');
147                            var src = captchaImg.attr('src');
148                            var lastSlashIndex = src.lastIndexOf('/') + 1;
149                            var newSrc = src.substring(0, lastSlashIndex) + obj.message;
150                            captchaImg.attr('src', newSrc);
151                            keyField.attr('id', obj.key);
152                            keyField.attr('value', obj.key);
153                        }
154                    } catch (e) {
155                        console.log(e);
156                    }
157                    $('.wpdiscuz-loading-bar').hide();
158                });
159            }
160        }
161    }
162
163    function getUUID() {
164        var chars = '123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
165        var uuId = 'c';
166        for (i = 0; i < 13; i++) {
167            uuId += chars[Math.floor(Math.random() * (chars.length - 1) + 1)];
168        }
169        return uuId;
170    }
171//============================== CAPTCHA ============================== //
172//============================== ADD COMMENT FUNCTION ============================== //
173
174    $(document).delegate('.wc_comm_submit', 'click', function () {
175        var depth = 1;
176        var wcForm = $(this).parents('form');
177        if (!wcForm.hasClass('wc_main_comm_form')) {
178            depth = getCommentDepth($(this).parents('.wc-comment'));
179        }
180        if (!wpdiscuzAjaxObj.wpdiscuz_options.is_email_field_required && $('.wc_email', wcForm).val()) {
181            $('.wc_email', wcForm).attr('required', 'required');
182        }
183
184        if (!wpdiscuzAjaxObj.wpdiscuz_options.is_email_field_required && !($('.wc_email', wcForm).val())) {
185            $('.wc_email', wcForm).removeAttr('required');
186        }
187        wpdGoogleRecaptchaValid = true;
188        wpdValidateFieldRequired(wcForm);
189        wcForm.submit(function (event) {
190            event.preventDefault();
191        });
192        if (wcForm[0].checkValidity() && wpdGoogleRecaptchaValid) {
193            var data = new FormData();
194            data.append('action', 'addComment');
195            var inputs = $(":input", wcForm);
196            inputs.each(function () {
197                if (this.name != '' && this.type != 'checkbox' && this.type != 'radio') {
198                    data.append(this.name + '', $(this).val());
199                }
200                if (this.type == 'checkbox' || this.type == 'radio') {
201                    if ($(this).is(':checked')) {
202                        data.append(this.name + '', $(this).val());
203                    }
204                }
205            });
206
207            data.append('wc_comment_depth', depth);
208
209            if (wpdiscuzUploader == 1) {
210                var images = $(wcForm).find('input.wmu-image');
211                var videos = $(wcForm).find('input.wmu-video');
212                var files = $(wcForm).find('input.wmu-file');
213                if (images.length > 0) {
214                    $.each($(images), function (i, imageFile) {
215                        if (imageFile.files.length > 0) {
216                            $.each(imageFile.files, function (j, imageObj) {
217                                data.append('wmu_images[' + i + ']', imageObj);
218                            });
219                        }
220                    });
221                }
222
223                if (videos.length > 0) {
224                    $.each($(videos), function (i, videoFile) {
225                        if (videoFile.files.length > 0) {
226                            $.each(videoFile.files, function (j, videoObj) {
227                                data.append('wmu_videos[' + i + ']', videoObj);
228                            });
229                        }
230                    });
231                }
232
233                if (files.length > 0) {
234                    $.each($(files), function (i, file) {
235                        if (file.files.length > 0) {
236                            $.each(file.files, function (j, fileObj) {
237                                data.append('wmu_files[' + i + ']', fileObj);
238                            });
239                        }
240                    });
241                }
242            }
243
244            if (!wpdiscuzRecaptcha && !isGoodbyeCaptchaActive && (isShowCaptchaForGuests || isShowCaptchaForMembers) && !isCaptchaInSession) {
245                var image = $('.wc_captcha_img', wcForm);
246                var src = image.attr('src');
247                var lastIndex = src.lastIndexOf('/') + 1;
248                var fileName = src.substring(lastIndex);
249                data.append('fileName', fileName);
250            }
251
252            if ($.cookie('wc_author_name') && !$('.wc_name', wcForm).val()) {
253                data.append('wc_name', $.cookie('wc_author_name'));
254            }
255
256            if ($.cookie('wc_author_email') && !$('.wc_email', wcForm).val()) {
257                data.append('wc_email', $.cookie('wc_author_email'));
258            }
259
260            if (wpdiscuzAjaxObj.wpdiscuz_options.wpdiscuz_zs) {
261                data.append('wpdiscuz_zs', wpdiscuzAjaxObj.wpdiscuz_options.wpdiscuz_zs);
262            }
263
264            getAjaxObj(data).done(function (response) {
265                var messageKey = '';
266                var message = '';
267                try {
268                    var obj = $.parseJSON(response);
269                    messageKey = obj.code;
270                    if (parseInt(messageKey) >= 0) {
271                        var isMain = obj.is_main;
272                        message = obj.message;
273                        $('.wc_header_text_count').html(obj.wc_all_comments_count_new);
274                        if (isMain) {
275                            $('.wc-thread-wrapper').append(message); // @NK
276                        } else {
277                            $('#wc-secondary-form-wrapper-' + messageKey).slideToggle(700);
278                            if (obj.is_in_same_container == 1) {
279                                $('#wc-secondary-form-wrapper-' + messageKey).after(message);
280                            } else {
281                                $('#wc-secondary-form-wrapper-' + messageKey).after(message.replace('wc-reply', 'wc-reply wc-no-left-margin'));
282                            }
283                        }
284                        notifySubscribers(obj);
285                        wpdiscuzRedirect(obj);
286                        addCookie(wcForm, obj);
287                        wcForm.get(0).reset();
288                        setCookieInForm();
289                        displayShowHideReplies();
290                        var currTArea = $('.wc_comment', wcForm);
291                        currTArea.css('height', '72px');
292                        setTextareaCharCount(currTArea, commentTextMaxLength);
293                        $('.wmu-preview-wrap', wcForm).remove();
294                        if (wpdiscuzReplyButton.length) {
295                            wpdiscuzReplyButton.removeClass('wc-cta-active');
296                        }
297                    } else {
298                        message = wpdiscuzAjaxObj.wpdiscuz_options[messageKey];
299                        if (obj.typeError != 'undefined' && obj.typeError != null) {
300                            message += ' ' + obj.typeError;
301                        }
302                        wpdiscuzAjaxObj.setCommentMessage(wcForm, messageKey, message, true);
303                    }
304                    if (obj.callbackFunctions != null && obj.callbackFunctions != 'undefined' && obj.callbackFunctions.length) {
305                        $.each(obj.callbackFunctions, function (i) {
306                            if (typeof wpdiscuzAjaxObj[obj.callbackFunctions[i]] === "function") {
307                                wpdiscuzAjaxObj[obj.callbackFunctions[i]](messageKey, wcForm);
308                            } else {
309                                console.log(obj.callbackFunctions[i] + " is not a function");
310                            }
311                        });
312                    }
313                } catch (e) {
314                    if (response.indexOf('<') >= 0 && response.indexOf('>') >= 0) {
315                        message = e;
316                    } else {
317                        message = response;
318                    }
319                    wpdiscuzAjaxObj.setCommentMessage(wcForm, 'wc_invalid_field', message, true);
320                }
321                $('.wpdiscuz-loading-bar').hide();
322            });
323
324            $(document.body).trigger('wpdiscuz_new_comment', [data, wcForm.get(0)]);
325        }
326      //  changeCaptchaImage($('.wc_captcha_refresh_img', wcForm));
327        wpdiscuzReset();
328    });
329
330    function notifySubscribers(obj) {
331        if (!obj.held_moderate) {
332            var data = new FormData();
333            data.append('action', 'checkNotificationType');
334            data.append('comment_id', obj.new_comment_id);
335            data.append('email', obj.user_email);
336            data.append('isParent', obj.is_main);
337            var ajaxObject = getAjaxObj(data);
338            ajaxObject.done(function (response) {
339                try {
340                    obj = $.parseJSON(response);
341                } catch (e) {
342                    //console.log(e);
343                }
344            });
345        }
346    }
347
348    function wpdiscuzRedirect(obj) {
349        if (obj.redirect > 0 && obj.new_comment_id) {
350            var data = new FormData();
351            data.append('action', 'redirect');
352            data.append('commentId', obj.new_comment_id);
353            var ajaxObject = getAjaxObj(data);
354            ajaxObject.done(function (response) {
355                obj = $.parseJSON(response);
356                if (obj.code == 1) {
357                    setTimeout(function () {
358                        window.location.href = obj.redirect_to;
359                    }, 5000);
360                }
361            });
362        }
363    }
364
365    function setCookieInForm() {
366        if ($.cookie('wc_author_name') && $.cookie('wc_author_name').indexOf('Anonymous') < 0) {
367            $('.wc_comm_form .wc_name').val($.cookie('wc_author_name'));
368        }
369        if ($.cookie('wc_author_email') && $.cookie('wc_author_email').indexOf('@example.com') < 0) {
370            $('.wc_comm_form .wc_email').val($.cookie('wc_author_email'));
371        }
372        if ($.cookie('wc_author_website')) {
373            $('.wc_comm_form .wc_website').val($.cookie('wc_author_website'));
374        }
375    }
376
377    function addCookie(wcForm, obj) {
378        var email = '';
379        var name = '';
380        if ($('.wc_email', wcForm).val()) {
381            email = $('.wc_email', wcForm).val();
382        } else {
383            email = obj.user_email;
384        }
385        if ($('.wc_name', wcForm).val()) {
386            name = $('.wc_name', wcForm).val();
387        } else {
388            name = obj.user_name;
389        }
390        if (storeCommenterData == null) {
391            $.cookie('wc_author_email', email);
392            $.cookie('wc_author_name', name);
393            $.cookie('wc_author_website', $('.wc_website', wcForm).val());
394        } else {
395            storeCommenterData = parseInt(storeCommenterData);
396            $.cookie('wc_author_email', email, {expires: storeCommenterData, path: '/'});
397            $.cookie('wc_author_name', name, {expires: storeCommenterData, path: '/'});
398            $.cookie('wc_author_website', $('.wc_website', wcForm).val(), {expires: storeCommenterData, path: '/'});
399        }
400    }
401//============================== ADD COMMENT FUNCTION ============================== //
402//============================== EDIT COMMENT FUNCTION ============================== //
403    var wcCommentTextBeforeEditing;
404
405    $(document).delegate('.wc_editable_comment', 'click', function () {
406        var uniqueID = getUniqueID($(this), 0);
407        var commentID = getCommentID(uniqueID);
408        var editButton = $(this);
409        var data = new FormData();
410        data.append('action', 'editComment');
411        data.append('commentId', commentID);
412        var wcCommentTextBeforeEditingTop = $('#wc-comm-' + uniqueID + ' .wpd-top-custom-fields');
413        var wcCommentTextBeforeEditingBottom = $('#wc-comm-' + uniqueID + ' .wpd-bottom-custom-fields');
414        wcCommentTextBeforeEditing = wcCommentTextBeforeEditingTop.length ? '<div class="wpd-top-custom-fields">' + wcCommentTextBeforeEditingTop.html() + '</div>' : '';
415        wcCommentTextBeforeEditing += '<div class="wc-comment-text">' + $('#wc-comm-' + uniqueID + ' .wc-comment-text').html() + '</div>';
416        wcCommentTextBeforeEditing += wcCommentTextBeforeEditingBottom.length ? '<div class="wpd-bottom-custom-fields">' + $('#wc-comm-' + uniqueID + ' .wpd-bottom-custom-fields').html() + '</div>' : '';
417
418        getAjaxObj(data).done(function (response) {
419            try {
420                var obj = $.parseJSON(response);
421                var message = '';
422                var messageKey = obj.code;
423                if (parseInt(messageKey) >= 0) {
424                    $('#wc-comm-' + uniqueID + ' .wpd-top-custom-fields').remove();
425                    $('#wc-comm-' + uniqueID + ' .wpd-bottom-custom-fields').remove();
426                    $('#wc-comm-' + uniqueID + ' > .wc-comment-right .wc-comment-text').replaceWith(obj.message);
427                    $('#wc-comm-' + uniqueID + ' > .wc-comment-right .wc-comment-footer .wc_editable_comment').hide();
428                    $('#wc-comm-' + uniqueID + ' > .wc-comment-right .wc-comment-footer .wc_cancel_edit').css('display', 'inline-block');
429                    var editForm = $('#wc-comm-' + uniqueID + ' > .wc-comment-right #wpdiscuz-edit-form');
430                    wpdiscuzReplaceValidationUI(editForm[0]);
431                } else {
432                    message = wpdiscuzAjaxObj.wpdiscuz_options[messageKey];
433                    wpdiscuzAjaxObj.setCommentMessage(editButton, messageKey, message, false);
434                }
435            } catch (e) {
436                console.log(e);
437            }
438            $('.wpdiscuz-loading-bar').hide();
439        });
440    });
441
442    $(document).delegate('.wc_save_edited_comment', 'click', function () {
443        var uniqueID = getUniqueID($(this));
444        var commentID = getCommentID(uniqueID);
445        var editCommentForm = $('#wc-comm-' + uniqueID + ' #wpdiscuz-edit-form');
446        var saveButton = $(this);
447        wpdValidateFieldRequired(editCommentForm);
448        editCommentForm.submit(function (event) {
449            event.preventDefault();
450        });
451
452        if (editCommentForm[0].checkValidity()) {
453            var data = new FormData();
454            data.append('action', 'saveEditedComment');
455            data.append('commentId', commentID);
456            var inputs = $(":input", editCommentForm);
457            inputs.each(function () {
458                if (this.name != '' && this.type != 'checkbox' && this.type != 'radio') {
459                    data.append(this.name + '', $(this).val());
460                }
461                if (this.type == 'checkbox' || this.type == 'radio') {
462                    if ($(this).is(':checked')) {
463                        data.append(this.name + '', $(this).val());
464                    }
465                }
466            });
467
468            getAjaxObj(data).done(function (response) {
469                try {
470                    var obj = $.parseJSON(response);
471                    var messageKey = obj.code;
472                    var message = '';
473                    if (parseInt(messageKey) >= 0) {
474                        wcCancelOrSave(uniqueID, obj.message);
475                    } else {
476                        message = wpdiscuzAjaxObj.wpdiscuz_options[messageKey];
477                        wpdiscuzAjaxObj.setCommentMessage(saveButton, messageKey, message, false);
478                    }
479                    if (obj.callbackFunctions != null && obj.callbackFunctions != 'undefined' && obj.callbackFunctions.length) {
480                        $.each(obj.callbackFunctions, function (i) {
481                            if (typeof wpdiscuzAjaxObj[obj.callbackFunctions[i]] === "function") {
482                                wpdiscuzAjaxObj[obj.callbackFunctions[i]](messageKey, commentID, commentContent);
483                            } else {
484                                console.log(obj.callbackFunctions[i] + " is not a function");
485                            }
486                        });
487                    }
488                } catch (e) {
489                    if (response.indexOf('<') >= 0 && response.indexOf('>') >= 0) {
490                        message = e;
491                    } else {
492                        message = response;
493                    }
494                    wpdiscuzAjaxObj.setCommentMessage(saveButton, 'wc_invalid_field', message, false);
495                }
496                $('.wpdiscuz-loading-bar').hide();
497            });
498        }
499    });
500
501    $(document).delegate('.wc_cancel_edit', 'click', function () {
502        var uniqueID = getUniqueID($(this));
503        wcCancelOrSave(uniqueID, wcCommentTextBeforeEditing);
504    });
505
506    function wcCancelOrSave(uniqueID, content) {
507        $('#wc-comm-' + uniqueID + ' > .wc-comment-right .wc-comment-footer .wc_editable_comment').show();
508        $('#wc-comm-' + uniqueID + ' > .wc-comment-right .wc-comment-footer .wc_cancel_edit').hide();
509        $('#wc-comm-' + uniqueID + ' #wpdiscuz-edit-form').replaceWith(content);
510    }
511
512    function nl2br(str, is_xhtml) {
513        var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br/>' : '<br>';
514        var string = (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
515        return string.replace('<br><br>', '<br/>');
516    }
517//============================== EDIT COMMENT FUNCTION ============================== //
518//============================== LOAD MORE ============================== //
519    $(document).delegate('.wc-load-more-submit', 'click', function () {
520        var loadButton = $(this);
521        var loaded = 'wc-loaded';
522        var loading = 'wc-loading';
523        if (loadButton.hasClass(loaded)) {
524            wpdiscuzLoadComments(loadButton, loaded, loading);
525        }
526    });
527
528    var wpdiscuzHasMoreComments = $('#wpdiscuzHasMoreComments').val();
529    var isRun = false;
530    if (commentListLoadType == 2 && !wordpressIsPaginate) {
531        $('.wc-load-more-submit').parents('.wpdiscuz-comment-pagination').hide();
532        $(window).scroll(function () {
533            var scrollHeight = document.getElementById('wcThreadWrapper').scrollHeight;
534            if ($(window).scrollTop() >= scrollHeight && isRun === false && wpdiscuzHasMoreComments == 1) {
535                isRun = true;
536                wpdiscuzLoadComments($('.wc-load-more-submit'));
537            }
538        });
539    }
540
541    function wpdiscuzLoadComments(loadButton, loaded, loading) {
542        loadButton.toggleClass(loaded);
543        loadButton.toggleClass(loading);
544        var data = new FormData();
545        data.append('action', 'loadMoreComments');
546        data.append('offset', wpdiscuzLoadCount);
547        data.append('orderBy', wpdiscuzCommentOrderBy);
548        data.append('order', wpdiscuzCommentOrder);
549        data.append('lastParentId', getLastParentID());
550        wpdiscuzLoadCount++;
551        getAjaxObj(data).done(function (response) {
552            try {
553                var obj = $.parseJSON(response);
554                $('.wpdiscuz-comment-pagination').before(obj.comment_list);
555                setLoadMoreVisibility(obj);
556                $('.wpdiscuz_single').remove();
557                isRun = false;
558                displayShowHideReplies();
559            } catch (e) {
560                console.log(e);
561            }
562            $('.wpdiscuz-loading-bar').hide();
563            $('.wc-load-more-submit').blur();
564            loadButton.toggleClass(loaded);
565            loadButton.toggleClass(loading);
566        });
567    }
568
569    function setLoadMoreVisibility(obj) {
570        var hasMoreComments = 0;
571        if (obj.is_show_load_more == false) {
572            hasMoreComments = 0;
573            wpdiscuzHasMoreComments = 0;
574            $('.wc-load-more-submit').parents('.wpdiscuz-comment-pagination').hide();
575        } else {
576            setLastParentID(obj.last_parent_id);
577            wpdiscuzHasMoreComments = 1;
578            hasMoreComments = 1;
579        }
580        $('#wpdiscuzHasMoreComments').val(hasMoreComments);
581    }
582
583//============================== LOAD MORE ============================== //
584//============================== VOTE  ============================== //
585    $(document).delegate('.wc_vote.wc_not_clicked', 'click', function () {
586        var currentVoteBtn = $(this);
587        $(currentVoteBtn).removeClass('wc_not_clicked');
588        var messageKey = '';
589        var message = '';
590        var commentID = $(this).parents('.wc-comment-right').attr('id');
591        commentID = commentID.substring(commentID.lastIndexOf('-') + 1);
592        var voteType;
593        if ($(this).hasClass('wc-up')) {
594            voteType = 1;
595        } else {
596            voteType = -1;
597        }
598
599        var data = new FormData();
600        data.append('action', 'voteOnComment');
601        data.append('commentId', commentID);
602        data.append('voteType', voteType);
603        getAjaxObj(data).done(function (response) {
604            $(currentVoteBtn).addClass('wc_not_clicked');
605            try {
606                var obj = $.parseJSON(response);
607                messageKey = obj.code;
608                if (parseInt(messageKey) >= 0) {
609                    if (obj.buttonsStyle == 'total') {
610                        var voteCountDiv = $('.wc-comment-footer .wc-vote-result', $('#comment-' + commentID));
611                        voteCountDiv.text(parseInt(voteCountDiv.text()) + voteType);
612                    } else {
613                        var likeCountDiv = $('.wc-comment-footer .wc-vote-result-like', $('#comment-' + commentID));
614                        var dislikeCountDiv = $('.wc-comment-footer .wc-vote-result-dislike', $('#comment-' + commentID));
615                        likeCountDiv.text(obj.likeCount);
616                        dislikeCountDiv.text(obj.dislikeCount);
617                        parseInt(obj.likeCount) > 0 ? likeCountDiv.addClass('wc-positive') : likeCountDiv.removeClass('wc-positive');
618                        parseInt(obj.dislikeCount) < 0 ? dislikeCountDiv.addClass('wc-negative') : dislikeCountDiv.removeClass('wc-negative');
619                    }
620                } else {
621                    message = wpdiscuzAjaxObj.wpdiscuz_options[messageKey];
622                    wpdiscuzAjaxObj.setCommentMessage(currentVoteBtn, messageKey, message, false);
623                }
624                if (obj.callbackFunctions != null && obj.callbackFunctions != 'undefined' && obj.callbackFunctions.length) {
625                    $.each(obj.callbackFunctions, function (i) {
626                        if (typeof wpdiscuzAjaxObj[obj.callbackFunctions[i]] === "function") {
627                            wpdiscuzAjaxObj[obj.callbackFunctions[i]](messageKey, commentID, voteType);
628                        } else {
629                            console.log(obj.callbackFunctions[i] + " is not a function");
630                        }
631                    });
632                }
633            } catch (e) {
634                console.log(e);
635            }
636            $('.wpdiscuz-loading-bar').hide();
637        });
638    });
639//============================== VOTE ============================== //
640//============================== SORTING ============================== //
641    $(document).delegate('.wpdiscuz-sort-button', 'click', function () {
642        wpdiscuzHasMoreComments = $('#wpdiscuzHasMoreComments').val();
643        if (!($(this).hasClass('wpdiscuz-sort-button-active'))) {
644            var clickedBtn = $(this);
645            if ($(this).hasClass('wpdiscuz-vote-sort-up')) {
646                wpdiscuzCommentOrderBy = 'by_vote';
647                wpdiscuzCommentOrder = 'desc';
648            } else {
649                wpdiscuzCommentOrderBy = 'comment_date_gmt';
650                wpdiscuzCommentOrder = $(this).hasClass('wpdiscuz-date-sort-desc') ? 'desc' : 'asc';
651            }
652            var data = new FormData();
653            data.append('action', 'wpdiscuzSorting');
654            data.append('orderBy', wpdiscuzCommentOrderBy);
655            data.append('order', wpdiscuzCommentOrder);
656
657            var messageKey = '';
658            var message = '';
659            getAjaxObj(data).done(function (response) {
660                try {
661                    var obj = $.parseJSON(response);
662                    messageKey = obj.code;
663                    message = obj.message;
664                    if (parseInt(messageKey) > 0) {
665                        $('#wpcomm .wc-thread-wrapper .wc-comment').each(function () {
666                            $(this).remove();
667                        });
668                        $('#wpcomm .wc-thread-wrapper').prepend(message);
669                        wpdiscuzLoadCount = parseInt(obj.loadCount);
670                    } else {
671                    }
672                    setActiveButton(clickedBtn);
673                    setLoadMoreVisibility(obj);
674                } catch (e) {
675                    console.log(e);
676                }
677                displayShowHideReplies();
678                $('.wpdiscuz-loading-bar').hide();
679            });
680        }
681    });
682
683    function setActiveButton(clickedBtn) {
684        $('.wpdiscuz-sort-buttons .wpdiscuz-sort-button').each(function () {
685            $(this).removeClass('wpdiscuz-sort-button-active');
686        });
687        clickedBtn.addClass('wpdiscuz-sort-button-active');
688    }
689
690//============================== SORTING ============================== //
691//============================== SINGLE COMMENT ============================== //
692    function getSingleComment() {
693        var loc = location.href;
694        var matches = loc.match(/#comment\-(\d+)/);
695        if (matches !== null) {
696            var commentId = matches[1];
697            if (!$('#comment-' + commentId).length) {
698                var data = new FormData();
699                data.append('action', 'getSingleComment');
700                data.append('commentId', commentId);
701                var ajaxObject = getAjaxObj(data);
702                ajaxObject.done(function (response) {
703                    try {
704                        var obj = $.parseJSON(response);
705                        $('.wc-thread-wrapper').prepend(obj.message);
706                        $('html, body').animate({
707                            scrollTop: $(".wc-thread-wrapper").offset().top
708                        }, 1000);
709                    } catch (e) {
710                        console.log(e);
711                    }
712                    $('.wpdiscuz-loading-bar').hide();
713                });
714            }
715        }
716    }
717    getSingleComment();
718//============================== SINGLE COMMENT ============================== //
719//============================== LIVE UPDATE ============================== //
720    if (commentListUpdateType > 0 && loadLastCommentId && (isUserLoggedIn || (!isUserLoggedIn && !disableGuestsLiveUpdate))) {
721        setInterval(liveUpdate, parseInt(commentListUpdateTimer) * 1000);
722    }
723
724    function liveUpdate() {
725        var visibleCommentIds = getVisibleCommentIds();
726        var email = ($.cookie('wc_author_email') != undefined && $.cookie('wc_author_email') != '') ? $.cookie('wc_author_email') : '';
727        var data = new FormData();
728        data.append('action', 'updateAutomatically');
729        data.append('loadLastCommentId', loadLastCommentId);
730        data.append('visibleCommentIds', visibleCommentIds);
731        data.append('email', email);
732        var ajaxObject = getAjaxObj(data);
733        ajaxObject.done(function (response) {
734            try {
735                var obj = $.parseJSON(response);
736                if (obj.code == 1) {
737                    if (commentListUpdateType == 1) {
738                        liveUpdateImmediately(obj);
739                    } else {
740                        wpdiscuzCommentArray = wpdiscuzCommentArray.concat(obj.message.comments);
741                        wpdiscuzReplyArray = wpdiscuzReplyArray.concat(obj.message.author_replies);
742                        var newCommentArrayLength = wpdiscuzCommentArray.length;
743                        var newRepliesArrayLength = wpdiscuzReplyArray.length;
744                        if (newCommentArrayLength > 0) {
745                            var newCommentText = newCommentArrayLength + ' ';
746                            newCommentText += newCommentArrayLength > 1 ? wpdiscuzAjaxObj.wpdiscuz_options.wc_new_comments_button_text : wpdiscuzAjaxObj.wpdiscuz_options.wc_new_comment_button_text;
747                            $('.wc_new_comment').html(newCommentText).show();
748                        } else {
749                            $('.wc_new_comment').hide();
750                        }
751                        if (newRepliesArrayLength > 0) {
752                            var newReplyText = newRepliesArrayLength + ' ';
753                            newReplyText += newRepliesArrayLength > 1 ? wpdiscuzAjaxObj.wpdiscuz_options.wc_new_replies_button_text : wpdiscuzAjaxObj.wpdiscuz_options.wc_new_reply_button_text;
754                            $('.wc_new_reply').html(newReplyText).show();
755                        } else {
756                            $('.wc_new_reply').hide();
757                        }
758                    }
759                    $('.wc_header_text_count').html(obj.wc_all_comments_count_new);
760                    loadLastCommentId = obj.loadLastCommentId;
761                }
762            } catch (e) {
763                console.log(e);
764            }
765            $('.wpdiscuz-loading-bar').hide();
766        });
767    }
768
769    function liveUpdateImmediately(obj) {
770        if (obj.message !== undefined) {
771            var commentObject;
772            var message = obj.message;
773            for (var i = 0; i < message.length; i++) {
774                commentObject = message[i];
775                addCommentToTree(commentObject.comment_parent, commentObject.comment_html);
776            }
777            displayShowHideReplies();
778        }
779    }
780
781    $(document).delegate('.wc-update-on-click', 'click', function () {
782        var data = new FormData();
783        data.append('action', 'updateOnClick');
784        var clickedButton = $(this);
785        if (clickedButton.hasClass('wc_new_comment')) {
786            data.append('newCommentIds', wpdiscuzCommentArray.join());
787        } else {
788            data.append('newCommentIds', wpdiscuzReplyArray.join());
789        }
790
791        getAjaxObj(data).done(function (response) {
792            try {
793                var obj = $.parseJSON(response);
794                liveUpdateImmediately(obj);
795                if (clickedButton.hasClass('wc_new_comment')) {
796                    wpdiscuzCommentArray = [];
797                    $('.wc_new_comment').hide();
798                } else {
799                    wpdiscuzReplyArray = [];
800                    $('.wc_new_reply').hide();
801                }
802            } catch (e) {
803                console.log(e);
804            }
805            $('.wpdiscuz-loading-bar').hide();
806        });
807    });
808//============================== LIVE UPDATE ============================== //
809//============================== READ MORE ============================== //
810    $(document).delegate('.wpdiscuz-readmore', 'click', function () {
811        var uniqueId = getUniqueID($(this));
812        var commentId = getCommentID(uniqueId);
813        var data = new FormData();
814        data.append('action', 'readMore');
815        data.append('commentId', commentId);
816        getAjaxObj(data).done(function (response) {
817            try {
818                var obj = $.parseJSON(response);
819                if (obj.code) {
820                    $('#comment-' + commentId + ' .wc-comment-text').html(' ' + obj.message);
821                    $('#wpdiscuz-readmore-' + uniqueId).remove();
822                }
823            } catch (e) {
824                console.log(e);
825            }
826            $('.wpdiscuz-loading-bar').hide();
827        });
828    });
829//============================== READ MORE ============================== //
830
831//============================== FUNCTIONS ============================== //
832    /**
833     * field - the clicked element
834     * messagekey - the key for adding class on message container
835     * message - the message to add
836     * isformerror - whether the error is form or not
837     */
838    wpdiscuzAjaxObj.setCommentMessage = function (field, messageKey, message, isFormError) {
839        var msgContainer;
840        var parentContainer;
841        if (isFormError) {
842            parentContainer = field.parents('.wc-form-wrapper');
843        } else {
844            parentContainer = field.closest('.wc-comment');
845        }
846        msgContainer = parentContainer.children('.wpdiscuz-comment-message');
847        msgContainer.removeClass();
848        msgContainer.addClass('wpdiscuz-comment-message');
849        msgContainer.addClass(messageKey);
850        msgContainer.html(message);
851        msgContainer.show().delay(4000).fadeOut(1000, function () {
852            msgContainer.removeClass();
853            msgContainer.addClass('wpdiscuz-comment-message');
854            msgContainer.html('');
855        });
856
857    }
858
859    function load_recap() {
860        if (loggedin == 1 || window.grecap_loaded && window.grecap_loaded == true ) {
861            return;
862        }
863        var script = document.createElement('script');
864        script.src = "https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit";
865
866        document.head.appendChild(script);
867        window.grecap_loaded = true;
868    }
869
870    (function($) {
871        $(document).delegate('textarea.wc_comment', 'focus', function () {
872            var uniqueId = this.id.replace('wc-textarea-', '');
873            reinit_grecaptcha(uniqueId);
874        });
875    })(jQuery);
876
877	 function reinit_grecaptcha(uniqueId) {
878         load_recap();
879         if ( typeof grecaptcha === 'undefined' ) {
880             return;
881         }
882
883         try{
884             grecaptcha.render('recaptcha-'+uniqueId, {
885                 'sitekey' : '6LdvVSckAAAAAEcKOJVTVbVY7KzhEKx2QbK6Pe2h'
886             });
887         }catch(error){}
888	 }
889
890    function cloneSecondaryForm(field) {
891        var uniqueId = getUniqueID(field, 0);
892        $('#wpdiscuz_form_anchor-' + uniqueId).before(replaceUniqueId(uniqueId));
893        var secondaryFormWrapper = $('#wc-secondary-form-wrapper-' + uniqueId);
894        wpdiscuzReplaceValidationUI($('.wc_comm_form', secondaryFormWrapper)[0]);
895        secondaryFormWrapper.slideToggle(700, function () {
896            field.addClass('wpdiscuz-clonned');
897        });
898      //  changeCaptchaImage($('.wc_captcha_refresh_img', secondaryFormWrapper));
899		reinit_grecaptcha(uniqueId);
900    }
901
902    function replaceUniqueId(uniqueId) {
903        var secondaryForm = $('#wpdiscuz_hidden_secondary_form').html();
904        return secondaryForm.replace(/wpdiscuzuniqueid/g, uniqueId);
905    }
906
907    function getUniqueID(field, isMain) {
908        var fieldID = '';
909        if (isMain) {
910            fieldID = field.parents('.wc-main-form-wrapper').attr('id');
911        } else {
912            fieldID = field.parents('.wc-comment').attr('id');
913        }
914        var uniqueID = fieldID.substring(fieldID.lastIndexOf('-') + 1);
915        return uniqueID;
916    }
917
918    function getCommentID(uniqueID) {
919        return uniqueID.substring(0, uniqueID.indexOf('_'));
920    }
921
922    function getLastParentID() {
923        var url = $('.wc-load-more-link').attr("href");
924        return url.substring(url.lastIndexOf('=') + 1);
925    }
926
927    function setLastParentID(lastParentID) {
928        var url = $('.wc-load-more-link').attr("href");
929        $('.wc-load-more-link').attr("href", url.replace(/[\d]+$/m, lastParentID));
930        if (commentListLoadType != 2) {
931            $('.wpdiscuz-comment-pagination').show();
932        }
933    }
934
935
936    function getCommentDepth(field) {
937        var fieldClasses = field.attr('class');
938        var classesArray = fieldClasses.split(' ');
939        var depth = '';
940        $.each(classesArray, function (index, value) {
941            if ('wc_comment_level' === getParentDepth(value, false)) {
942                depth = getParentDepth(value, true);
943            }
944        });
945        return parseInt(depth) + 1;
946    }
947
948    function getParentDepth(depthValue, isNumberPart) {
949        var depth = '';
950        if (isNumberPart) {
951            depth = depthValue.substring(depthValue.indexOf('-') + 1);
952        } else {
953            depth = depthValue.substring(0, depthValue.indexOf('-'));
954        }
955        return depth;
956    }
957
958    function addCommentToTree(parentId, comment) {
959        if (parentId == 0) {
960            $('.wc-thread-wrapper').prepend(comment);
961        } else {
962            var parentUniqueId = getUniqueID($('#comment-' + parentId), 0);
963            $('#wpdiscuz_form_anchor-' + parentUniqueId).after(comment);
964        }
965    }
966
967    function getVisibleCommentIds() {
968        var uniqueId;
969        var commentId;
970        var visibleCommentIds = '';
971        $('.wc-comment-right').each(function () {
972            uniqueId = getUniqueID($(this), 0);
973            commentId = getCommentID(uniqueId);
974            visibleCommentIds += commentId + ',';
975        });
976        return visibleCommentIds;
977    }
978
979    function loginButtonsClone() {
980        if ($('.wc_social_plugin_wrapper .wp-social-login-provider-list').length) {
981            $('.wc_social_plugin_wrapper .wp-social-login-provider-list').clone().prependTo('#wpdiscuz_hidden_secondary_form > .wc-form-wrapper >  .wc-secondary-forms-social-content');
982        } else if ($('.wc_social_plugin_wrapper .the_champ_login_container').length) {
983            $('.wc_social_plugin_wrapper .the_champ_login_container').clone().prependTo('#wpdiscuz_hidden_secondary_form > .wc-form-wrapper >  .wc-secondary-forms-social-content');
984        } else if ($('.wc_social_plugin_wrapper .social_connect_form').length) {
985            $('.wc_social_plugin_wrapper .social_connect_form').clone().prependTo('#wpdiscuz_hidden_secondary_form > .wc-form-wrapper >  .wc-secondary-forms-social-content');
986        } else if ($('.wc_social_plugin_wrapper .oneall_social_login_providers').length) {
987            $('.wc_social_plugin_wrapper .oneall_social_login .oneall_social_login_providers').clone().prependTo('#wpdiscuz_hidden_secondary_form > .wc-form-wrapper >  .wc-secondary-forms-social-content');
988        }
989    }
990
991    function displayShowHideReplies() {
992        $('#wcThreadWrapper .wc-comment').each(function (i) {
993            if ($('> .wc-reply', this).length) {
994                $('> .wc-comment-right .wc-comment-footer .wc-toggle', this).removeClass('wpdiscuz-hidden');
995            }
996        });
997    }
998
999    /**
1000     * @param {type} action the action key
1001     * @param {type} data the request properties
1002     * @returns {jqXHR}
1003     */
1004    function getAjaxObj(data) {
1005        if (data.action !== 'liveUpdate') {
1006            $('.wpdiscuz-loading-bar').show();
1007        }
1008
1009
1010
1011        var truePostId = window.wpdiscuzPostId;
1012        if(!truePostId) truePostId = wpdiscuzPostId
1013
1014        // console.log(truePostId);
1015        data.append('postId', truePostId);
1016
1017
1018        console.log(data);
1019        return $.ajax({
1020            type: 'POST',
1021            url: wpdiscuzAjaxObj.url,
1022            data: data,
1023            contentType: false,
1024            processData: false,
1025        });
1026    }
1027
1028    function wpdiscuzReset() {
1029        $('.wpdiscuz_reset').val("");
1030    }
1031
1032    function setTextareaCharCount(elem, count) {
1033        if (commentTextMaxLength != null) {
1034            var currLength = elem.val().length;
1035            var textareaWrap = elem.parents('.wc_comm_form');
1036            var charCountDiv = $('.commentTextMaxLength', textareaWrap);
1037            var left = commentTextMaxLength - currLength;
1038            if (left <= 10) {
1039                charCountDiv.addClass('left10');
1040            } else {
1041                charCountDiv.removeClass('left10');
1042            }
1043            charCountDiv.html(left);
1044        }
1045    }
1046
1047    function wpdValidateFieldRequired(form) {
1048        var fieldsGroup = form.find('.wpd-required-group');
1049        $.each(fieldsGroup, function () {
1050            $('input', this).removeAttr('required');
1051            var checkedFields = $('input:checked', this);
1052            if (checkedFields.length === 0) {
1053                $('input', $(this)).attr('required', 'required');
1054            } else {
1055                $('.wpd-field-invalid', this).remove();
1056            }
1057        });
1058
1059        if (wpdiscuzRecaptcha && $('input[name=wpdiscuz_recaptcha]', form).length && !$('input[name=wpdiscuz_recaptcha]', form).val().length) {
1060            wpdGoogleRecaptchaValid = false;
1061            $('.wpdiscuz-recaptcha', form).css('border', '1px solid red');
1062        } else if (wpdiscuzRecaptcha) {
1063            $('.wpdiscuz-recaptcha', form).css('border', 'none');
1064        }
1065    }
1066
1067    //============================== FUNCTIONS ============================== //
1068
1069    //=================== FORM VALIDATION ================================//
1070    function wpdiscuzReplaceValidationUI(form) {
1071        form.addEventListener("invalid", function (event) {
1072            event.preventDefault();
1073        }, true);
1074        form.addEventListener("submit", function (event) {
1075            if (!this.checkValidity()) {
1076                event.preventDefault();
1077            }
1078        });
1079    }
1080
1081    $(document).delegate('.wc_comm_submit, .wc_save_edited_comment', 'click', function () {
1082        var curentForm = $(this).parents('form');
1083        var invalidFields = $(':invalid', curentForm),
1084                errorMessages = $('.error-message', curentForm),
1085                parent;
1086
1087        for (var i = 0; i < errorMessages.length; i++) {
1088            errorMessages[ i ].parentNode.removeChild(errorMessages[ i ]);
1089        }
1090        for (var i = 0; i < invalidFields.length; i++) {
1091            parent = invalidFields[ i ].parentNode;
1092            var oldMsg = parent.querySelector('.wpd-field-invalid');
1093            if (oldMsg) {
1094                parent.removeChild(oldMsg);
1095            }
1096            if (invalidFields[ i ].validationMessage !== '') {
1097                parent.insertAdjacentHTML("beforeend", "<div class='wpd-field-invalid'><span>" +
1098                        invalidFields[ i ].validationMessage +
1099                        "</span></div>");
1100            }
1101        }
1102    });
1103
1104    function wpdiscuzRemoveError(field) {
1105        var wpdiscuzErrorDiv = $(field).parents('div.wpdiscuz-item').find('.wpd-field-invalid');
1106        if (wpdiscuzErrorDiv) {
1107            wpdiscuzErrorDiv.remove();
1108        }
1109    }
1110    $(document).delegate('.wpdiscuz-item input,.wpdiscuz-item textarea,.wpdiscuz-item select', 'click', function () {
1111        wpdiscuzRemoveError($(this));
1112    });
1113
1114    $(document).delegate('.wpdiscuz-item input,.wpdiscuz-item textarea,.wpdiscuz-item select', 'focus', function () {
1115        wpdiscuzRemoveError($(this));
1116    });
1117
1118    $(document).delegate('.wpd-required-group', 'change', function () {
1119        if ($('input:checked', this).length !== 0) {
1120            $('.wpd-field-invalid', this).remove();
1121            $('input', $(this)).removeAttr('required');
1122        } else {
1123            $('input', $(this)).attr('required', 'required');
1124        }
1125    });
1126});

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.