PageSourceSearch

https://www.ecoflix.com/assets/share.js

js ecoflix.com collected 2026-09-24 19:52:57 UTC 3,758 bytes, 72 lines download raw bytes

1/* Ecoflix — "Share to show your support" (awareness-first sharing).
2   Any element with [data-share] triggers it. Uses the native share sheet
3   (Instagram, WhatsApp, Messages, etc. on mobile) where available; otherwise
4   opens a small fallback menu, Instagram-led. Optional attributes:
5     data-share-url   the link to share (defaults to the current page)
6     data-share-text  the caption (defaults to the page title) */
7(function () {
8  'use strict';
9  var ENC = encodeURIComponent;
10
11  function info(el) {
12    return {
13      url: el.getAttribute('data-share-url') || (location.origin + location.pathname),
14      text: el.getAttribute('data-share-text') || document.title,
15      title: el.getAttribute('data-share-title') || document.title
16    };
17  }
18  function toast(msg) {
19    var t = document.createElement('div');
20    t.className = 'share-toast'; t.textContent = msg;
21    document.body.appendChild(t);
22    requestAnimationFrame(function () { t.classList.add('on'); });
23    setTimeout(function () { t.classList.remove('on'); setTimeout(function () { t.remove(); }, 300); }, 2800);
24  }
25  function copy(s) {
26    if (navigator.clipboard && navigator.clipboard.writeText) return navigator.clipboard.writeText(s);
27    var ta = document.createElement('textarea'); ta.value = s; ta.style.position = 'fixed'; ta.style.opacity = '0';
28    document.body.appendChild(ta); ta.focus(); ta.select();
29    try { document.execCommand('copy'); } catch (e) {}
30    ta.remove(); return Promise.resolve();
31  }
32  function close() { var b = document.querySelector('.share-pop-backdrop'); if (b) b.remove(); }
33
34  function fallback(d) {
35    close();
36    var msg = d.text + ' ' + d.url;
37    var rows = [
38      { label: 'Instagram', cls: 'is-ig', act: function () {
39          copy(msg).then(function () {
40            toast('Caption copied — paste it into your Instagram post or story');
41            window.open('https://www.instagram.com/', '_blank', 'noopener');
42          });
43        } },
44      { label: 'WhatsApp', cls: 'is-wa', act: function () { window.open('https://wa.me/?text=' + ENC(msg), '_blank', 'noopener'); } },
45      { label: 'X', cls: 'is-x', act: function () { window.open('https://twitter.com/intent/tweet?text=' + ENC(d.text) + '&url=' + ENC(d.url), '_blank', 'noopener'); } },
46      { label: 'Facebook', cls: 'is-fb', act: function () { window.open('https://www.facebook.com/sharer/sharer.php?u=' + ENC(d.url), '_blank', 'noopener'); } },
47      { label: 'Copy link', cls: 'is-copy', act: function () { copy(d.url).then(function () { toast('Link copied'); }); } }
48    ];
49    var back = document.createElement('div'); back.className = 'share-pop-backdrop';
50    var pop = document.createElement('div'); pop.className = 'share-pop'; pop.setAttribute('role', 'dialog');
51    var h = document.createElement('div'); h.className = 'share-pop-head'; h.textContent = 'Share to show your support';
52    pop.appendChild(h);
53    rows.forEach(function (r) {
54      var b = document.createElement('button'); b.type = 'button';
55      b.className = 'share-pop-item ' + (r.cls || ''); b.textContent = r.label;
56      b.addEventListener('click', function () { r.act(); close(); });
57      pop.appendChild(b);
58    });
59    back.appendChild(pop);
60    back.addEventListener('click', function (e) { if (e.target === back) close(); });
61    document.body.appendChild(back);
62  }
63
64  document.addEventListener('click', function (e) {
65    var btn = e.target.closest('[data-share]'); if (!btn) return;
66    e.preventDefault();
67    var d = info(btn);
68    if (navigator.share) { navigator.share({ title: d.title, text: d.text, url: d.url }).catch(function () {}); return; }
69    fallback(d);
70  });
71  document.addEventListener('keydown', function (e) { if (e.key === 'Escape') close(); });
72})();

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.