PageSourceSearch

https://modarte.pl/_js/share.js

js modarte.pl collected 2026-09-28 17:28:21 UTC 18,236 bytes, 385 lines download raw bytes

1var genesisShare = {  
2    navigatorDialog: navigator.canShare,  
3    data: {
4        title: document.title,
5        text: '',
6        url: window.location.href
7    },
8    init: function () {         
9        var obj  = this;      
10        let date = new Date(),
11            iso  = date.toISOString().match(/(\d{4}\-\d{2}\-\d{2})T(\d{2}:\d{1})/);   
12        if (!this.navigatorDialog || this.isAppleDevice())
13        {               
14            if ($('.genesis-layer').length == 0)
15                $('body').append('<div class="genesis-layer"></div>');
16            if ($('.genesis-window').length == 0)
17                $('.genesis-layer').append('<div class="genesis-window"></div>');  
18        }
19
20        $('head link[rel="stylesheet"]').first().before('<link rel="stylesheet" href="/_css/share.css?d=' + iso[1] + '_' + iso[2] + '0" type="text/css" />');  
21        this.detectShareButtons();  
22        
23        if (!genesisPage.isMobile && ($('.art-content .share-buttons-wrapper .share-buttons').length > 0))    
24            this.createArticleShareBar();   
25        
26        if (($('#element-header .right-column .header-art-details a.header-art-share').length > 0) && ($('#element-header .right-column .header-art-details a.header-art-share').hasClass('assigned')))    
27        {   
28            $('#element-header .right-column .header-art-details a.header-art-share').addClass('visible');   
29        }             
30        if (($('#element .art-bar-googlenews').length == 1) && (!$('#element .art-bar-googlenews').hasClass('assigned')))
31        { 
32            $('#element .art-bar-googlenews').addClass('assigned');    
33            $('#element .art-bar-googlenews a').on('click', function () {
34                let id    = genesisPage.getTargetData('id'),
35                    type  = genesisPage.getTargetData('type'),
36                    typeN = obj.typeName(type);   
37                obj.eventGA('GoogleNews', type, id); 
38            });
39        }             
40        if (($('#element .art-bar-google-source').length == 1) && (!$('#element .art-bar-google-source').hasClass('assigned')))
41        { 
42            $('#element .art-bar-google-source').addClass('assigned');    
43            $('#element .art-bar-google-source a').on('click', function () {
44                let id    = genesisPage.getTargetData('id'),
45                    type  = genesisPage.getTargetData('type'),
46                    typeN = obj.typeName(type);   
47                obj.eventGA('Google (source)', type, id); 
48            });
49        }               
50    },            
51    detectShareButtons: function () {       
52        var obj = this; 
53        $('*[data-share="genesis"]').not('.assigned').each(function () {
54            $(this).addClass('assigned');    
55            $(this).on('click', function (event) {  
56                obj.shareAction();
57                event.preventDefault();   
58                event.stopPropagation(); 
59                return false;   
60            });                                
61        }); 
62    },     
63    shareAction: function () {    
64        if (this.navigatorDialog && !this.isAppleDevice())
65        { 
66            var obj = this; 
67            navigator.share(this.data).then(() => {
68                obj.saveShare('System Dialog');                
69            });
70        }                    
71        else
72            this.showDialog();
73    },   
74    showDialog: function () {    
75        if ($('.genesis-layer').not('.assigned').length == 1)
76        {
77            $('.genesis-layer').addClass('assigned');   
78            $('.genesis-layer').on('click', function (event) {  
79                $('.genesis-layer').removeClass('visible');   
80                event.preventDefault();   
81                event.stopPropagation(); 
82                return false;   
83            });                         
84        }       
85        this.createShareForm();        
86        $('.genesis-window').height('auto');
87        $('.genesis-window').show().addClass('visible');       
88        $('.genesis-layer').show().addClass('visible');  
89    },   
90    createShareForm: function () {     
91        var obj   = this;    
92        let btns  = this.getShareButtons(), 
93            title = '', 
94            icon  = '',   
95            img   = '';     
96        $('.genesis-window').width('auto').height('auto');
97        $('.genesis-window').html('<div class="genesis-window-share disabled-select"></div>');    
98        if ($('meta[property="og:title"]').length == 1)   
99            title  = ($('meta[property="og:title"]').attr('content')).trim(); 
100        if ($('meta[property="og:image"]').length == 1)      
101            img    = ($('meta[property="og:image"]').attr('content')).trim(); 
102        if ($('link[rel="icon"]').length == 1)    
103            icon   = ($('link[rel="icon"]').attr('href')).trim();    
104         if (img != '') 
105            icon = img; 
106        $('.genesis-window-share').append('<b class="close-button"></b><div class="info">' + ((icon != '') ? '<img src="' + icon + '" />' : '') + '<strong><b>Udostępnij</b>' + this.wrapLetters(title) + '</strong></div>'); 
107        $('.genesis-window-share').append('<div class="buttons">' + btns + '</div>');  
108        this.shareButtonsEvents();
109        $('.genesis-window-share .close-button').on('click', function (event) {  
110            $('.genesis-layer').click();
111            event.preventDefault();   
112            event.stopPropagation(); 
113            return false;   
114        });                                                           
115        $('.genesis-window-share').on('click', function (event) {  
116            event.preventDefault();   
117            event.stopPropagation(); 
118            return false;   
119        });                                 
120    },     
121    createArticleShareBar: function () {      
122        var obj = this;                   
123        let artShareButtons = $('.art-content .share-buttons-wrapper .share-buttons');
124        if ($(artShareButtons).length == 1)  
125        {  
126            if (! $(artShareButtons).hasClass('assigned'))
127            {
128                $(artShareButtons).addClass('assigned');
129                $(artShareButtons).html(this.getShareButtons());
130                this.shareButtonsEvents();
131                $(artShareButtons).append('<span class="share-button-more"></span>');
132                $('span.share-button-more', artShareButtons).on('click', function (event) {                         
133                    $('.copy-button',       artShareButtons).slideDown(20,  function () { $(this).addClass('visible'); });
134                    $('.email-button',      artShareButtons).slideDown(30,  function () { $(this).addClass('visible'); });
135                    $('.linkedin-button',   artShareButtons).slideDown(50,  function () { $(this).addClass('visible'); });
136                    $('.tumblr-button',     artShareButtons).slideDown(100, function () { $(this).addClass('visible'); });
137                    $('.pinterest-button',  artShareButtons).slideDown(150, function () { $(this).addClass('visible'); });
138                    $('.wykop-button',      artShareButtons).slideDown(200, function () { $(this).addClass('visible'); });
139                    $(this).slideUp(function () {
140                        $(this).remove();         
141                    });      
142                    event.preventDefault();
143                    return false;                              
144                });                             
145            }  
146        }       
147    },       
148    shareButtonsEvents: function () {       
149        var obj = this;                   
150        $('.share-button').not('.assigned').each(function () {
151            $(this).addClass('assigned');   
152            $(this).on('click', function (event) {
153                if ($(this).data('to') == 'Copy')
154                {         
155                    let $temp = $('<input type="text">');  
156                    $temp.val(this.href).attr('value', this.href).select();   
157                    $(this).after($temp);    
158                    $temp.select(); 
159                    document.execCommand("copy"); 
160                    $temp.remove();
161                }               
162                else        
163                if ($(this).data('to') == 'Email')
164                    location = this.href;
165                else       
166                if ($(this).data('to') == 'SMS')
167                    location = this.href;
168                else   
169                    window.open(this.href);
170                $('.genesis-layer').click();
171                obj.saveShare($(this).data('to')); 
172                event.preventDefault();   
173                event.stopPropagation(); 
174                return false;  
175            });                                
176        });                    
177    },    
178    getShareButtons: function () {   
179        let btns   = '', 
180            page   = '', 
181            title  = '', 
182            link   = '',  
183            icon   = '',   
184            img    = '', 
185            _fb    = '',  
186            _img   = '',  
187            _via   = '',  
188            _short = '',      
189            _page  = '', 
190            _title = '', 
191            _link  = '';     
192        if ($('#header .h1 a em').length == 1)   
193            page   = ($('#header .h1 a em').text()).trim(); 
194        if ($('meta[property="og:title"]').length == 1)   
195            title  = ($('meta[property="og:title"]').attr('content')).trim(); 
196        if ($('meta[property="og:url"]').length == 1)   
197            link   = ($('meta[property="og:url"]').attr('content')).trim();  
198        if ($('meta[property="fb:app_id"]').length == 1)   
199            _fb    = ($('meta[property="fb:app_id"]').attr('content')).trim();
200        if ($('meta[property="og:image"]').length == 1)      
201            img    = ($('meta[property="og:image"]').attr('content')).trim(); 
202        if ($('meta[meta="twitter:site"]').length == 1)    
203            _via   = ($('meta[meta="twitter:site"]').attr('content')).trim();  
204        if ($('link[rel="shortlink"]').length == 1)    
205            _short = encodeURIComponent($('link[rel="shortlink"]').attr('href')).trim();    
206        if ($('link[rel="icon"]').length == 1)    
207            icon   = ($('link[rel="icon"]').attr('href')).trim();    
208        _page  = encodeURIComponent(page);    
209        _title = encodeURIComponent(title);
210        _link  = encodeURIComponent(link);  
211        _img   = encodeURIComponent(img);               
212        if ((!_short) || (_short == 'undefined'))
213            _short = _link;                 
214        if (img != '') 
215            icon = img; 
216        btns += '<a class="share-button facebook-button" data-to="Facebook" title="Udostępnij na Facebooku" href="https://www.facebook.com/share.php?u=' + _link + '&t=' + _title + '"><i>Facebook</i></a>';  
217        btns += '<a class="share-button twitter-button" data-to="X" title="Udostępnij na X" href="https://twitter.com/share?url=' + _short + '&text=' + _title + ((_via!='') ? ('&via=' + _via.replace('@', '')):'') + '"  ><i>X</i></a>';  
218        if (genesisPage.isMobile && _fb)
219            btns += '<a class="share-button messenger-button" data-to="Messenger" title="Udostępnij przez Messenger" href="fb-messenger://share?link=' + _link + '&app_id=' + encodeURIComponent(_fb) + '"><i>Messenger</i></a>'
220        if (genesisPage.isMobile)                        
221            btns += '<a class="share-button whatsapp-button" data-to="WhatsApp" title="Udostępnij przez Whatsapp" href="whatsapp://send?text=' + _link + '" ><i>Whatsapp</i></a>';  
222        if (genesisPage.isMobile) 
223            btns += '<a class="share-button sms-button" data-to="SMS" title="Wyślij przez SMS" href="sms:?body=' + encodeURIComponent('Odwiedź stronę ') + _page + '%3A%0D%0A' + _link + '"><i>SMS</i></a>'
224        btns += '<a class="share-button linkedin-button" data-to="Linkedin" title="Udostępnij na Linked In" href="https://www.linkedin.com/shareArticle?url=' + _link + '&title=' + _title + '"><i>Linked In</i></a>';  
225        btns += '<a class="share-button tumblr-button" data-to="Tumblr" title="Udostępnij na Tumblr" href="http://wwws.tumblr.com/share/link?url=' + _link + '&name=' + _title + '&description="><i>Tumblr</i></a>';  
226        if (_img)
227            btns += '<a class="share-button pinterest-button" data-to="Pinterest" title="Udostępnij na Pinterest" href="https://pinterest.com/pin/create/button/?url='+_link+'&media=' + _img + '&description=' + _title + '"><i>Pinterest</i></a>'
228        btns += '<a class="share-button wykop-button" data-to="Wykop" title="Udostępnij na Wykopie" href="https://www.wykop.pl/dodaj?url=' + _link + '" ><i>Wykop</i></a>';  
229        btns += '<a class="share-button email-button" data-to="Email" title="Wyślij przez e-mail" href="mailto:?subject=' + _title + '&amp;body=' + encodeURIComponent('Odwiedź stronę ') + _page + '%3A%0D%0A' + _link + '"><i>E-mail</i></a>'
230        btns += '<a class="share-button copy-button" data-to="Copy" title="Skopiuj adres" href="' + link + '"><i>E-mail</i></a>'
231        return btns;                        
232    },                    
233    typeName: function (type) {          
234        if (type == 1)
235        {
236            if ($('.genesis-large-audio-player').length == 1)    
237                return 'Podcast';  
238            else  
239            if ($('.genesis-large-video-player').length == 1) 
240                return 'Video';    
241            else                                        
242                return 'Article';    
243        }
244        else
245        if (type == 2)                       
246            return 'Gallery'  
247        else
248        if (type == 16)                    
249            return 'Quiz';      
250        else
251        if (type == 25)                                                 
252            return 'Tag page';   
253        else      
254        if (type == 28)                                                 
255            return 'Product';   
256        else                                             
257            return 'Unknow';                          
258    },               
259    saveShare: function (to) {     
260        let obj   = this,                                 
261            id    = genesisPage.getTargetData('id'),
262            type  = genesisPage.getTargetData('type'),
263            typeN = obj.typeName(type);  
264        if ((id > 0) && (type > 0))
265        {            
266            obj.eventGA(to, typeN, id); 
267            $.ajax({  
268                type: 'POST',  
269                url: '/hits.php',
270                data: {                      
271                    'id':       '' + id,              
272                    'type':     '' + type,
273                    'to':       '' + to,
274                    'director':  location.href, 
275                    'event':    'share',
276                    'action':   'set'
277                },          
278                dataType: 'json',
279                success: function() {  
280                    //
281                }   
282            });   
283        }            
284    },      
285    wrapLetters: function (text, insert_char) {
286        let nowrap_after = [            
287            '&', 
288            'a', 'i', 'o', 'w', 'z', 'u',  
289            '"a', '"i', '"o', '"w', '"z', '"u', 
290            '„a', '„i', '„o', '„w', '„z', '„u', 
291            'A', 'I', 'O', 'W', 'Z', 'U',    
292            '"A', '"I', '"O', '"W', '"Z', '"U',
293            '„A', '„I', '„O', '„W', '„Z', '„U', 
294            'do', 'od', 'bo', 'to', 'po', 'go', 'we', 'je', 'za', 'ze', 'że', 'iż', 'im', 'aż', 'na', 'ta', 'tą', 'te', 'tę', 'ma' , 'my', 'by', 'wy', 'co',  
295            'Do', 'Od', 'Bo', 'To'   
296            , 'Ty'
297            , 'Ta'
298            , 'Te'
299            , 'Po'
300            , 'We'
301            , 'Za'
302            , 'Że'
303            , 'Aż'
304            , 'Na'
305            , 'Ma'
306            , 'My'
307            , 'By'
308            , 'Wy'
309            , 'Co'
310            , 'Le'
311            , '"Do'
312            , '"Od'
313            , '"Bo'
314            , '"To'
315            , '"Ta'
316            , '"Te'
317            , '"Po'
318            , '"We'
319            , '"Za'
320            , '"Że'
321            , '"Aż'
322            , '"Na'
323            , '"Ma'
324            , '"My'
325            , '"By'
326            , '"Wy'
327            , '"Co'
328            , '„Do'
329            , '„Od'
330            , '„Bo'
331            , '„To'
332            , '„Ta'
333            , '„Te'
334            , '„Po'
335            , '„We'
336            , '„Za'
337            , '„Że'
338            , '„Aż'
339            , '„Na'
340            , '„Ma'
341            , '„My'
342            , '„By'
343            , '„Wy'
344            , '„Co', 
345            'aby', 'ale', 'dla', 'czy', 'nie', 'lub', 'pod', 'niż', 'zaś', 'oraz',  
346            'Aby', 'Ale', 'Czy', 'Al.', 'Dla', 
347            'and', 'or', 'of', 'is', 'in', 'as', 'us', 'if', 'for', 'the', 'And', 'Or', 'Of', 'Is', 'In', 'Im', 'As', 'For', 'The'
348        ];
349        text = text.replace(/\r/g, '').  
350                    replace(/\t/g, ' ');  
351        for (let i = 0; i < nowrap_after.length; i++)  
352        {
353            let tr = ' ' + nowrap_after[i] + ' ';
354            let re = new RegExp(tr, "gi");  
355            text = text.replace(re, ' ' + nowrap_after[i] + (insert_char ? String.fromCharCode(8239) : '&nbsp;')); 
356        }
357        return text.trim();
358    },          
359    isAppleDevice: function () {   
360        if (genesisPage.isMobile)
361        {
362            const ua       = navigator.userAgent,
363                platform = navigator.platform,
364                iOS      = /iPhone|iPad|iPod/.test(ua) || (platform === "MacIntel" && navigator.maxTouchPoints > 1),
365                macOS    = /Mac/.test(platform);
366            return iOS || macOS;
367        }
368        else
369            return false;
370    },
371    eventGA: function (method, content_type, item_id) {
372        if ((typeof gtag == 'function') || (typeof GA_TRACKING_ID == 'string')) 
373        {      
374            let params = {
375               method: method
376            };
377            if (content_type)
378               params['content_type'] = content_type;  
379            if (item_id)
380                params['item_id'] = item_id;              
381            gtag('event', 'share', params);
382        }
383    }
384};
385(function(a){a.init();}(genesisShare));  

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.