PageSourceSearch

https://www.sciencebee.com.bd/daily-science/wp-content/plugins/wp-…/assets/js/front.js?v=1.3.10&ver=6.9.9

js sciencebee.com.bd collected 2026-09-24 09:00:28 UTC 9,388 bytes, 224 lines download raw bytes

1let all_emoji_containers = [];
2var WPRA_Front = {
3    'animate_emojis': function (container = null) {
4        let containers;
5        if (container == null) {
6            containers = jQuery('.wpra-reactions-container');
7        } else {
8            containers = container;
9        }
10
11        containers.each(function () {
12            let container = jQuery(this);
13            container.data('animations', []);
14            all_emoji_containers.push(container);
15            let emojis = container.find('.wpra-reaction');
16            // check if animation is set true
17            let animation = container.data('animation');
18            if (animation) {
19                emojis.each(function () {
20                    let emoji_id = jQuery(this).data('emoji_id');
21                    WPRA_Front.load_lottie_emoji(container, jQuery(this), emoji_id, null);
22                });
23            }
24        });
25        WPRA_Front.checkIfPlayable();
26    },
27    'load_lottie_emoji': function (container, emoji_elm, emoji_id, onComplete = null, isAnimated = true) {
28        let args = {
29            container: emoji_elm.get(0),
30            path: wpra.emojis_path + 'json/' + emoji_id + '.json?v=' + wpra.version,
31            renderer: 'svg',
32            loop: true,
33            autoplay: false,
34            name: emoji_id,
35        };
36        if (!isAnimated) {
37            args['loop'] = false;
38            args['autoplay'] = false;
39        }
40
41        let animation = bodymovin.loadAnimation(args);
42        container.data('animations').push(animation);
43        if (onComplete != null) {
44            animation.addEventListener('DOMLoaded', onComplete);
45            animation.play();
46        }
47    },
48    'checkIfPlayable': function () {
49        jQuery.each(all_emoji_containers, function (key, container) {
50            let elem_top = container.offset().top;
51            let isScrolled = jQuery(window).scrollTop() + jQuery(window).height() > elem_top;
52            let isDisplayed = container.is(':visible');
53            if (jQuery(container).data('behavior') == 'regular') {
54                if (isScrolled && isDisplayed && !container.data('isPlaying')) {
55                    container.data('isPlaying', true);
56                    jQuery.each(container.data('animations'), function (key, emoji) {
57                        emoji.play();
58                    });
59                }
60                if ((!isScrolled || !isDisplayed) && container.data('isPlaying')) {
61                    container.data('isPlaying', false);
62                    jQuery.each(container.data('animations'), function (key, emoji) {
63                        emoji.pause();
64                    });
65                }
66            }
67        });
68    },
69    'narrowContainerize': function ($plugin_container, for_button_reveal = false) {
70        $plugin_container.addClass('wpra-narrow-container');
71        let reaction_count = $plugin_container.find('.wpra-reaction').length;
72        let reactions_width = for_button_reveal ? $(window).width() - 30 : $plugin_container.width();
73        $plugin_container.find('.wpra-reaction').css('width', reactions_width / reaction_count + 'px');
74        $plugin_container.find('.wpra-reaction').css('height', reactions_width / reaction_count + 'px');
75        $plugin_container.addClass('wpra-rendered');
76    },
77    'adaptSocialButtons': function ($plugin_container) {
78        if ($plugin_container.hasClass('wpra-regular') && ($plugin_container.outerWidth() < $plugin_container.find('.wpra-share-wrap').outerWidth())) {
79            let count = $plugin_container.find('.share-btn').length;
80            $plugin_container.find('.wpra-share-wrap').addClass('wpra-share-wrap-narrow share-arrange-' + count);
81        }
82    }
83};
84
85jQuery(document).ready(function ($) {
86
87    $('.wpra-plugin-container').each(function () {
88        let $plugin_container = $(this);
89        // if it is regular reactions check if it needs narrowing
90        // if share buttons does not fit container then narrow them
91        if ($plugin_container.outerWidth() < $plugin_container.find('.wpra-share-wrap').outerWidth()) {
92            $plugin_container.find('.wpra-share-wrap').addClass('wpra-s
92hare-wrap-narrow');
93        }
94        // if classic reactions does not fit to its container then narrow it
95        if ($plugin_container.find('.wpra-reactions').outerWidth() > $plugin_container.parent().width()) {
96            $plugin_container.addClass('wpra-narrow-container');
97            let reaction_count = $plugin_container.find('.wpra-reaction').length;
98            let reactions_width = $plugin_container.width();
99            $plugin_container.find('.wpra-reaction').css('width', reactions_width / reaction_count + 'px');
100            $plugin_container.find('.wpra-reaction').css('height', reactions_width / reaction_count + 'px');
101            $plugin_container.addClass('wpra-rendered');
102        } else {
103            $plugin_container.addClass('wpra-rendered');
104        }
105    });
106
107    $(document).on('click', '.wpra-reaction', function () {
108
109        if ($(this).hasClass('active')) {
110            return;
111        }
112
113        let container = $(this).parents('.wpra-reactions-container');
114        let wrapper = container.parent();
115        let reacted_to = $(this).attr('class').split(" ")[0];
116        let post_id = container.attr('data-post_id');
117        let containers = $('[data-post_id=' + post_id + ']');
118        let emoji_id = $(this).data('emoji_id');
119
120        if (container.data('show_count')) {
121            let current_data_count = parseInt($(this).attr('data-count'));
122            let active = containers.find('.active');
123            let active_count = parseInt(active.attr('data-count'));
124
125            let revert_count = 0;
126            if (active_count > 1) {
127                revert_count = active_count - 1;
128            }
129            if (revert_count == 0) {
130                active.find('.wpra-arrow-badge').hide();
131            } else {
132                active.find('.wpra-arrow-badge').show();
133            }
134            if (active_count < 1000) {
135                active.find('.wpra-arrow-badge .count-num').html(revert_count);
136            }
137            active.attr('data-count', revert_count);
138
139            if (isNaN(current_data_count)) {
140                current_data_count = 0;
141            }
142
143            containers.find('.wpra-reaction').removeClass("active");
144            containers.find('.' + reacted_to).addClass("active");
145            containers.find('.' + reacted_to).find('.wpra-plus-one').html(current_data_count + 1);
146
147            containers.find('.wpra-reaction').find('.wpra-plus-one').removeClass("triggered");
148            containers.find('.' + reacted_to).find('.wpra-plus-one').addClass("triggered");
149
150            if (current_data_count < 1000) {
151                containers.find('.active .wpra-arrow-badge .count-num').html(current_data_count + 1);
152            }
153            containers.find('.active').attr("data-count", current_data_count + 1);
154            containers.find('.active .wpra-arrow-badge').show();
155
156            if (active_count > 0) {
157                containers.find('.active .wpra-arrow-badge').removeClass('hide-count');
158            }
159        } else {
160            containers.find('.wpra-reaction').removeClass("active");
161            containers.find('.' + reacted_to).addClass("active");
162        }
163
164        if (container.data('enable_share')) {
165            container.find('.wpra-share-wrap').css('display', 'flex');
166            if (wrapper.outerWidth() < container.outerWidth()) {
167                container.find('.wpra-share-wrap').addClass('wpra-share-wrap-narrow');
168            }
169        }
170
171        $.ajax({
172            url: wpra.ajaxurl,
173            dataType: 'text',
174            type: 'post',
175            data: {
176                action: 'wpra_react',
177                reacted_to: reacted_to,
178                emoji_id: emoji_id,
179                post_id: post_id,
180                checker: container.data('secure')
181            }
182        });
183
184        let reveal_wrap = container.parents('.wpra-button-reveal-wrap');
185
186        if (reveal_wrap.length > 0) {
187            let $reacted_emoji = reveal_wrap.find('.wpra-reacted-emoji');
188            let $reactions_wrap = reveal_wrap.find('.wpra-reactions-wrap');
189            let $reveal_toggle = reveal_wrap.find('.wpra-reveal-toggle');
190            let clicked_text = $reveal_toggle.data('text_clicked');
191
192            $reacted_emoji.html('');
193            $reactions_wrap.hide();
194            reveal_wrap.data('user_reacted', true);
195
196            // if share popup enabled then change button text and class
197            if ($reveal_toggle.data('enable_share_popup')) {
198                $reveal_toggle.text(clicked_text);
199                $reveal_toggle.addClass('share-popup-toggle');
200            }
201        }
202
203    });
204
205    function wpraIsMobile() {
206        return $(window).width() < 768;
207    }
208
209    $(document).on('click', '.share-btn', function () {
210        let platform = $(this).data('platform');
211        let platform_url = (wpraIsMobile() && typeof wpra.social_platforms[platform]['url']['mobile'] != "undefined")
212            ? wpra.social_platforms[platform]['url']['mobile']
213            : wpra.social_platforms[platform]['url']['desktop'];
214        window.open(platform_url + location.href, '_blank', 'width=626, height=436');
215    });
216
217    WPRA_Front.animate_emojis();
218
219    $(window).scroll(function () {
220        WPRA_Front.checkIfPlayable();
221    });
222
223});
224

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.