PageSourceSearch

https://kitweonline.com/wp-content/plugins/wp-comment-designer-lite/js/wpcd-frontend.js?ver=2.0.5

js kitweonline.com collected 2026-09-25 02:02:55 UTC 14,199 bytes, 293 lines download raw bytes

1jQuery(document).ready(function ($) {
2    // for removing unnecessary p tags from frontend
3    $('.wp-comment-designer-lite-wrap p').filter(function () {
4        return $.trim($(this).text()) === '' && $(this).children().length == 0
5    }).remove()
6
7    $('.wp-comment-designer-lite-wrap small').filter(function () {
8        return $.trim($(this).text()) === '' && $(this).children().length == 0
9    }).remove()
10    // for removing unnecessary br tags from frontend
11    $('.wp-comment-designer-lite-wrap').find('br').remove()
12    
13    // Control Like/Dislike using Cookies for comment rating
14    function wpcd_setCookie(cname, cvalue, exdays) {
15        var d = new Date();
16        d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
17        var expires = "expires=" + d.toUTCString();
18        document.cookie = cname + "=" + cvalue + "; " + expires;
19    }
20
21    function wpcd_getCookie(cname) {
22        var name = cname + "=";
23        var ca = document.cookie.split(';');
24         for (var i = 0; i < ca.length; i++) {
25            var c = ca[i];
26            while (c.charAt(0) == ' ') {
27                c = c.substring(1);
28            }
29            if (c.indexOf(name) == 0) {
30                return c.substring(name.length, c.length);
31            }
32        }
33        return "";
34    }
35
36    function wpcd_deleteCookie(name) {
37        document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
38    }
39
40    $('body').on('click', '.wpcd-like-dislike-trigger', function(e) {
41        var $this = $(this);
42        e.preventDefault();
43        var comment_id = $(this).data('comment-id');
44        var trigger_type = $(this).data('trigger-type');
45        var wpcd_like_cookie = wpcd_getCookie('wpcd_like_' + comment_id);
46        var wpcd_dislike_cookie = wpcd_getCookie('wpcd_dislike_' + comment_id);
47        var current_like_count = $this.closest('.wpcd-like-dislike-wrapper').find('.wpcd-like-count-wrap').html();
48        var current_dislike_count = $this.closest('.wpcd-like-dislike-wrapper').find('.wpcd-dislike-count-wrap').html();
49
50        //when clicked on like
51        if(trigger_type == 'like' && wpcd_like_cookie == '' ){
52            if (!$this.hasClass('wpcd-dislike-trigger')) {
53                var cookie_name = 'wpcd_' + trigger_type + '_' + comment_id;
54                wpcd_setCookie(cookie_name, 1, 365);
55                if (wpcd_dislike_cookie == '') {
56                    var end_character = current_like_count.slice(-1);
57                    if(end_character=="K" || end_character=="M" || end_character=="B" || end_character=="T")
58                    {
59                        var new_like_count = parseInt(current_like_count);
60                        var new_dislike_count = parseInt(current_dislike_count);
61                    }
62                    else{
63                        var new_like_count = parseInt(current_like_count) + 1;
64                        var new_dislike_count = parseInt(current_dislike_count);
65                    }
66                }
67                if (wpcd_dislike_cookie != '') {
68                    var end_character = current_like_count.slice(-1);
69                    if(end_character=="K" || end_character=="M" || end_character=="B" || end_character=="T")
70                    {
71                        var new_like_count = parseInt(current_like_count);
72                        var new_dislike_count = parseInt(current_dislike_count);
73                    }
74                    else{
75                        var new_dislike_count = parseInt(current_dislike_count) - 1;
76                        if (new_dislike_count < 0){
77                            new_dislike_count = 0;
78                        }
79                        var new_like_count = parseInt(current_like_count) + 1;
80                    }
81                }
82                $('#wpcd-like-count-' + comment_id).html(new_like_count);
83                $('#wpcd-dislike-count-' + comment_id).html(new_dislike_count);
84                var not_trigger_type = 'dislike';
85                wpcd_like_dislike_cookie(trigger_type, comment_id, $this, not_trigger_type);
86            }
87        }
88        //when clicked on dislike
89        if (wpcd_dislike_cookie == '' && trigger_type == 'dislike') {
90            var cookie_name = 'wpcd_' + trigger_type + '_' + comment_id;
91            wpcd_setCookie(cookie_name, 1, 365);
92            if (!$this.hasClass('wpcd-like-trigger')) {
93                if (wpcd_like_cookie == '') {
94                    var end_character = current_dislike_count.slice(-1);
95                    if(end_character=="K" || end_character=="M" || end_character=="B" || end_character=="T")
96                    {
97                        var new_like_count = parseInt(current_like_count);
98                        var new_dislike_count = parseInt(current_dislike_count);
99                    }else{
100                        var new_dislike_count = parseInt(current_dislike_count) + 1;
101                        var new_like_count = parseInt(current_like_count);
102                    }
103                }
104                if (wpcd_like_cookie != '') {
105                    var end_character = current_dislike_count.slice(-1);
106                    if(end_character=="K" || end_character=="M" || end_character=="B" || end_character=="T")
107                    {
108                        var new_like_count = parseInt(current_like_count);
109                        var new_dislike_count = parseInt(current_dislike_count);
110                    }else{
111                        var new_like_count = parseInt(current_like_count) - 1;
112                        if (new_like_count < 0){
113                            new_like_count = 0;
114                        }
115                        var new_dislike_count = parseInt(current_dislike_count) + 1;
116                    }
117                }
118                $('#wpcd-like-count-' + comment_id).html(new_like_count);
119                $('#wpcd-dislike-count-' + comment_id).html(new_dislike_count);
120                var not_trigger_type = 'like';
121                wpcd_like_dislike_cookie(trigger_type, comment_id, $this, not_trigger_type);
122            }
123        }
124    });
125
126    function wpcd_like_dislike_cookie(trigger_type, comment_id, $this, not_trigger_type) {
127        var wpcd_like_cookie = wpcd_getCookie('wpcd_like_' + comment_id);
128        var wpcd_dislike_cookie = wpcd_getCookie('wpcd_dislike_' + comment_id);
129
130        if ($this.hasClass('wpcd-like-trigger')) {
131            $('.wpcd-dislike-trigger', $this.closest(".wpcd-like-dislike-wrapper")).removeClass("wpcd-already-disliked");
132            $this.addClass("wpcd-already-liked");
133        }
134
135        if ($this.hasClass('wpcd-dislike-trigger')) {
136            $('.wpcd-like-trigger', $this.closest(".wpcd-like-dislike-wrapper")).removeClass("wpcd-already-liked");
137            $this.addClass("wpcd-already-disliked");
138        }
139        
140        $.ajax({
141            type: 'post',
142            url: wpcd_frontend_js_obj.ajax_url,
143            data: {
144                comment_id: comment_id,
145                wpcd_like_cookie: wpcd_like_cookie,
146                wpcd_dislike_cookie:wpcd_dislike_cookie,
147                action: 'wpcd_comment_ajax_action',
148                type: trigger_type,
149                _wpnonce: wpcd_frontend_js_obj.ajax_nonce
150            },
151            beforeSend: function (xhr) {
152            },
153            success: function (res) {
154                console.log(res);
155                res = $.parseJSON(res);
156                var cookie_name = 'wpcd_' + trigger_type + '_' + comment_id;
157                var del_cookie = 'wpcd_' + not_trigger_type + '_' + comment_id;
158                wpcd_deleteCookie(del_cookie);
159                wpcd_setCookie(cookie_name, 1, 365);
160                var latest_like_count = res.latest_like_count;
161                var latest_dislike_count = res.latest_dislike_count;
162                $('#wpcd-like-count-' + comment_id).html(latest_like_count);
163                $('#wpcd-dislike-count-' + comment_id).html(latest_dislike_count);
164            }
165        });
166    }
167
168    $('.wp-comment-designer-lite-wrap').on('click', '.wpcd-page-link', function (e) {
169        $(this).closest('.wpcd-comment-pagination-wrapper').find('.wpcd-page-link').removeClass('wpcd-current-page');
170        $(this).addClass('wpcd-current-page');
171        var post_id = $('#wpcd-current-post-id').val();
172        var page_number = $(this).data('page-number');
173        var total_page = $(this).data('total-page');
174        var pagination_type = $(this).data('pagination-type');
175        var template = $(this).closest('.wp-comment-designer-lite-wrap').attr('data-template-demo');
176        $.ajax({
177            type: 'post',
178            url: wpcd_frontend_js_obj.ajax_url,
179            data: {
180                page_number: page_number,
181                template:template,
182                post_id: post_id,
183                action: 'wpcd_comment_pagination_ajax_action',
184                _wpnonce: wpcd_frontend_js_obj.ajax_nonce
185            },
186            cache:false,
187            beforeSend: function (xhr) {
188                $('.wpcd-page-number-loader').show();
189            },
190            success: function (res) {
191                $('.wpcd-page-number-loader').hide();
192                var pagination_html = pagination_html_function(page_number, total_page, pagination_type);
193                $('.wpcd-comment-list-inner').replaceWith(res);
194                $('.wpcd-comment-pagination-wrapper').replaceWith(pagination_html);
195                $('html, body').animate({
196                    scrollTop: $(".wpcd-comment-listing-wrap").offset().top
197                }, 1000);
198            }
199        });
200    });
201
202    $('body').on('click', '.wpcd-next-page,.wpcd-previous-page', function () {
203        var post_id = $('#wpcd-current-post-id').val();
204        var total_page = $(this).data('total-page');
205        var pagination_type = $(this).data('pagination-type');
206        var current_page = $(this).closest('.wpcd-comment-pagination-wrapper').find('.wpcd-current-page').data('page-number');
207        var next_page = parseInt(current_page) + 1;
208        var previous_page = parseInt(current_page) - 1;
209        var template = $(this).closest('.wp-comment-designer-lite-wrap').attr('data-template-demo');
210
211        if ($(this).hasClass('wpcd-previous-page')) {
212            current_page = previous_page;
213        } else {
214            current_page = next_page;
215        }
216
217        $.ajax({
218            type: 'post',
219            url: wpcd_frontend_js_obj.ajax_url,
220            data: {
221                page_number: current_page,
222                template:template,
223                post_id: post_id,
224                action: 'wpcd_comment_pagination_ajax_action',
225                 _wpnonce: wpcd_frontend_js_obj.ajax_nonce
226            },
227            beforeSend: function (xhr) {
228                $('.wpcd-page-number-loader').show();
229            },
230            success: function (res) {
231                $('.wpcd-page-number-loader').hide();
232                var pagination_html = pagination_html_function(current_page, total_page, pagination_type);
233                $('.wpcd-comment-list-inner').replaceWith(res);
234                $('.wpcd-comment-pagination-wrapper').replaceWith(pagination_html);
235                $('html, body').animate({
236                    scrollTop: $(".wpcd-comment-listing-wrap").offset().top
237                }, 1000);
238            }
239        });
240    });
241
242    function pagination_html_function(page_number, total_page, pagination_type) {
243        var pagination_html = '';
244        var current_page = page_number;
245        var page_number_loader= wpcd_frontend_js_obj.page_number_loader;
246        pagination_html += '<div class="wpcd-comment-pagination-wrapper wpcd-' + pagination_type + '"> <ul>';
247
248        if (current_page > 1) {
249            pagination_html += '<li class="wpcd-previous-page-wrap">' +
250                '<a href="javascript:void(0);" class="wpcd-previous-page" data-total-page="' + total_page + '" data-pagination-type="page-number">' +
251                '<i class="fa fa-angle-left"></i>' +
252                '</a>' +
253                '</li>';
254        }
255        var lower_limit = current_page;
256        var upper_limit = total_page;
257
258        for (var page_count = lower_limit; page_count <= upper_limit; page_count++) {
259            var page_class = (current_page == page_count) ? 'wpcd-current-page wpcd-page-link' : 'wpcd-page-link';
260            pagination_html += '<li class="wpcd-fa">' +
261                '<a href="javascript:void(0);" data-total-page="' + total_page + '" data-page-number="' + page_count + '" class="' + page_class + '" data-pagination-type="page-number" >' +
262                page_count 
263                '</a>' +
264                '</li>';
265        }
266
267        if (current_page < total_page) {
268            pagination_html += '<li class="wpcd-next-page-wrap">' +
269                '<a href="javascript:void(0);" data-total-page="' + total_page + '" class="wpcd-next-page"' + '" data-pagination-type="' + pagination_type + '">' +
270                '<i class="fa fa-angle-right"></i>' +
271                '</a>' +
272                '</li>';
273        }
274
275        pagination_html += '</ul> <img src="'+ page_number_loader +'" class="wpcd-page-number-loader" style="display:none;"></div>';
276        return pagination_html;
277    }
278
279    $('body').on('click', '.wpcd-show-replies-trigger', function () {
280        var comment_id = $(this).data('comment-id');
281        $(this).closest('.wpcd-comment-template').siblings("ul").slideDown(400, function () { });
282        $('.wpcd-hide-reply-trigger-'+comment_id).show();
283        $('.wpcd-show-reply-trigger-'+comment_id).hide();
284    });
285
286    $('body').on('click', '.wpcd-hide-replies-trigger', function () {
287        var comment_id = $(this).data('comment-id');
288        $(this).closest('.wpcd-comment-template').siblings("ul").slideUp(400, function () { });
289        $('.wpcd-hide-reply-trigger-'+comment_id).hide();
290        $('.wpcd-show-reply-trigger-'+comment_id).show();
291    });
292        
293});

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.