PageSourceSearch

https://www.elle.cz/js/modules/gallery/facebookEmbeds.js

js elle.cz collected 2026-10-02 07:55:44 UTC 1,932 bytes, 74 lines download raw bytes

1const FACEBOOK_EMBED_SELECTOR = '[data-gallery-facebook-embed]';
2
3export function createFacebookEmbedController(originalSlides) {
4  const initializedEmbeds = new WeakSet();
5  let sdkLoadListenerAttached = false;
6
7  function getFacebookParser() {
8    return typeof window.FB?.XFBML?.parse === 'function'
9      ? window.FB.XFBML.parse.bind(window.FB.XFBML)
10      : null;
11  }
12
13  function waitForSdk() {
14    if (sdkLoadListenerAttached) {
15      return;
16    }
17
18    const sdkScript = document.querySelector('script[src*="connect.facebook.net/"][src*="/sdk.js"]');
19    if (!sdkScript) {
20      return;
21    }
22
23    sdkLoadListenerAttached = true;
24    sdkScript.addEventListener('load', initializeAll, {once: true});
25  }
26
27  function initialize(embedRoot, parse) {
28    const href = embedRoot.dataset.facebookHref;
29    if (!href || initializedEmbeds.has(embedRoot) || embedRoot.getBoundingClientRect().width <= 0) {
30      return;
31    }
32
33    const placeholder = document.createElement('div');
34    placeholder.className = 'fb-post';
35    placeholder.dataset.href = href;
36    placeholder.dataset.width = 'auto';
37    embedRoot.replaceChildren(placeholder);
38    initializedEmbeds.add(embedRoot);
39
40    try {
41      parse(embedRoot);
42    } catch {
43      initializedEmbeds.delete(embedRoot);
44      embedRoot.replaceChildren();
45    }
46  }
47
48  function initializeAll() {
49    const parse = getFacebookParser();
50    if (!parse) {
51      waitForSdk();
52      return;
53    }
54
55    originalSlides.forEach((slide) => {
56      const embedRoot = slide.querySelector(FACEBOOK_EMBED_SELECTOR);
57      if (embedRoot) {
58        initialize(embedRoot, parse);
59      }
60    });
61  }
62
63  function resetAll() {
64    originalSlides.forEach((slide) => {
65      const embedRoot = slide.querySelector(FACEBOOK_EMBED_SELECTOR);
66      if (embedRoot) {
67        initializedEmbeds.delete(embedRoot);
68        embedRoot.replaceChildren();
69      }
70    });
71  }
72
73  return {initializeAll, resetAll};
74}

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.