PageSourceSearch

https://photohuman.space/wp-content/themes/photohuman/source/js/modules/shareCart.js?v=1.6.284

js photohuman.space collected 2026-09-28 08:54:34 UTC 1,530 bytes, 56 lines download raw bytes

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.