1class generateperfSocialShare { 2 constructor() { 3 this.touchEvent = 'click'; 4 this.shareUrls = this.generateShareUrls(); 5 this.initEventListeners(); 6 } 7 8 generateShareUrls() { 9 return { 10 twitter: `https://x.com/intent/tweet?url=${generateperf_social_share.url}&text=${generateperf_social_share.title}`, 11 x: `https://x.com/intent/tweet?url=${generateperf_social_share.url}&text=${generateperf_social_share.title}`, 12 facebook: `https://www.facebook.com/sharer.php?u=${generateperf_social_share.url}"e=${generateperf_social_share.title}`, 13 flipboard: `https://share.flipboard.com/bookmarklet/popout?v=2&t=${new Date().getTime()}&url=${generateperf_social_share.url}&title=${generateperf_social_share.title}&utm_campaign=widgets&utm_medium=web&utm_source=profile_badge`, 14 linkedin: `https://www.linkedin.com/shareArticle?url=${generateperf_social_share.url}&title=${generateperf_social_share.title}`, 15 pinterest: `https://www.pinterest.fr/pin/create/button/?url=${generateperf_social_share.url}&description=${generateperf_social_share.title}&media=${generateperf_social_share.image}`, 16 whatsapp: `https://wa.me/?text=${generateperf_social_share.title}%20:%20${generateperf_social_share.url}`, 17 telegram: `https://t.me/share/url?url=${generateperf_social_share.url}&text=${generateperf_social_share.title}`, 18 snapchat: `https://snapchat.com/scan?attachmentUrl=${generateperf_social_share.url}`, 19 reddit: `http://www.reddit.com/submit?url=${generateperf_social_share.url}&title=${generateperf_social_share.title}`, 20 ninegag: `https://9gag.com/submit?url=${generateperf_social_share.image}`, 21 threads: `barcelona://create?text=${generateperf_social_share.title} ${generateperf_social_share.url}`, 22 }; 23 } 24 25 initEventListeners() { 26 document.querySelectorAll("[data-share-url]").forEach(el => { 27 el.addEventListener(this.touchEvent, this.handleShareClick.bind(this), { passive: true }); 28 }); 29 } 30 31 handleShareClick(e) { 32 const service = e.currentTarget.dataset.shareUrl; 33 let url = this.shareUrls[service]; 34 35 if (service === "native") { 36 this.handleNativeShare(e.currentTarget); 37 } else if (service === "copy-link") { 38 this.handleCopyLink(e.currentTarget); 39 } else if (url) { 40 window.open(url, "_blank").focus(); 41 } 42 } 43 44 handleNativeShare(element) { 45 if (navigator.share) { 46 navigator.share({ 47 title: generateperf_social_share.title, 48 url: generateperf_social_share.url, 49 }); 50 } else { 51 window.requestAnimationFrame(() => { 52 element.closest('.share-buttons-toggler').remove(); 53 }); 54 } 55 } 56 57 handleCopyLink(element) { 58 if (!element.dataset.orig) element.dataset.orig = encodeURI(element.innerHTML); 59 window.requestAnimationFrame(() => { 60 element.innerHTML = generateperf_social_share.copied; 61 }); 62 63 navigator.clipboard.writeText(decodeURIComponent(generateperf_social_share.url)); 64 setTimeout(() => { element.innerHTML = decodeURI(element.dataset.orig); }, 1500); 65 } 66} 67 68document.addEventListener("DOMContentLoaded", function() { 69 new generateperfSocialShare(); 70});
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.