PageSourceSearch

https://cvc29.ru/wp-content/plugins/blog-designer-pro/public/js/SocialShare.js?ver=1.0

js cvc29.ru collected 2026-10-08 20:53:34 UTC 17,010 bytes, 397 lines download raw bytes

1/*
2 SocialShare - jQuery plugin
3 */
4(function ($) {
5
6    function get_class_list(elem) {
7        if (elem.classList) {
8            return elem.classList;
9        } else {
10            return $(elem).attr('class').match(/\S+/gi);
11        }
12    }
13
14    $.fn.ShareLink = function (options) {
15        var defaults = {
16            title: '',
17            text: '',
18            image: '',
19            url: window.location.href,
20            class_prefix: 's_'
21        };
22
23        var options = $.extend({}, defaults, options);
24
25        var class_prefix_length = options.class_prefix.length;
26
27        var templates = {
28            facebook: 'https://www.facebook.com/sharer.php?s=100&p[title]={title}&u={url}&t={title}&p[summary]={text}&p[url]={url}',
29            plus: 'https://plus.google.com/share?url={url}',
30            linkedin: 'https://www.linkedin.com/shareArticle?mini=true&url={url}&title={title}&summary={text}&source={url}',
31            pinterest: 'https://www.pinterest.com/pin/create/button/?media={image}&url={url}&description={text}',
32            twitter: 'https://twitter.com/intent/tweet?url={url}&text={text}',
33            gmail: 'http://mail.google.com/mail/?view=cm&fs=1&to=&su={title}&body={text}&ui=1',
34            whatsapp: 'whatsapp://send?text={url} {title}',
35            pocket: 'https://getpocket.com/edit?url={url}&title={title}',
36            tumblr: 'https://tumblr.com/share?s=&v=3&t={title}&u={url}',
37            google: 'http://www.google.com/bookmarks/mark?op=add&bkmk={url}&title={title}&annotation={text}',
38            webnews: 'http://www.webnews.de/einstellen?url={url}&title={title}',
39            wordpress: 'http://wordpress.com/wp-admin/press-this.php?u={url}&t={title}&s={text}&v=2',
40            telegram: 'https://telegram.me/share/url?url={url}'
41        }
42
43        function link(network) {
44            var url = templates[network];
45            url = url.replace(/{url}/g, encodeURIComponent(options.url));
46            url = url.replace(/{title}/g, encodeURIComponent(options.title));
47            url = url.replace(/{text}/g, encodeURIComponent(options.text));
48            url = url.replace(/{image}/g, encodeURIComponent(options.image));
49            return url;
50        }
51
52        return this.each(function (i, elem) {
53            var classlist = get_class_list(elem);
54            for (var i = 0; i < classlist.length; i++) {
55                var cls = classlist[i];
56                if (cls.substr(0, class_prefix_length) == options.class_prefix && templates[cls.substr(class_prefix_length)]) {
57                    var final_link = link(cls.substr(class_prefix_length));
58                    $(elem).attr('href', final_link).on('click',function () {
59                        if ($(this).attr('href').indexOf('http://') === -1 && $(this).attr('href').indexOf('https://') === -1) {
60                            return window.open($(this).attr('href')) && false;
61                        }
62                        var screen_width = screen.width;
63                        var screen_height = screen.height;
64                        var popup_width = options.width ? options.width : (screen_width - (screen_width * 0.2));
65                        var popup_height = options.height ? options.height : (screen_height - (screen_height * 0.2));
66                        var left = (screen_width / 2) - (popup_width / 2);
67                        var top = (screen_height / 2) - (popup_height / 2);
68                        var parameters = 'toolbar=0,status=0,width=' + popup_width + ',height=' + popup_height + ',top=' + top + ',left=' + left;
69                        return window.open($(this).attr('href'), '', parameters) && false;
70                    });
71                }
72            }
73        });
74    }
75
76    $.fn.ShareCounter = function (options) {
77        var defaults = {
78            url: window.location.href,
79            class_prefix: 'c_',
80            display_counter_from: 0,
81            increment: false
82        };
83
84        var options = $.extend({}, defaults, options);
85
86        var class_prefix_length = options.class_prefix.length
87
88        var social = {
89            'vk': vk,
90            'myworld': myworld,
91            'linkedin': linkedin,
92            'odnoklassniki': odnoklassniki,
93            'pinterest': pinterest,
94            'plus': plus,
95            'facebook': facebook
96        }
97
98        return this.each(function (i, elem) {
99            var classlist = get_class_list(elem);
100            for (var i = 0; i < classlist.length; i++) {
101                var cls = classlist[i];
102                if (cls.substr(0, class_prefix_length) == options.class_prefix && social[cls.substr(class_prefix_length)]) {
103                    social[cls.substr(class_prefix_length)](options.url, function (count) {
104                        count = parseInt(count);
105                        if (count >= options.display_counter_from) {
106                            var current_value = parseInt($(elem).text());
107                            if (options.increment && !isNaN(current_value)) {
108                                count += current_value;
109                            }
110                            $(elem).text(count);
111                        }
112                    })
113                }
114            }
115        });
116
117        function vk(url, callback) {
118            if (window.VK === undefined) {
119                VK = {
120                    CallbackList: [],
121                    Share: {
122                        count: function (idx, value) {
123                            VK.CallbackList[idx](value);
124                        }
125                    }
126                }
127            }
128
129            var current_callback_index = VK.CallbackList.length;
130            VK.CallbackList.push(callback);
131
132            $.ajax({
133                type: 'GET',
134                dataType: 'jsonp',
135                url: 'https://vk.com/share.php',
136                data: {'act': 'count', 'index': current_callback_index, 'url': url}
137            })
138                    .fail(function (data, status) {
139                        if (status != 'parsererror') {
140                            for (i in VK.CallbackList) {
141                                VK.CallbackList[i](0)
142                            }
143                        }
144                    })
145        }
146
147        function myworld(url, callback) {
148            var results = [];
149            $.ajax({
150                type: 'GET',
151                dataType: 'jsonp',
152                url: 'https://connect.mail.ru/share_count',
153                jsonp: 'func',
154                data: {'url_list': url, 'callback': '1'}
155            })
156                    .done(function (data) {
157                        callback(data[url].shares)
158                    })
159                    .fail(function (data) {
160                        callback(0)
161                    })
162        }
163
164        function linkedin(url, callback) {
165            $.ajax({
166                type: 'GET',
167                dataType: 'jsonp',
168                url: 'https://www.linkedin.com/countserv/count/share',
169                data: {'url': url, 'format': 'jsonp'}
170            })
171                .done(function (data) {
172                        callback(data.count)
173                    })
174                    .fail(function () {
175                        callback(0)
176                    })
177        }
178
179        function odnoklassniki(url, callback) {
180            if (window.ODKL === undefined) {
181                ODKL = {
182                    CallbackList: [],
183                    updateCount: function (uid, value) {
184                        ODKL.CallbackList[parseInt(uid)](value);
185                    }
186                }
187            }
188
189            var current_callback_index = ODKL.CallbackList.length;
190            ODKL.CallbackList.push(callback);
191
192            $.ajax({
193                type: 'GET',
194                dataType: 'jsonp',
195                url: 'https://ok.ru/dk',
196                data: {'st.cmd': 'extLike', 'ref': url, 'uid': current_callback_index}
197            })
198                    .fail(function (data, status) {
199                        if (status != 'parsererror') {
200                            for (i in ODKL.CallbackList) {
201                                ODKL.CallbackList[i](0)
202                            }
203                        }
204                    })
205        }
206
207        function pinterest(url, callback) {
208            $.ajax({
209                type: 'GET',
210                dataType: 'jsonp',
211                url: 'https://api.pinterest.com/v1/urls/count.json',
212                data: {'url': url}
213            })
214                    .done(function (data) {
215                        callback(data.count)
216                    })
217                    .fail(function () {
218                        callback(0)
219                    })
220        }
221
222        function plus(url, callback) {
223            $.ajax({
224                type: 'POST',
225                url: 'https://clients6.google.com/rpc',
226                processData: true,
227                contentType: 'application/json',
228                data: JSON.stringify({
229                    'method': 'pos.plusones.get',
230                    'id': location.href,
231                    'params': {
232                        'nolog': true,
233                        'id': url,
234                        'source': 'widget',
235                        'userId': '@viewer',
236                        'groupId': '@self'
237                    },
238                    'jsonrpc': '2.0',
239                    'key': 'p',
240                    'apiVersion': 'v1'
241                })
242            })
243                    .done(function (data) {
244                        callback(data.result.metadata.globalCounts.count)
245                    })
246                    .fail(function () {
247                        callback(0)
248                    })
249        }
250
251        function facebook(url, callback) {
252            var token = $('#fb_token').val();
253            $.ajax({
254                type: 'GET',
255                dataType: 'jsonp',
256                url: 'https://graph.facebook.com/v2.2/',
257                data: {'access_token': token, 'id': url,'fields': 'engagement'}
258            })
259                .done(function (data) {
260                        if (data.engagement != undefined && data.engagement.share_count != undefined) {
261                            callback(data.engagement.share_count)
262                        }
263                    })
264                    .fail(function () {
265                        callback(0)
266                    })
267        }
268    }
269 
270    $(document).on('click', '.bdp-email-share',function (event) {
271        event.preventDefault();
272        $('.bdp_email_form').show();
273        var email_share = $(this);
274        var email_share_left = email_share.offset().left;
275        var email_share_top = email_share.offset().top;
276        var email_share_div = jQuery('.bdp_email_share');
277        email_share_div.show(500);
278        email_share_div.css('left', email_share_left);
279        email_share_div.css('top', email_share_top);
280        jQuery('#txtPostId').val(email_share.attr('data-id'));
281        jQuery('#txtShortcodeId').val(email_share.attr('data-shortcode-id'));
282
283        $('.bdp_email_sucess').html('');
284        $('.bdp_email_sucess').hide();
285    });
286
287    $(document).on('click', '.bdp-close_button, .bdp-close',function () {
288        $('#txtToEmail').val('');
289        $('#txtYourName').val('');
290        $('#txtYourEmail').val('');
291        $(this).closest('.bdp_email_share').hide(500);
292    });
293
294    $(document).on('submit', '#frmEmailShare',function (event) {
295        event.preventDefault();
296        var cur_page = page_object.current_page;
297        var cur_id = page_object.current_id;
298        var bdp_email_share_form = jQuery(this).serialize() + "&cur_page=" + cur_page + "&cur_id=" + cur_id;
299        $.ajax({
300            type: 'post',
301            url: ajaxurl,
302            data: bdp_email_share_form,
303            success: function (data) {
304                $('.bdp_email_sucess').show();
305                if (data == 'sent') {
306                    $('#txtToEmail').val('');
307                    $('#txtYourName').val('');
308                    $('#txtYourEmail').val('');
309                    $('.bdp_email_form').hide();
310                    $('.bdp_email_sucess').html('This post has been shared!');
311                } else {
312                    $('.bdp_email_sucess').html('<font color="#ff0000">Error in sharing post</font>');
313                }
314            }
315        });
316    });
317
318})(jQuery);
319
320
321jQuery(document).ready(function () {
322    jQuery(document).on('click', '.bdp-social-share', function (e) {
323        e.preventDefault();
324        
325        if(jQuery(this).data('share') == 'facebook') {
326            var $href = jQuery(this).data('href');
327            var $url = jQuery(this).data('url');
328            
329            var $link = $href + '?u=' + $url;
330            window.open($link,'targetWindow', 'width=800, height=400', 'toolbar=no', 'location=0', 'status=no', 'menubar=no', 'scrollbars=yes', 'resizable=yes');
331        }
332        
333        if(jQuery(this).data('share') == 'google' || jQuery(this).data('share') == 'linkedin') {
334            var $href = jQuery(this).data('href');
335            var $url = jQuery(this).data('url');
336            
337            var $link = $href + '?url=' + $url;
338            window.open($link,'targetWindow', 'width=800, height=400', 'toolbar=no', 'location=0', 'status=no', 'menubar=no', 'scrollbars=yes', 'resizable=yes');
339        }
340        
341        if(jQuery(this).data('share') == 'twitter' || jQuery(this).data('share') == 'skype' || jQuery(this).data('share') == 'telegram') {
342            var $href = jQuery(this).data('href');
343            var $text = jQuery(this).data('text');
344            var $url = jQuery(this).data('url');
345            
346            var $link = $href + '?text=' + $text + '&url=' + $url;
347            window.open($link,'targetWindow', 'width=800, height=400', 'toolbar=no', 'location=0', 'status=no', 'menubar=no', 'scrollbars=yes', 'resizable=yes');
348        }
349        
350        if(jQuery(this).data('share') == 'pinterest') {
351            var $href = jQuery(this).data('href');
352            var $url = jQuery(this).data('url');
353            var $media = jQuery(this).data('media');
354            var $description = jQuery(this).data('description');
355            
356            var $link = $href + '?url=' + $url + '&media=' + $media + '&description=' + $description;
357            window.open($link,'targetWindow', 'width=800, height=400', 'toolbar=no', 'location=0', 'status=no', 'menubar=no', 'scrollbars=yes', 'resizable=yes');
358        }
359        
360        if(jQuery(this).data('share') == 'pocket' || jQuery(this).data('share') == 'reddit' || jQuery(this).data('share') == 'digg' || jQuery(this).data('share') == 'tumblr') {
361            var $href = jQuery(this).data('href');
362            var $title = jQuery(this).data('title');
363            var $url = jQuery(this).data('url');
364            
365            var $link = $href + '?url=' + $url + '&title=' + $title;
366            window.open($link,'targetWindow', 'width=800, height=400', 'toolbar=no', 'location=0', 'status=no', 'menubar=no', 'scrollbars=yes', 'resizable=yes');
367        }
368        
369        if(jQuery(this).data('share') == 'tumblr') {
370            var $href = jQuery(this).data('href');
371            var $title = jQuery(this).data('title');
372            var $url = jQuery(this).data('url');
373            
374            var $link = $href + '?canonicalUrl=' + $url + '&title=' + $title;
375            window.open($link,'targetWindow', 'width=800, height=400', 'toolbar=no', 'location=0', 'status=no', 'menubar=no', 'scrollbars=yes', 'resizable=yes');
376        }
377        
378        if(jQuery(this).data('share') == 'wordpress') {
379            var $href = jQuery(this).data('href');
380            var $title = jQuery(this).data('title');
381            var $url = jQuery(this).data('url');
382            var $image = jQuery(this).data('image');
383            
384            var $link = $href + '?u=' + $url + '&t=' + $title + '&i=' + $image;
385            window.open($link,'targetWindow', 'width=800, height=400', 'toolbar=no', 'location=0', 'status=no', 'menubar=no', 'scrollbars=yes', 'resizable=yes');            
386        }
387        
388        if(jQuery(this).data('share') == 'whatsapp') {
389            var $href = jQuery(this).data('href');
390            var $text = jQuery(this).data('text');
391            var $url = jQuery(this).data('url');
392            
393            var $link = $href + '?text=' + $text + '&url=' + $url;
394            window.open($link,'targetWindow', 'width=800, height=400', 'toolbar=no', 'location=0', 'status=no', 'menubar=no', 'scrollbars=yes', 'resizable=yes');            
395        }
396    });
vendor: 3 bytes, line 397
397});

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.