PageSourceSearch

https://ughe.org/wp-content/plugins/woo-smart-compare/assets/js/frontend.js?ver=6.5.5

js ughe.org collected 2026-09-24 17:39:52 UTC 37,048 bytes, 1,081 lines download raw bytes

1'use strict';
2
3(function ($) {
4    var woosc_timer = 0;
5
6    // ready
7    $(function () {
8        woosc_color();
9        woosc_change_count('first');
10        woosc_check_buttons();
11        woosc_hide_empty();
12        woosc_hide_similarities();
13        woosc_highlight_differences();
14
15        if (woosc_vars.reload_count === 'yes') {
16            // reload the count
17            woosc_load_data('count');
18        }
19
20        if (woosc_vars.open_bar === 'yes') {
21            woosc_load_data('bar');
22            woosc_open_bar();
23        }
24
25        $('.woosc-settings-fields').sortable({
26            handle: '.move', update: function (event, ui) {
27                woosc_save_settings();
28            },
29        });
30
31        if (woosc_vars.button_action === 'show_message') {
32            $.notiny.addTheme('woosc', {
33                notification_class: 'notiny-theme-woosc',
34            });
35        }
36
37        woosc_quick_table();
38    });
39
40    // resize
41    $(window).on('resize', function () {
42        woosc_quick_table();
43    });
44
45    // quick view
46    $(document).on('click touch', '.woosc_table .woosq-btn, .woosc_table .woosq-link', function (e) {
47        e.preventDefault();
48        woosc_close();
49    });
50
51    $(document).on('click touch', '.woosc-sidebar .woosq-btn, .woosc-sidebar .woosq-link', function (e) {
52        e.preventDefault();
53        woosc_close_sidebar();
54    });
55
56    // settings
57    $(document).on('click touch', '.woosc-table-settings', function (e) {
58        e.preventDefault();
59        $('.woosc-settings').toggleClass('open');
60    });
61
62    $(document).on('click touch', '.woosc-bar-print', function (e) {
63        e.preventDefault();
64        $.print('#woosc-area');
65    });
66
67    $(document).on('change', '#woosc-filter', function (e) {
68        e.preventDefault();
69        woosc_filter();
70    });
71
72    $(document).on('keydown', function (e) {
73        if ((e.ctrlKey == true || e.metaKey == true) && (e.which == '80')) {
74            //ctrl+p or command+p
75            if ($('.woosc-area').hasClass('woosc-area-open-table')) {
76                e.preventDefault();
77                $.print('#woosc-area');
78            }
79        }
80    });
81
82    $(document).on('click touch', '.woosc-bar-share', function (e) {
83        e.preventDefault();
84        $('.woosc-share').toggleClass('open');
85        $('.woosc-share-content').addClass('woosc-loading');
86
87        var data = {
88            action: 'woosc_share', nonce: woosc_vars.nonce,
89        };
90
91        jQuery.post(woosc_vars.wc_ajax_url.toString().replace('%%endpoint%%', 'woosc_share'), data, function (response) {
92            $('.woosc-share-content').html(response).removeClass('woosc-loading');
93        });
94    });
95
96    // copy link
97    $(document).on('click touch', '#woosc_copy_url, #woosc_copy_btn', function (e) {
98        e.preventDefault();
99        let $link = $('#woosc_copy_url');
100        let link = $link.val();
101
102        navigator.clipboard.writeText(link).then(function () {
103            alert(woosc_vars.copied_text.replace('%s', link));
104        }, function () {
105            alert('Failure to copy!');
106        });
107
108        $link.select();
109    });
110
111    // search
112    $(document).on('click touch', '.woosc-bar-search', function (e) {
113        e.preventDefault();
114        $('.woosc-search').toggleClass('open');
115
116        if ($('.woosc-search-result').text() === '') {
117            if (woosc_timer != null) {
118                clearTimeout(woosc_timer);
119            }
120
121            woosc_timer = setTimeout(woosc_search, 300);
122            return false;
123        }
124    });
125
126    // popup
127    $(document).on('click touch', '.woosc-popup', function (e) {
128        if ($(e.target).closest('.woosc-popup-content').length === 0) {
129            $(this).toggleClass('open');
130        }
131    });
132
133    $(document).on('keyup', '#woosc_search_input', function () {
134        if ($('#woosc_search_input').val() !== '') {
135            if (woosc_timer != null) {
136                clearTimeout(woosc_timer);
137            }
138
139            woosc_timer = setTimeout(woosc_search, 300);
140            return false;
141        }
142    });
143
144    $(document).on('click touch', '.woosc-item-add', function (e) {
145        e.preventDefault();
146        var product_id = $(this).attr('data-id');
147
148        $('.woosc-search').toggleClass('open');
149        woosc_add_product(product_id);
150        woosc_load_data('table');
151        woosc_open_table();
152    });
153
154    $(document).on('click touch', '.woosc-popup-close', function (e) {
155        e.preventDefault();
156        $(this).closest('.woosc-popup').toggleClass('open');
157    });
158
159    // woovr
160    $(document).on('woovr_selected', function (e, selected) {
161        if (woosc_vars.variations === 'yes') {
162            var id = selected.attr('data-id');
163            var pid = selected.attr('data-pid');
164
165            if (id > 0) {
166                $('.woosc-btn-' + pid).removeClass('woosc-btn-added woosc-added').attr('data-id', id).attr('data-product_id', id);
167            } else {
168                $('.woosc-btn-' + pid).removeClass('woosc-btn-added woosc-added').attr('data-id', pid).attr('data-product_id', pid);
169            }
170        }
171    });
172
173    // found variation
174    $(document).on('found_variation', function (e, t) {
175        if (woosc_vars.variations === 'yes') {
176            var product_id = $(e['target']).attr('data-product_id');
177
178            $('.woosc-btn-' + product_id).each(function () {
179                let $btn = $(this);
180                let text = $btn.data('text') !== undefined && $btn.data('text') !== '' ? $btn.data('text') : woosc_vars.button_text;
181
182                $btn.removeClass('woosc-btn-added woosc-added').attr('data-id', t.variation_id).attr('data-product_id', t.variation_id);
183
184                if ($btn.hasClass('woosc-btn-has-icon')) {
185                    $btn.find('.woosc-btn-icon').removeClass(woosc_vars.button_added_icon).addClass(woosc_vars.button_normal_icon);
186                    $btn.find('.woosc-btn-text').text(text);
187                } else {
188                    $btn.text(text);
189                }
190            });
191        }
192    });
193
194    // reset data
195    $(document).on('reset_data', function (e) {
196        if (woosc_vars.variations === 'yes') {
197            var product_id = $(e['target']).attr('data-product_id');
198
199            $('.woosc-btn-' + product_id).each(function () {
200                let $btn = $(this);
201                let text = $btn.data('text') !== undefined && $btn.data('text') !== '' ? $btn.data('text') : woosc_vars.button_text;
202
203                $btn.removeClass('woosc-btn-added woosc-added').attr('data-id', product_id).attr('data-product_id', product_id);
204
205                if ($btn.hasClass('woosc-btn-has-icon')) {
206                    $btn.find('.woosc-btn-icon').removeClass(woosc_vars.button_added_icon).addClass(woosc_vars.button_normal_icon);
207                    $btn.find('.woosc-btn-text').text(text);
208                } else {
209                    $btn.text(text);
210                }
211            });
212        }
213    });
214
215    // remove all
216    $(document).on('click touch', '.woosc-bar-remove', function (e) {
217        e.preventDefault();
218        var r = confirm(woosc_vars.remove_all);
219
220        if (r == true) {
221            woosc_remove_product('all');
222            woosc_load_data('table');
223        }
224    });
225
226    // add
227    $(document).on('click touch', '.woosc-btn', function (e) {
228        e.preventDefault();
229        var $this = $(this);
230        var id = $this.attr('data-id');
231        var pid = $this.attr('data-pid');
232        var product_id = $this.attr('data-product_id');
233        var product_name = $this.attr('data-product_name');
234        var product_image = $this.attr('data-product_image');
235
236        if (typeof pid !== typeof undefined && pid !== false) {
237            id = pid;
238        }
239
240        if (typeof product_id !== typeof undefined && product_id !== false) {
241            id = product_id;
242        }
243
244        if ($this.hasClass('woosc-btn-added woosc-added')) {
245            if (woosc_vars.click_again === 'yes') {
246                // remove
247                woosc_remove_product(id);
248
249                if (woosc_vars.button_action === 'show_message') {
250                    $.notiny({
251                        theme: 'woosc',
252                        position: woosc_vars.message_position,
253                        image: product_image,
254                        text: woosc_vars.message_removed.replace('{name}', '<strong>' + product_name + '</strong>'),
255                    });
256                }
257            } else {
258                if (woosc_vars.button_action === 'show_message') {
259                    $.notiny({
260                        theme: 'woosc',
261                        position: woosc_vars.message_position,
262                        image: product_image,
263                        text: woosc_vars.message_exists.replace('{name}', '<strong>' + product_name + '</strong>'),
264                    });
265                }
266            }
267        } else {
268            $this.addClass('woosc-btn-adding woosc-adding');
269            woosc_add_product(id);
270
271            if (woosc_vars.button_action === 'show_message') {
272                $.notiny({
273                    theme: 'woosc',
274                    position: woosc_vars.message_position,
275                    image: product_image,
276                    text: woosc_vars.message_added.replace('{name}', '<strong>' + product_name + '</strong>'),
277                });
278            }
279        }
280
281        if (woosc_vars.button_action === 'show_bar') {
282            // show bar only
283            woosc_load_data('bar');
284            woosc_open_bar();
285        }
286
287        if (woosc_vars.button_action === 'show_table') {
288            // show bar & table
289            woosc_load_data('table');
290            woosc_open_bar();
291            woosc_open_table();
292        }
293
294        if ((woosc_vars.button_action === 'show_message') || (woosc_vars.button_action === 'none')) {
295            // load bar again
296            if ($('.woosc-bar').hasClass('woosc-bar-open')) {
297                woosc_load_data('bar');
298            }
299        }
300
301        if (woosc_vars.button_action === 'show_sidebar') {
302            woosc_load_data('sidebar');
303            woosc_open_sidebar();
304        }
305    });
306
307    // remove on popup
308    $(document).on('click touch', '#woosc-area .woosc-bar-item-remove, #woosc-area .woosc-remove', function (e) {
309        e.preventDefault();
310        var product_id = $(this).attr('data-id');
311
312        $(this).parent().addClass('removing');
313        woosc_remove_product(product_id);
314        woosc_load_data('table');
315        woosc_check_buttons();
316    });
317
318    // remove on page
319    $(document).on('click touch', '.woosc-page .woosc-remove', function (e) {
320        e.preventDefault();
321        var product_id = $(this).attr('data-id');
322
323        woosc_remove_product(product_id);
324        location.reload();
325    });
326
327    // remove all on page
328    $(document).on('click touch', '.woosc-page .woosc-remove-all', function (e) {
329        e.preventDefault();
330        var r = confirm(woosc_vars.remove_all);
331
332        if (r == true) {
333            woosc_remove_product('all');
334        }
335
336        location.reload();
337    });
338
339    // remove on sidebar
340    $(document).on('click touch', '.woosc-sidebar-item-remove', function (e) {
341        e.preventDefault();
342        var product_id = $(this).closest('.woosc-sidebar-item').attr('data-id');
343
344        woosc_remove_product(product_id);
345        $(this).closest('.woosc-sidebar-item').slideUp();
346        woosc_check_buttons();
347    });
348
349    // bar button
350    $(document).on('click touch', '.woosc-bar-btn', function (e) {
351        e.preventDefault();
352
353        if (!$('.woosc-table-items').hasClass('woosc-table-items-loaded')) {
354            woosc_load_data('table');
355        }
356
357        woosc_toggle_table();
358    });
359
360    // close
361    $(document).on('click touch', function (e) {
362        if (((woosc_vars.click_outside === 'yes') || ((woosc_vars.click_outside === 'yes_empty') && (parseInt($('.woosc-bar').attr('data-count')) === 0))) && ($(e.target).closest('.wpc_compare_count').length === 0) && ($(e.target).closest('.woosc-popup').length === 0) && ($(e.target).closest('.woosc-btn').length === 0) && ($(e.target).closest('.woosc-table').length === 0) && ($(e.target).closest('.woosc-bar').length === 0) && ($(e.target).closest('.woosc-menu-item a').length === 0) && ($(e.target).closest('.woosc-link a').length === 0) && ($(e.target).closest('.woosc-menu a').length === 0) && ($(e.target).closest('.woosc-sidebar-btn').length === 0) && ((woosc_vars.open_button === '') || ($(e.target).closest(woosc_vars.open_button).length === 0))) {
363            woosc_close();
364        }
365    });
366
367    // close sidebar
368    $(document).on('click touch', '.woosc-area-open-sidebar', function (e) {
369        if (($(e.target).closest('.woosc-sidebar').length === 0)) {
370            woosc_close_sidebar();
371        }
372    });
373
374    $(document).on('click touch', '.woosc-sidebar-close, .woosc-sidebar-continue', function (e) {
375        woosc_close_sidebar();
376    });
377
378    // let compare
379    $(document).on('click touch', '.woosc-sidebar-btn', function (e) {
380        e.preventDefault();
381        woosc_close_sidebar();
382        woosc_toggle();
383    });
384
385    // close
386    $(document).on('click touch', '#woosc-table-close', function (e) {
387        e.preventDefault();
388        woosc_close_table();
389    });
390
391    // change settings
392    $(document).on('change', '.woosc-settings-field, .woosc-settings-tool', function () {
393        woosc_save_settings();
394    });
395
396    // open button
397    if (woosc_vars.open_button !== '') {
398        $(document).on('click touch', woosc_vars.open_button, function (e) {
399            e.preventDefault();
400
401            if (woosc_vars.open_button_action === 'open_page') {
402                // open page
403                if ((woosc_vars.page_url !== '') && (woosc_vars.page_url !== '#')) {
404                    window.location.href = woosc_vars.page_url;
405                }
406            } else {
407                if (woosc_vars.open_button_action === 'open_popup') {
408                    // open compare popup
409                    if (!$('.woosc-table-items').hasClass('woosc-table-items-loaded')) {
410                        woosc_load_data('table');
411                    }
412
413                    woosc_open_bar();
414                    woosc_open_table();
415                }
416
417                if (woosc_vars.open_button_action === 'open_sidebar') {
418                    // open sidebar
419                    if (!$('.woosc-sidebar-items').hasClass('woosc-sidebar-items-loaded')) {
420                        woosc_load_data('sidebar');
421                    }
422
423                    woosc_open_sidebar();
424                }
425            }
426        });
427    }
428
429    // menu item
430    $(document).on('click touch', '.woosc-menu-item a, .woosc-menu a, .woosc-link a', function (e) {
431        if (woosc_vars.menu_action === 'open_popup') {
432            e.preventDefault();
433
434            // open compare popup
435            if (!$('.woosc-table-items').hasClass('woosc-table-items-loaded')) {
436                woosc_load_data('table');
437            }
438
439            woosc_open_bar();
440            woosc_open_table();
441        }
442
443        if (woosc_vars.menu_action === 'open_sidebar') {
444            e.preventDefault();
445
446            // open sidebar
447            if (!$('.woosc-sidebar-items').hasClass('woosc-sidebar-items-loaded')) {
448                woosc_load_data('sidebar');
449            }
450
451            woosc_open_sidebar();
452        }
453    });
454
455    function woosc_search() {
456        $('.woosc-search-result').html('').addClass('woosc-loading');
457        // ajax search product
458        woosc_timer = null;
459
460        var data = {
461            action: 'woosc_search', keyword: $('#woosc_search_input').val(), nonce: woosc_vars.nonce,
462        };
463
464        $.post(woosc_vars.wc_ajax_url.toString().replace('%%endpoint%%', 'woosc_search'), data, function (response) {
465            $('.woosc-search-result').html(response).removeClass('woosc-loading');
466        });
467    }
468
469    function woosc_set_cookie(cname, cvalue, exdays) {
470        var d = new Date();
471
472        d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
473
474        var expires = 'expires=' + d.toUTCString();
475
476        document.cookie = cname + '=' + cvalue + '; ' + expires + '; path=/';
477    }
478
479    function woosc_get_cookie(cname) {
480        var name = cname + '=';
481        var ca = document.cookie.split(';');
482
483        for (var i = 0; i < ca.length; i++) {
484            var c = ca[i];
485
486            while (c.charAt(0) == ' ') {
487                c = c.substring(1);
488            }
489
490            if (c.indexOf(name) == 0) {
491                return decodeURIComponent(c.substring(name.length, c.length));
492            }
493        }
494
495        return '';
496    }
497
498    function woosc_get_products() {
499        var cookie_products = woosc_get_cookie_products();
500
501        if (woosc_get_cookie(cookie_products) != '') {
502            return woosc_get_cookie(cookie_products);
503        } else {
504            return '';
505        }
506    }
507
508    function woosc_save_products() {
509        var cookie_products = woosc_get_cookie_products();
510        var products = [];
511
512        $('.woosc-bar-item').each(function () {
513            var pid = $(this).attr('data-id');
514
515            if (pid !== '') {
516                products.push(pid);
517            }
518        });
519
520        var products_str = products.join();
521
522        woosc_set_cookie(cookie_products, products_str, 7);
523        woosc_load_data('table');
524    }
525
526    function woosc_save_settings() {
527        var fields = [];
528        var settings = [];
529        var cookie_fields = 'woosc_fields_' + woosc_vars.hash;
530        var cookie_settings = 'woosc_settings_' + woosc_vars.hash;
531
532        if (woosc_vars.user_id !== '') {
533            cookie_fields += '_' + woosc_vars.user_id;
534            cookie_settings += '_' + woosc_vars.user_id;
535        }
536
537        // fields
538        $('.woosc-settings-field').each(function () {
539            var _val = $(this).val();
540
541            if ($(this).prop('checked')) {
542                fields.push(_val);
543                $('.woosc_table .tr-' + _val).removeClass('tr-hide');
544            } else {
545                $('.woosc_table .tr-' + _val).addClass('tr-hide');
546            }
547        });
548
549        // tools
550        $('.woosc-settings-tool').each(function () {
551            var _val = $(this).val();
552
553            if ($(this).prop('checked')) {
554                settings.push(_val);
555            }
556        });
557
558        woosc_set_cookie(cookie_fields, fields.join(','), 7);
559        woosc_set_cookie(cookie_settings, settings.join(','), 7);
560        woosc_load_data('table');
561    }
562
563    function woosc_add_product(product_id) {
564        var count;
565        var limit = false;
566        var limit_notice = woosc_vars.limit_notice;
567        var cookie_products = woosc_get_cookie_products();
568
569        if (woosc_get_cookie(cookie_products) !== '') {
570            var products = woosc_get_cookie(cookie_products).split(',');
571
572            if (products.length < woosc_vars.limit) {
573                products = $.grep(products, function (value) {
574                    return value != product_id;
575                });
576
577                if (woosc_vars.adding === 'append') {
578                    products.push(product_id);
579                } else {
580                    products.unshift(product_id);
581                }
582
583                var products_str = products.join();
584
585                woosc_set_cookie(cookie_products, products_str, 7);
586            } else {
587                limit = true;
588                limit_notice = limit_notice.replace('{limit}', woosc_vars.limit);
589            }
590
591            count = products.length;
592        } else {
593            woosc_set_cookie(cookie_products, product_id, 7);
594            count = 1;
595        }
596
597        woosc_change_count(count);
598        $(document.body).trigger('woosc_added', [count]);
599
600        if (limit) {
601            $('.woosc-btn[data-id="' + product_id + '"]').removeClass('woosc-btn-adding woosc-adding');
602            alert(limit_notice);
603        } else {
604            $('.woosc-btn[data-id="' + product_id + '"]').each(function () {
605                let $btn = $(this);
606                let text_added = $btn.data('text_added') !== undefined && $btn.data('text_added') !== '' ? $btn.data('text_added') : woosc_vars.button_text_added;
607
608                $btn.removeClass('woosc-btn-adding woosc-adding').addClass('woosc-btn-added woosc-added');
609
610                if ($btn.hasClass('woosc-btn-has-icon')) {
611                    $btn.find('.woosc-btn-icon').removeClass(woosc_vars.button_normal_icon).addClass(woosc_vars.button_added_icon);
612                    $btn.find('.woosc-btn-text').text(text_added);
613                } else {
614                    $btn.text(text_added);
615                }
616            });
617        }
618    }
619
620    function woosc_remove_product(product_id) {
621        var count = 0;
622        var cookie_products = woosc_get_cookie_products();
623
624        if (product_id !== 'all') {
625            // remove one
626            if (woosc_get_cookie(cookie_products) !== '') {
627                var products = woosc_get_cookie(cookie_products).split(',');
628
629                products = $.grep(products, function (value) {
630                    return value !== product_id;
631                });
632
633                var products_str = products.join();
634
635                woosc_set_cookie(cookie_products, products_str, 7);
636                count = products.length;
637            }
638
639            $('.woosc-btn[data-id="' + product_id + '"]').each(function () {
640                let $btn = $(this);
641                let text = $btn.data('text') !== undefined && $btn.data('text') !== '' ? $btn.data('text') : woosc_vars.button_text;
642
643                $btn.removeClass('woosc-btn-added woosc-added');
644
645                if ($btn.hasClass('woosc-btn-has-icon')) {
646                    $btn.find('.woosc-btn-icon').removeClass(woosc_vars.button_added_icon).addClass(woosc_vars.button_normal_icon);
647                    $btn.find('.woosc-btn-text').text(text);
648                } else {
649                    $btn.text(text);
650                }
651            });
652        } else {
653            // remove all
654            if (woosc_get_cookie(cookie_products) !== '') {
655                woosc_set_cookie(cookie_products, '', 7);
656                count = 0;
657            }
658
659            $('.woosc-btn').each(function () {
660                let $btn = $(this);
661                let text = $btn.data('text') !== undefined && $btn.data('text') !== '' ? $btn.data('text') : woosc_vars.button_text;
662
663                $btn.removeClass('woosc-btn-added woosc-added');
664
665                if ($btn.hasClass('woosc-btn-has-icon')) {
666                    $btn.find('.woosc-btn-icon').removeClass(woosc_vars.button_added_icon).addClass(woosc_vars.button_normal_icon);
667                    $btn.find('.woosc-btn-text').text(text);
668                } else {
669                    $btn.text(text);
670                }
671            });
672        }
673
674        woosc_change_count(count);
675        $(document.body).trigger('woosc_removed', [count]);
676    }
677
678    function woosc_check_buttons() {
679        var cookie_products = woosc_get_cookie_products();
680
681        if (woosc_get_cookie(cookie_products) !== '') {
682            var products = woosc_get_cookie(cookie_products).split(',');
683
684            $('.woosc-btn').each(function () {
685                let $btn = $(this);
686                let text = $btn.data('text') !== undefined && $btn.data('text') !== '' ? $btn.data('text') : woosc_vars.button_text;
687
688                $btn.removeClass('woosc-btn-added woosc-added');
689
690                if ($btn.hasClass('woosc-btn-has-icon')) {
691                    $btn.find('.woosc-btn-icon').removeClass(woosc_vars.button_added_icon).addClass(woosc_vars.button_normal_icon);
692                    $btn.find('.woosc-btn-text').text(text);
693                } else {
694                    $btn.text(text);
695                }
696            });
697
698            products.forEach(function (product_id) {
699                $('.woosc-btn[data-id="' + product_id + '"]').each(function () {
700                    let $btn = $(this);
701                    let text_added = $btn.data('text_added') !== undefined && $btn.data('text_added') !== '' ? $btn.data('text_added') : woosc_vars.button_text_added;
702
703                    $btn.addClass('woosc-btn-added woosc-added');
704
705                    if ($btn.hasClass('woosc-btn-has-icon')) {
706                        $btn.find('.woosc-btn-icon').removeClass(woosc_vars.button_normal_icon).addClass(woosc_vars.button_added_icon);
707                        $btn.find('.woosc-btn-text').text(text_added);
708                    } else {
709                        $btn.text(text_added);
710                    }
711                });
712            });
713        }
714    }
715
716    function woosc_load_data(get_data) {
717        var data = {
718            action: 'woosc_load', get_data: get_data, nonce: woosc_vars.nonce,
719        };
720
721        if (get_data === 'table') {
722            $('.woosc-table-inner').addClass('woosc-loading');
723        }
724
725        if (get_data === 'sidebar') {
726            $('.woosc-sidebar').addClass('woosc-loading');
727        }
728
729        $.post(woosc_vars.wc_ajax_url.toString().replace('%%endpoint%%', 'woosc_load'), data, function (response) {
730            if (get_data === 'bar' || get_data === 'table') {
731                // load bar items
732                $('.woosc-bar-items').html(response.bar).addClass('woosc-bar-items-loaded');
733
734                $(document.body).trigger('woosc_bar_loaded');
735            }
736
737            if (get_data === 'table') {
738                // load table
739                $('.woosc-table-items').html(response.table).addClass('woosc-table-items-loaded');
740
741                if ($(window).width() >= 768) {
742                    if ((woosc_vars.freeze_column === 'yes') && (woosc_vars.freeze_row === 'yes')) {
743                        // freeze row and column
744                        $('#woosc_table').tableHeadFixer({'head': true, left: 1});
745                    } else if (woosc_vars.freeze_column === 'yes') {
746                        // freeze column
747                        $('#woosc_table').tableHeadFixer({'head': false, left: 1});
748                    } else if (woosc_vars.freeze_row === 'yes') {
749                        // freeze row
750                        $('#woosc_table').tableHeadFixer({'head': true});
751                    }
752                } else {
753                    if (woosc_vars.freeze_row === 'yes') {
754                        // freeze row
755                        $('#woosc_table').tableHeadFixer({'head': true});
756                    }
757                }
758
759                if (woosc_vars.scrollbar === 'yes') {
760                    $('.woosc-table-items').perfectScrollbar({theme: 'wpc'});
761                }
762
763                $('.woosc-table-inner').removeClass('woosc-loading');
764                woosc_hide_empty();
765                woosc_hide_similarities();
766                woosc_highlight_differences();
767
768                $(document.body).trigger('woosc_table_loaded');
769            }
770
771            if (get_data === 'sidebar') {
772                // load sidebar
773                $('.woosc-sidebar-items').html(response.sidebar).addClass('woosc-sidebar-items-loaded');
774                $('.woosc-sidebar').removeClass('woosc-loading');
775
776                if (woosc_vars.scrollbar === 'yes') {
777                    $('.woosc-sidebar-items').perfectScrollbar({theme: 'wpc'});
778                }
779
780                $(document.body).trigger('woosc_sidebar_loaded');
781            }
782
783            if (get_data === 'bar' || get_data === 'table' || get_data === 'sidebar') {
784                // load bar filter
785                $('.woosc-bar-filter').html(response.filter);
786                woosc_filter();
787
788                $(document.body).trigger('woosc_filter_loaded');
789            }
790
791            if (get_data === 'count') {
792                // load count
793                if (response.count != null) {
794                    var count = parseInt(response.count);
795
796                    woosc_change_count(count);
797                    $(document.body).trigger('woosc_count_loaded', [count]);
798                }
799            }
800        });
801    }
802
803    function woosc_quick_table() {
804        let ww = $(window).width();
805        let fixed = JSON.parse(woosc_vars.quick_table_fixed);
806
807        if (ww >= 1024) {
808            $('.woosc-quick-table .woosc_table').tableHeadFixer({'head': false, left: fixed.pc});
809        }
810
811        if (ww >= 768 && ww < 1024) {
812            $('.woosc-quick-table .woosc_table').tableHeadFixer({'head': false, left: fixed.ta});
813        }
814
815        if (ww < 768) {
816            $('.woosc-quick-table .woosc_table').tableHeadFixer({'head': false, left: fixed.mo});
817        }
818    }
819
820    function woosc_open_bar() {
821        woosc_close_sidebar();
822
823        $('#woosc-area').addClass('woosc-area-open-bar');
824        $('.woosc-bar').addClass('woosc-bar-open');
825
826        $('.woosc-bar-items').sortable({
827            handle: 'img', update: function (event, ui) {
828                woosc_save_products();
829            },
830        });
831
832        $(document.body).trigger('woosc_bar_open');
833    }
834
835    function woosc_close_bar() {
836        $('#woosc-area').removeClass('woosc-area-open-bar');
837        $('.woosc-bar').removeClass('woosc-bar-open');
838
839        $(document.body).trigger('woosc_bar_close');
840    }
841
842    function woosc_open_sidebar() {
843        woosc_close_bar();
844        woosc_close_table();
845
846        $('#woosc-area').addClass('woosc-area-open-sidebar');
847        $('.woosc-sidebar').addClass('woosc-sidebar-open');
848
849        $(document.body).trigger('woosc_sidebar_open');
850    }
851
852    function woosc_close_sidebar() {
853        $('#woosc-area').removeClass('woosc-area-open-sidebar');
854        $('.woosc-sidebar').removeClass('woosc-sidebar-open');
855
856        $(document.body).trigger('woosc_sidebar_close');
857    }
858
859    function woosc_open_table() {
860        woosc_close_sidebar();
861
862        $('#woosc-area').addClass('woosc-area-open-table');
863        $('.woosc-table').addClass('woosc-table-open');
864        $('.woosc-bar-btn').addClass('woosc-bar-btn-open');
865
866        if (woosc_vars.bar_bubble === 'yes') {
867            $('.woosc-bar').removeClass('woosc-bar-bubble');
868        }
869
870        $(document.body).trigger('woosc_table_open');
871    }
872
873    function woosc_close_table() {
874        $('#woosc-area').removeClass('woosc-area-open woosc-area-open-table');
875        $('.woosc-table').removeClass('woosc-table-open');
876        $('.woosc-bar-btn').removeClass('woosc-bar-btn-open');
877
878        if (woosc_vars.bar_bubble === 'yes') {
879            $('.woosc-bar').addClass('woosc-bar-bubble');
880        }
881
882        if (woosc_vars.hide_closed === 'yes') {
883            woosc_close_bar();
884        }
885
886        $(document.body).trigger('woosc_table_close');
887    }
888
889    function woosc_toggle_table() {
890        if ($('.woosc-table').hasClass('woosc-table-open')) {
891            woosc_close_table();
892        } else {
893            woosc_open_table();
894        }
895    }
896
897    function woosc_open() {
898        $('#woosc-area').addClass('woosc-area-open');
899        woosc_load_data('table');
900        woosc_open_bar();
901        woosc_open_table();
902
903        $(document.body).trigger('woosc_open');
904    }
905
906    function woosc_close() {
907        $('#woosc-area').removeClass('woosc-area-open');
908        woosc_close_bar();
909        woosc_close_table();
910
911        $(document.body).trigger('woosc_close');
912    }
913
914    function woosc_toggle() {
915        if ($('#woosc-area').hasClass('woosc-area-open')) {
916            woosc_close();
917        } else {
918            woosc_open();
919        }
920
921        $(document.body).trigger('woosc_toggle');
922    }
923
924    function woosc_color() {
925        var bg_color = $('#woosc-area').attr('data-bg-color');
926        var btn_color = $('#woosc-area').attr('data-btn-color');
927
928        $('.woosc-table').css('background-color', bg_color);
929        $('.woosc-bar').css('background-color', bg_color);
930        $('.woosc-bar-btn').css('background-color', btn_color);
931        $('.woosc-sidebar-btn').css('background-color', btn_color);
932    }
933
934    function woosc_filter() {
935        if (woosc_vars.bar_filter !== 'no' && $('#woosc-filter').length) {
936            var filter = $('#woosc-filter').val().toLowerCase();
937
938            if (filter !== '_all_') {
939                $('.woosc_table .col').addClass('col-hide').hide();
940                $('.woosc_table .col-' + filter).removeClass('col-hide').show();
941
942                $('.woosc-bar-item').addClass('woosc-bar-item-hidden');
943                $('.woosc-bar-item-' + filter).removeClass('woosc-bar-item-hidden');
944            } else {
945                $('.woosc_table .col').removeClass('col-hide').show();
946                $('.woosc-bar-item').removeClass('woosc-bar-item-hidden');
947            }
948
949            if (woosc_vars.hide_empty_row === 'yes') {
950                $('.woosc_table > tbody > tr:not(.tr-print)').each(function () {
951                    var $tr = $(this);
952                    var _td = 0;
953                    var _empty = true;
954
955                    $tr.removeClass('tr-empty').show();
956
957                    $tr.children('.col:not(.col-hide)').each(function () {
958                        if ($(this).html().length > 0) {
959                            _empty = false;
960                            return false;
961                        }
962                    });
963
964                    if (_empty) {
965                        $tr.addClass('tr-empty').hide();
966                    }
967                });
968            }
969        }
970    }
971
972    function woosc_change_count(count) {
973        if (count === 'first') {
974            var products = woosc_get_products();
975
976            if (products != '') {
977                var products_arr = products.split(',');
978
979                count = products_arr.length;
980            } else {
981                count = 0;
982            }
983        }
984
985        $('.woosc-menu-item').each(function () {
986            if ($(this).hasClass('menu-item-type-woosc')) {
987                $(this).find('.woosc-menu-item-inner').attr('data-count', count);
988            } else {
989                $(this).addClass('menu-item-type-woosc').find('a').wrapInner('<span class="woosc-menu-item-inner" data-count="' + count + '"></span>');
990            }
991        });
992
993        $('#woosc-area').attr('data-count', count);
994        $('.woosc-bar').attr('data-count', count);
995        $('.woosc-sidebar-count').text(' (' + count + ')');
996        $('.woosc-link .woosc-link-inner').attr('data-count', count);
997
998        $('.woosc-bar-items').removeClass('woosc-bar-items-loaded');
999        $('.woosc-sidebar-items').removeClass('woosc-sidebar-items-loaded');
1000        $('.woosc-table-items').removeClass('woosc-table-items-loaded');
1001
1002        $(document.body).trigger('woosc_change_count', [count]);
1003    }
1004
1005    function woosc_hide_empty() {
1006        if (woosc_vars.hide_empty_row === 'yes') {
1007            $('.woosc_table > tbody > tr').each(function () {
1008                var $tr = $(this);
1009                var _td = 0;
1010                var _empty = true;
1011
1012                $tr.children('td').each(function () {
1013                    if ((_td > 0) && ($(this).html().length > 0)) {
1014                        _empty = false;
1015                        return false;
1016                    }
1017
1018                    _td++;
1019                });
1020
1021                if (_empty) {
1022                    $tr.addClass('tr-empty').remove();
1023                }
1024            });
1025        }
1026    }
1027
1028    function woosc_highlight_differences() {
1029        if ($('#woosc_highlight_differences').prop('checked')) {
1030            $('.woosc_table > tbody > tr').each(function () {
1031                var $tr = $(this);
1032                var _td = 0;
1033                var _val = $(this).children('td').eq(1).html();
1034                var _differences = false;
1035
1036                $tr.children('td:not(.td-placeholder)').each(function () {
1037                    if ((_td > 1) && ($(this).html() !== _val)) {
1038                        _differences = true;
1039                        return false;
1040                    }
1041                    _td++;
1042                });
1043
1044                if (_differences) {
1045                    $tr.addClass('tr-highlight');
1046                }
1047            });
1048        } else {
1049            $('.woosc_table tr').removeClass('tr-highlight');
1050        }
1051    }
1052
1053    function woosc_hide_similarities() {
1054        if ($('#woosc_hide_similarities').prop('checked')) {
1055            $('.woosc_table > tbody > tr').each(function () {
1056                var $tr = $(this);
1057                var _td = 0;
1058                var _val = $(this).children('td').eq(1).html();
1059                var _similarities = true;
1060
1061                $tr.children('td:not(.td-placeholder)').each(function () {
1062                    if ((_td > 1) && ($(this).html() !== _val)) {
1063                        _similarities = false;
1064                        return false;
1065                    }
1066                    _td++;
1067                });
1068
1069                if (_similarities) {
1070                    $tr.addClass('tr-similar');
1071                }
1072            });
1073        } else {
1074            $('.woosc_table tr').removeClass('tr-similar');
1075        }
1076    }
1077
1078    function woosc_get_cookie_products() {
1079        return woosc_vars.user_id !== '' ? 'woosc_products_' + woosc_vars.user_id : 'woosc_products';
1080    }
1081})(jQuery);

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.