1document.addEventListener('DOMContentLoaded', () => { 2 async function renderButtons($elm) { 3 const services = $elm.getAttribute('services') || ''; 4 const layout = $elm.getAttribute('layout') || 'default'; 5 const rootUri = Joomla.getOptions('system.paths').root; 6 const formData = new FormData(); 7 8 formData.append('layout', layout); 9 formData.append('url', location.href); 10 formData.append('services', services); 11 12 $elm.getAttribute('showcount') && formData.append('showcount', $elm.getAttribute('showcount')); 13 $elm.getAttribute('showtext') && formData.append('showtext', $elm.getAttribute('showtext')); 14 $elm.getAttribute('buttonsize') && formData.append('buttonsize', $elm.getAttribute('buttonsize')); 15 $elm.getAttribute('buttonstyle') && formData.append('buttonstyle', $elm.getAttribute('buttonstyle')); 16 17 const endpoint = rootUri + '/index.php?option=com_ajax&plugin=jasocialshare&group=system&jasocialshare&format=json&ja_ajax_task=renderButtons'; 18 19 const res = await fetch(endpoint, { 20 method: 'POST', 21 body: formData, 22 }); 23 const resData = await res.json(); 24 if (resData.success) { 25 $elm.innerHTML = resData.data[0]; 26 } 27 } 28 29 const excluded = Joomla.getOptions('ja-share-excluded'); 30 excluded.forEach(selector => { 31 const $elms = document.querySelectorAll(`${selector} .ja-share-button`); 32 33 $elms.forEach($elm => { 34 $elm.setAttribute('excluded', true); 35 }) 36 }) 37 38 document.querySelectorAll('.ja-share-button').forEach($elm => { 39 if ($elm.getAttribute('excluded')) { 40 return; 41 } 42 43 renderButtons($elm); 44 }) 45 46 window.jasocialshare = $elm => { 47 if ($elm.dataset.service === 'email') { 48 location.href = 'mailto:?subject=' + encodeURIComponent(Joomla.JText._('JASOCIALSHARE_EMAIL_SUBJECT')) + '&body=' + encodeURIComponent(location.href); 49 } else { 50 const w = 600; 51 const h = 600; 52 const top = window.screenTop < 0 ? window.screenTop + (h / 3) : (window.screen.height - h - 70) / 2; 53 const left = window.screenLeft < 0 ? (window.screenLeft - w) / 2 : (window.screenLeft + w + 60); 54 55 window.open( 56 $elm.dataset.href, 57 'center window', 58 `scrollbars=yes,resizable=yes,height=${h}, width=${w}, top=${top}, left=${left}` 59 ) 60 }; 61 } 62})
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.