1import { shareUrl } from './shareHelpers.js'; 2 3let shareRequestInFlight = false; 4 5const getWcAjaxUrl = () => document.getElementById('photohuman-basket')?.dataset.wcAjaxUrl || ''; 6 7export const shareCart = async (button) => { 8 if (shareRequestInFlight) { 9 return; 10 } 11 12 const wcAjaxUrl = getWcAjaxUrl(); 13 14 if (!wcAjaxUrl) { 15 return; 16 } 17 18 shareRequestInFlight = true; 19 button.setAttribute('aria-busy', 'true'); 20 21 const url = wcAjaxUrl.replace('%%endpoint%%', 'photohuman_create_cart_share'); 22 23 try { 24 const response = await fetch(url, { 25 method: 'POST', 26 credentials: 'same-origin', 27 }); 28 29 const data = await response.json(); 30 31 if (data?.error) { 32 window.alert(data.message || 'Ðе ÑдалоÑÑ ÑоздаÑÑ ÑÑÑлкÑ.'); 33 return; 34 } 35 36 if (!data?.url) { 37 window.alert('Ðе ÑдалоÑÑ ÑоздаÑÑ ÑÑÑлкÑ.'); 38 return; 39 } 40 41 const shared = await shareUrl(button, data.url, { 42 title: button.dataset.shareTitle || 'ÐоÑзина Photohuman', 43 text: button.dataset.shareText || 'ÐоÑмоÑÑи Ð¼Ð¾Ñ ÐºÐ¾ÑзинÑ', 44 defaultLabel: 'ÐоделиÑÑÑÑ ÐºÐ¾Ñзиной', 45 }); 46 47 if (!shared) { 48 window.alert('Ðе ÑдалоÑÑ ÑкопиÑоваÑÑ ÑÑÑлкÑ.'); 49 } 50 } catch (error) { 51 window.alert('Ðе ÑдалоÑÑ ÑоздаÑÑ ÑÑÑлкÑ.'); 52 } finally { 53 shareRequestInFlight = false; 54 button.removeAttribute('aria-busy'); 55 } 56};
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.