PageSourceSearch

https://www.fooddatascrape.com/assets/js/new-fds-main.js

js fooddatascrape.com collected 2026-09-30 15:53:02 UTC 9,812 bytes, 252 lines download raw bytes

1//     document.getElementById('yr').textContent = new Date().getFullYear();
2// const burger = document.getElementById('burger'), mm = document.getElementById('mobileMenu');
3// burger?.addEventListener('click', () => { burger.classList.toggle('active'); mm.classList.toggle('open'); document.body.style.overflow = mm.classList.contains('open') ? 'hidden' : '' });
4
5// document.querySelectorAll('.macc-h').forEach(h => { h.addEventListener('click', () => { const a = h.parentElement, b = h.nextElementSibling; if (a.classList.contains('open')) { b.style.maxHeight = null; a.classList.remove('open') } else { a.classList.add('open'); b.style.maxHeight = b.scrollHeight + 'px' } }) });
6
7
8// document.querySelectorAll('.macc-h').forEach(h => {
9//     h.addEventListener('click', () => {
10//         const currentItem = h.parentElement;
11//         const currentBody = h.nextElementSibling;
12
13//         document.querySelectorAll('.macc.open').forEach(item => {
14//             if (item !== currentItem) {
15//                 item.classList.remove('open');
16
17//                 const body = item.querySelector('.macc-body');
18//                 if (body) body.style.maxHeight = null;
19//             }
20//         });
21
22//         if (currentItem.classList.contains('open')) {
23//             currentItem.classList.remove('open');
24//             currentBody.style.maxHeight = null;
25//         } else {
26//             currentItem.classList.add('open');
27//             currentBody.style.maxHeight =
28//                 currentBody.scrollHeight + 'px';
29//         }
30//     });
31// });
32
33document.querySelectorAll('.cov-tab').forEach(t => {
34    t.addEventListener('click', () => {
35        document.querySelectorAll('.cov-tab').forEach(x => x.classList.remove('active'));
36        document.querySelectorAll('.cov-panel').forEach(x => x.classList.remove('active'));
37        t.classList.add('active');
38        document.getElementById('cov-' + t.dataset.cov).classList.add('active')
39    })
40});
41document.querySelectorAll('.s-tab').forEach(t => {
42    t.addEventListener('click', () => {
43        document.querySelectorAll('.s-tab').forEach(x => x.classList.remove('active'));
44        document.querySelectorAll('.s-panel').forEach(x => x.classList.remove('active'));
45        t.classList.add('active');
46        document.getElementById(t.dataset.tab).classList.add('active')
47    })
48});
49
50/* ===== STAGGER INDEX for cards ===== */
51document.querySelectorAll('.vert-grid > .reveal, .ai-grid > .reveal, .why-grid > .reveal, .engage-grid > .reveal').forEach((el, i) => el.style.setProperty('--i', i));
52
53/* ===== REVEAL ON SCROLL ===== */
54const obs = new IntersectionObserver(e => {
55    e.forEach(x => {
56        if (x.isIntersecting) {
57            x.target.classList.add('in');
58            obs.unobserve(x.target)
59        }
60    })
61}, {
62    threshold: .12
63});
64document.querySelectorAll('.reveal').forEach(el => obs.observe(el));
65
66/* ===== NUMBER COUNTER ===== */
67function animateCounter(el) {
68    const target = parseFloat(el.dataset.target);
69    const duration = 1800;
70    const start = performance.now();
71
72    function tick(now) {
73        const t = Math.min(1, (now - start) / duration);
74        const eased = 1 - Math.pow(1 - t, 3);
75        const val = target * eased;
76        el.textContent = val >= 10 ? Math.round(val) : val.toFixed(1).replace(/\.0$/, '');
77        if (t < 1) requestAnimationFrame(tick);
78        else el.textContent = target;
79    }
80    requestAnimationFrame(tick);
81}
82const counterObs = new IntersectionObserver(e => {
83    e.forEach(x => {
84        if (x.isIntersecting) {
85            animateCounter(x.target);
86            counterObs.unobserve(x.target)
87        }
88    })
89}, {
90    threshold: .5
91});
92document.querySelectorAll('.counter').forEach(el => counterObs.observe(el));
93
94/* ===== CURSOR SPOTLIGHT on cards ===== */
95document.querySelectorAll('.vert, .ai-card, .tier').forEach(card => {
96    card.addEventListener('mousemove', (e) => {
97        const r = card.getBoundingClientRect();
98        card.style.setProperty('--x', (e.clientX - r.left) + 'px');
99        card.style.setProperty('--y', (e.clientY - r.top) + 'px');
100    });
101});
102
103/* ===== MAGNETIC BUTTONS ===== */
104// document.querySelectorAll('.btn-ember, .tier-btn').forEach(btn => {
105//   btn.addEventListener('mousemove', (e) => {
106//     const r = btn.getBoundingClientRect();
107//     const x = e.clientX - r.left - r.width / 2;
108//     const y = e.clientY - r.top - r.height / 2;
109//     btn.style.transform = `translate(${x * .15}px, ${y * .25}px)`;
110//   });
111//   btn.addEventListener('mouseleave', () => { btn.style.transform = '' });
112// });
113
114/* ===== HERO CARD LIVE DATA PULSE ===== */
115const heroRows = document.querySelectorAll('.hc-row');
116const heroVals = [
117    ['12.4M', '12.6M', '12.5M', '12.7M'],
118    ['38,209', '38,420', '38,317', '38,602'],
119    ['96.7%', '96.8%', '96.9%', '97.0%'],
120    ['1,842', '1,829', '1,815', '1,801'],
121    ['A+', 'A+', 'A+', 'A+']
122];
123let heroIdx = 0;
124setInterval(() => {
125    heroIdx = (heroIdx + 1) % 4;
126    heroRows.forEach((row, i) => {
127        const r = row.querySelector('.r');
128        if (!r || !heroVals[i]) return;
129        const delta = r.querySelector('.delta');
130        const newVal = heroVals[i][heroIdx];
131        r.firstChild.textContent = newVal + ' ';
132        row.classList.add('flash');
133        setTimeout(() => row.classList.remove('flash'), 800);
134    });
135}, 3500);
136
137/* ===== HERO H1 FADE animation handled by existing .ld d2 CSS ===== */
138/* ===== FAQ ACCORDION (inner pages) ===== */
139// document.querySelectorAll('.faq-q').forEach(q => {
140//   q.addEventListener('click', () => {
141//     const item = q.parentElement, ans = q.nextElementSibling;
142//     if (item.classList.contains('open')) {
143//       ans.style.maxHeight = null;
144//       item.classList.remove('open');
145//     } else {
146//       item.classList.add('open');
147//       ans.style.maxHeight = ans.scrollHeight + 'px';
148//     }
149//   });
150// });
151
152
153// =========================== faqs =========================
154
155const itemss = document.querySelectorAll(".accordion button");
156
157function toggleAccordion() {
158    const itemToggle = this.getAttribute("aria-expanded");
159
160    for (i = 0; i < itemss.length; i++) {
161        itemss[i].setAttribute("aria-expanded", "false");
162    }
163
164    if (itemToggle == "false") {
165        this.setAttribute("aria-expanded", "true");
166    }
167}
168
169itemss.forEach((item) => item.addEventListener("click", toggleAccordion));
170
171// Add event listeners for outer tabs
172document.querySelectorAll(".jobs-nav-button").forEach((tab) => {
173    tab.addEventListener("click", () => {
174        const target = tab.getAttribute("data-tab-target");
175        document.querySelectorAll(".Jobs-tab-content").forEach((tabContent) => {
176            tabContent.classList.remove("active");
177        });
178        document.querySelectorAll(".jobs-nav-button").forEach((button) => {
179            button.classList.remove("active");
180        });
181        tab.classList.add("active");
182        document.querySelector(target).classList.add("active");
183    });
184});
185
186// Add event listeners for inner tabs
187document.querySelectorAll(".jobs-nav-button-tab").forEach((innerTab) => {
188    innerTab.addEventListener("click", () => {
189        const targetItem = innerTab.getAttribute("data-tab-targetItem");
190        const parentTabContent = innerTab.closest(".Jobs-tab-content");
191        parentTabContent.querySelectorAll(".jobs-data-info").forEach((info) => {
192            info.classList.remove("active");
193        });
194        parentTabContent
195            .querySelectorAll(".jobs-nav-button-tab")
196            .forEach((button) => {
197                button.classList.remove("active");
198            });
199        innerTab.classList.add("active");
200        parentTabContent.querySelector(targetItem).classList.add("active");
201    });
202});
203
204// FAQ accordion
205$(".new-page-f-a-q-question").click(function() {
206    const item = $(this).parent();
207    const answer = $(this).next(".new-page-f-a-q-answer");
208
209    if (item.hasClass("active")) {
210        item.removeClass("active");
211        answer.removeClass("active");
212    } else {
213        $(".new-page-f-a-q-item").removeClass("active");
214        $(".new-page-f-a-q-answer").removeClass("active");
215        item.addClass("active");
216        answer.addClass("active");
217    }
218});
219
220document.querySelectorAll('.faq-q').forEach(function (btn) {
221    btn.addEventListener('click', function (e) {
222        e.stopPropagation();
223
224        const faqItem = this.parentElement;
225        const faqAnswer = this.nextElementSibling;
226
227        if (!faqItem || !faqAnswer) return;
228
229        const isOpen = faqItem.classList.contains('faq-open-xyz');
230
231        faqItem.classList.toggle('faq-open-xyz', !isOpen);
232        faqAnswer.style.maxHeight = isOpen ? '0px' : faqAnswer.scrollHeight + 'px';
233    });
234});
235
236 /* Datasets-by-category tab filter */
237    document.addEventListener('DOMContentLoaded', function () {
238      document.querySelectorAll('.cat-tabs').forEach(function (bar) {
239        var section = bar.closest('section') || document;
240        var tabs = bar.querySelectorAll('.cat-tab');
241        tabs.forEach(function (tab) {
242          tab.addEventListener('click', function () {
243            var target = tab.getAttribute('data-cat');
244            tabs.forEach(function (t) { t.classList.remove('active'); t.setAttribute('aria-selected', 'false'); });
245            tab.classList.add('active'); tab.setAttribute('aria-selected', 'true');
246            section.querySelectorAll('.cat-panel').forEach(function (p) {
247              p.classList.toggle('active', p.getAttribute('data-cat') === target);
248            });
249          });
250        });
251      });
252    });

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.