PageSourceSearch

https://amawestmichigan.org/wp-content/themes/ama-child/js/interactions.js?ver=1.9.0

js amawestmichigan.org collected 2026-10-05 06:20:33 UTC 5,248 bytes, 127 lines download raw bytes

1/* AMA Homepage — podcast player + meme wall interactions.
2   Extracted verbatim from the original inline script. */
3function playPodVideo(e) {
4  if (e) e.stopPropagation();
5  var el = document.getElementById('podFeat');
6  if (!el || el.classList.contains('playing')) return;
7  var id = el.getAttribute('data-yt');
8  var f = document.createElement('iframe');
9  f.className = 'pod-iframe';
10  f.src = 'https://www.youtube-nocookie.com/embed/' + id + '?autoplay=1&rel=0';
11  f.title = 'Marketers In Motion';
12  f.setAttribute('allow', 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share');
13  f.setAttribute('allowfullscreen', '');
14  el.appendChild(f);
15  el.classList.add('playing');
16}
17/* Play a specific episode in the featured player (episode-list thumbnails). */
18function playPodEpisode(id, title) {
19  var el = document.getElementById('podFeat');
20  if (!el || !id) return;
21  var old = el.querySelector('.pod-iframe');
22  if (old) { old.remove(); el.classList.remove('playing'); }
23  el.setAttribute('data-yt', id);
24  if (title) {
25    var h = el.querySelector('h3');
26    if (h) h.textContent = title;
27  }
28  playPodVideo();
29  var y = el.getBoundingClientRect().top + window.pageYOffset - 90;
30  window.scrollTo({ top: y, behavior: 'smooth' });
31}
32
33document.addEventListener('click', function (e) {
34  /* Episode rows with a data-yt play in the featured player. */
35  var ep = e.target.closest('.ep[data-yt]');
36  if (ep) {
37    var t = ep.querySelector('h4');
38    playPodEpisode(ep.getAttribute('data-yt'), t ? t.textContent : '');
39    return;
40  }
41  /* "Add to calendar" builds and downloads a real .ics file. */
42  var cal = e.target.closest('.js-add-cal');
43  if (cal) {
44    e.preventDefault();
45    var esc = function (s) { return String(s || '').replace(/\\/g, '\\\\').replace(/;/g, '\\;').replace(/,/g, '\\,').replace(/\n/g, '\\n'); };
46    var ics = [
47      'BEGIN:VCALENDAR', 'VERSION:2.0', 'PRODID:-//AMA West Michigan//Events//EN',
48      'BEGIN:VEVENT',
49      'UID:' + Date.now() + '@amawestmichigan.org',
50      'DTSTAMP:' + new Date().toISOString().replace(/[-:]/g, '').replace(/\.\d+/, ''),
51      'DTSTART;TZID=America/Detroit:' + cal.dataset.start,
52      'DTEND;TZID=America/Detroit:' + cal.dataset.end,
53      'SUMMARY:' + esc(cal.dataset.title),
54      'LOCATION:' + esc(cal.dataset.location),
55      'DESCRIPTION:' + esc(cal.dataset.desc || 'AMA West Michigan event'),
56      'END:VEVENT', 'END:VCALENDAR'
57    ].join('\r\n');
58    var blob = new Blob([ics], { type: 'text/calendar;charset=utf-8' });
59    var a = document.createElement('a');
60    a.href = URL.createObjectURL(blob);
61    a.download = (cal.dataset.title || 'event').replace(/[^\w]+/g, '-').toLowerCase() + '.ics';
62    document.body.appendChild(a);
63    a.click();
64    setTimeout(function () { URL.revokeObjectURL(a.href); a.remove(); }, 500);
65  }
66});
67
68/* Floating labels for Formidable fields: label sits inside the input and
69   shrinks to the top when the field is focused or has a value. */
70(function () {
71  function bind() {
72    document.querySelectorAll('.frm_form_field.frm_top_container').forEach(function (wrap) {
73      var input = wrap.querySelector('input:not([type=hidden]), textarea, select');
74      if (!input || wrap.classList.contains('frm_verify') || input.classList.contains('frm_verify')) return;
75      // Selects keep a placeholder option instead of a floating label.
76      if (input.tagName === 'SELECT') { wrap.classList.add('select-field'); return; }
77      wrap.classList.add('float-label');
78      var sync = function () {
79        wrap.classList.toggle('is-active', document.activeElement === input || '' !== input.value.trim());
80      };
81      input.addEventListener('focus', sync);
82      input.addEventListener('blur', sync);
83      input.addEventListener('input', sync);
84      sync();
85    });
86  }
87  if (document.readyState === 'loading') {
88    document.addEventListener('DOMContentLoaded', bind);
89  } else {
90    bind();
91  }
92})();
93
94function shuffleMemes() {
95  var wall = document.getElementById('memeWall');
96  if (!wall) return;
97  var items = Array.prototype.slice.call(wall.children);
98  for (var i = items.length - 1; i > 0; i--) {
99    var j = Math.floor(Math.random() * (i + 1));
100    wall.appendChild(items[j]);
101    items.splice(j, 1);
102  }
103  Array.prototype.forEach.call(wall.querySelectorAll('.meme-card'), function (c) {
104    var t = (Math.random() * 6 - 3).toFixed(2);
105    c.style.setProperty('--tilt', t + 'deg');
106  });
107}
108function revealMemes() {
109  var wrap = document.getElementById('memeReveal');
110  var btn = document.getElementById('memeUnlock');
111  if (!wrap || wrap.dataset.open) return;
112  wrap.dataset.open = '1';
113  wrap.hidden = false;
114  wrap.querySelectorAll('.reveal').forEach(function (el) { el.classList.add('in'); });
115  requestAnimationFrame(function () { wrap.classList.add('open'); });
116  setTimeout(function () {
117    if (wrap.getAnimations) wrap.getAnimations().forEach(function (a) { try { a.finish(); } catch (e) {} });
118  }, 750);
119  if (btn) {
120    btn.classList.add('used');
121    setTimeout(function () { btn.hidden = true; }, 450);
122  }
123  setTimeout(function () {
124    var y = wrap.getBoundingClientRect().top + window.pageYOffset - 80;
125    window.scrollTo({ top: y, behavior: 'smooth' });
126  }, 80);
127}

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.