PageSourceSearch

https://www.foodandwatereurope.org/wp-content/themes/fww-theme-twentytwenty-child/custom-compiled.js?ver=1.579

js foodandwatereurope.org collected 2026-09-24 18:47:15 UTC 39,677 bytes, 953 lines download raw bytes

1"use strict";
2
3var _this = void 0;
4
5function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
6
7function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
9function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
10
11function loadScript(url, callback) {
12  const script = document.createElement('script');
13  script.type = 'module';
14  script.src = url;
15
16  script.onload = function() {
17    callback();
18  };
19
20  script.onerror = function() {
21    console.error('Failed to load script:', url);
22  };
23
24  document.head.appendChild(script);
25}
26
27window.addEventListener('load', function (event) {
28  if(document.querySelector('bsky-embed')){
29    loadScript('/wp-content/themes/fww-theme-twentytwenty-child/bsky-embed.es.js', function() {
30      console.log('my_script.js loaded successfully!');
31    }); 
32  }
33  var setCookie = function setCookie(cookieKey, cookieValue, expirationDays) {
34    var expiryDate = '';
35
36    if (expirationDays) {
37      var date = new Date();
38      date.setTime("".concat(date.getTime()).concat(expirationDays || 30 * 24 * 60 * 60 * 1000));
39      expiryDate = "; expiryDate=\" ".concat(date.toUTCString());
40    }
41
42    document.cookie = "".concat(cookieKey, "=").concat(cookieValue || '').concat(expiryDate, "; path=/");
43  },
44      getCookie = function getCookie(cookieKey) {
45    var cookieName = "".concat(cookieKey, "=");
46    var cookieArray = document.cookie.split(';');
47
48    var _iterator = _createForOfIteratorHelper(cookieArray),
49        _step;
50
51    try {
52      for (_iterator.s(); !(_step = _iterator.n()).done;) {
53        var cookie = _step.value;
54
55        while (cookie.charAt(0) == ' ') {
56          cookie = cookie.substring(1, cookie.length);
57        }
58
59        if (cookie.indexOf(cookieName) == 0) {
60          return cookie.substring(cookieName.length, cookie.length);
61        }
62      }
63    } catch (err) {
64      _iterator.e(err);
65    } finally {
66      _iterator.f();
67    }
68  };
69
70  var setUpMobileMenuToggle = function setUpMobileMenuToggle() {
71    // mobile menu submenu toggles
72    var menuItemsWithChilrenLinks = document.querySelectorAll('.mobile-menu .menu-item-has-children .ancestor-wrapper > a');
73    Array.prototype.forEach.call(menuItemsWithChilrenLinks, function (item) {
74      var activeSub = item.parentElement.parentElement.querySelector('ul.sub-menu.active');
75      if (activeSub) activeSub.classList.remove('active');
76      item.addEventListener('click', function (e) {
77        e.preventDefault();
78        var activeItem = document.querySelector('.mobile-menu .menu-item-has-children .ancestor-wrapper > a.sub-menu-open');
79        var timeout = 0;
80
81        if (activeItem) {
82          activeItem.parentElement.querySelector('.sub-menu-toggle').click();
83          activeItem.classList.toggle('sub-menu-open');
84          if (activeItem === item) return;
85          timeout = 300;
86        }
87
88        setTimeout(function () {
89          item.classList.toggle('sub-menu-open');
90          item.parentElement.querySelector('.sub-menu-toggle').click();
91          if (item.classList.contains('sub-menu-open')) item.parentElement.parentElement.scrollIntoView(true);
92        }, timeout);
93      });
94    });
95  };
96
97  setUpMobileMenuToggle();
98
99  function toggleMobileMenu(button) {
100    var isActive = button.className.indexOf('active') > -1;
101    var mobileMenu = document.querySelector('.mobile-menu');
102    var rent = new Object();
103    var isTopMenuItem = false;
104    var subMenus = mobileMenu.getElementsByClassName('sub-menu');
105    var menuItems = mobileMenu.getElementsByClassName('menu-item');
106    var buttons = mobileMenu.getElementsByClassName('sub-menu-toggle');
107
108    if (!isActive) {
109      for (var i = 0; i < subMenus.length; i++) {
110        subMenus[i].classList.remove('active');
111        buttons[i].classList.remove('active');
112      }
113
114      button.parentNode.parentNode.getElementsByClassName('sub-menu')[0].classList.add('has-light-blue-background-color');
115    }
116
117    for (var i = 0; i < menuItems.length; i++) {
118      rent = menuItems[i].parentNode;
119      isTopMenuItem = rent.className.indexOf('sub-menu') === -1;
120
121      if (isTopMenuItem) {
122        menuItems[i].style.display = isActive ? 'flex' : 'none';
123        mobileMenu.parentNode.querySelector('.mobile-search-toggle').style.display = isActive ? 'flex' : 'none';
124      }
125    }
126
127    if (!isActive) {
128      button.parentNode.parentNode.style.display = 'flex';
129    }
130  }
131
132  ;
133  var menuItems = document.querySelectorAll('.primary-menu .menu-item-has-children');
134
135  function addOverview(menuItem) {
136    var link = menuItem.getElementsByClassName('ancestor-wrapper')[0].getElementsByTagName('a')[0];
137    var url = link.href;
138    var title = link.innerHTML;
139    menuItem.getElementsByClassName('sub-menu')[0].innerHTML += '<li class="menu-item" style="padding-left: 0;"><a href="' + url + '" style="text-decoration: underline;">' + title + ' Overview</a><li>';
140  }
141
142  for (var i = 0; i < menuItems.length; i++) {
143    if (menuItems[i].parentNode.className.indexOf('modal-menu') > -1) {
144      (function () {
145        var button = menuItems[i].getElementsByTagName('button')[0];
146        button.addEventListener("click", function (event) {
147          toggleMobileMenu(button);
148        });
149        addOverview(menuItems[i]);
150      })();
151    }
152  }
153
154  window.togglePageMenu = function (item) {
155    var isLinkOut = item.parentElement.classList.contains('link-out');
156    var activeIndex = 0;
157    var mobileLists = document.getElementsByClassName('fwa-mobile-list');
158    var hasMobileList = mobileLists.length > 0;
159    var bottomMenu = document.getElementsByClassName('fwa-mobile-page-menu-bottom')[0];
160
161    if (isLinkOut && !item.dataset.prime) {
162      window.location.href = item.dataset.href;
163      return;
164    }
165
166    if (!hasMobileList) {
167      item.classList.add('active');
168      item.classList.add('open');
169      document.getElementsByClassName('fwa-mobile-page-list')[0].classList.add('fwa-mobile-list');
170      bottomMenu.getElementsByClassName('fwa-mobile-page-menu')[0].classList.add('active');
171    }
172
173    var isItemTop = item.parentElement.classList.contains('top-menu');
174    var otherMenuItems = isItemTop ? bottomMenu.getElementsByClassName('fwa-mobile-page-menu')[0].getElementsByTagName('li') : document.querySelector('.fwa-mobile-page-menu.top-menu').getElementsByTagName('li');
175    var sections = document.getElementsByClassName('fwa-mobile-list')[0].getElementsByClassName('fwa-mobile-list-item');
176    sections = sections.length === 0 ? document.getElementsByClassName('fwa-mobile-list')[0].getElementsByClassName('wp-block-coblocks-row') : sections;
177
178    if (item.classList.contains('active')) {
179      if (!hasMobileList) {
180        sections[0].classList.add('active');
181      }
182
183      if (!item.classList.contains('open')) {
184        item.classList.add('open');
185        item.classList.remove('closed');
186      } else {
187        item.classList.remove('open');
188        item.classList.remove('active');
189        item.classList.add('closed');
190
191        for (var i = 0; i < sections.length; i++) {
192          sections[i].classList.remove('active');
193        }
194
195        sections[0].parentElement.parentElement.style.display = 'none';
196      }
197    } else {
198      for (var i = 0; i < item.parentElement.children.length; i++) {
199        if (item.parentElement.children[i] !== item) {
200          item.parentElement.children[i].classList.remove('active');
201          item.parentElement.children[i].classList.remove('open');
202          item.parentElement.children[i].classList.add('closed');
203        } else activeIndex = i;
204      }
205
206      item.classList.add('active');
207      item.classList.add('open');
208      item.classList.remove('closed');
209      if (sections.length === 1) sections[0].classList.add('active');else {
210        for (var i = 0; i < sections.length; i++) {
211          if (activeIndex === i) sections[i].classList.add('active');else sections[i].classList.remove('active');
212        }
213      }
214      sections[0].parentElement.parentElement.style.display = 'block';
215      if (window.scrollY > 400) document.getElementsByClassName('fwa-mobile-page-menu')[0].scrollIntoView();
216    }
217
218    for (var i = 0; i < otherMenuItems.length; i++) {
219      otherMenuItems[i].classList = item.parentElement.getElementsByTagName('li')[i].classList;
220    }
221  }; // presetting elements and variables for scroll function 
222
223
224  window.fwaHeaderItems = {
225    header: document.getElementById("site-header"),
226    navHeader: document.querySelector('.fwa-page-nav.yes-sticky'),
227    reportHeader: document.querySelector('.research-report-nav'),
228    postSocialShare: document.querySelector('.post-social-share'),
229    roadMap: document.querySelector('.road-map'),
230    jobPostHeader: document.querySelector('.category-job-posting-not-public header'),
231    jobPostDetails: document.querySelector('.category-job-posting-not-public .job-details'),
232    menuItems: null,
233    anchors: [],
234    roadMapAnchors: [],
235    roadMapMenuItems: null
236  };
237
238  var setNavAnchors = function setNavAnchors(menuItems, isRoadMap) {
239    var bodyRect = document.body.getBoundingClientRect(),
240        anchorArr = isRoadMap ? window.fwaHeaderItems.roadMapAnchors : window.fwaHeaderItems.anchors;
241    Array.prototype.forEach.call(menuItems, function (item) {
242      var anchor = document.querySelector('#' + item.href.split('#')[1]);
243
244      if (anchor !== null) {
245        var elemRect = anchor.getBoundingClientRect(),
246            offset = elemRect.top - bodyRect.top;
247        anchorArr.push({
248          menuItem: item,
249          offset: offset
250        });
251      }
252    });
253  };
254
255  if (window.fwaHeaderItems.navHeader) {
256    window.fwaHeaderItems.menuItems = window.fwaHeaderItems.navHeader.getElementsByTagName('a');
257    setNavAnchors(window.fwaHeaderItems.menuItems, false);
258  }
259
260  if (window.fwaHeaderItems.roadMap) {
261    window.fwaHeaderItems.roadMapMenuItems = window.fwaHeaderItems.roadMap.querySelectorAll('.road-map-nav li a');
262    window.fwaHeaderItems.roadMapMenuItems.forEach(function (item, i) {
263      item.addEventListener('click', function (e) {
264        e.preventDefault();
265        if (!window.fwaHeaderItems.roadMapAnchors[i]) return;
266        window.scrollTo(0, window.fwaHeaderItems.roadMapAnchors[i].offset - window.fwaHeaderItems.roadMap.querySelector('.road-map-nav').offsetHeight - window.fwaHeaderItems.header.offsetHeight + 50);
267      });
268    });
269    setNavAnchors(window.fwaHeaderItems.roadMapMenuItems, true);
270  }
271
272  document.getElementById('head-space').style.height = document.getElementById("site-header").offsetHeight + 'px';
273
274  function setFixedHeader() {
275    // don't run on virtual benefit page
276    if (document.querySelector('.vb-top')) return;
277    var isReportNavInHeader = window.fwaHeaderItems.header.classList.contains('contains-report-nav');
278    if (window.oldScroll > window.scrollY) window.fwaHeaderItems.header.classList.add('going-up');else window.fwaHeaderItems.header.classList.remove('going-up');
279
280    var manageRoadMap = function manageRoadMap() {
281      var headerBottom = window.fwaHeaderItems.header.getBoundingClientRect().bottom,
282          roadMapBounding = window.fwaHeaderItems.roadMap.getBoundingClientRect(),
283          roadMapNav = window.fwaHeaderItems.roadMap.querySelector('.road-map-nav');
284
285      if (headerBottom > roadMapBounding.top && headerBottom < roadMapBounding.bottom - roadMapNav.offsetHeight) {
286        window.fwaHeaderItems.roadMap.style.paddingTop = roadMapNav.offsetHeight + 'px';
287        window.fwaHeaderItems.roadMap.classList.add('sticky');
288        roadMapNav.style.top = window.fwaHeaderItems.header.offsetHeight + 'px';
289        roadMapNav.style.marginTop = '-18px';
290      } else {
291        window.fwaHeaderItems.roadMap.style.paddingTop = '';
292        roadMapNav.style = '';
293        window.fwaHeaderItems.roadMap.classList.remove('sticky');
294      }
295    },
296        manageSticky = function manageSticky(item, isHeader, isReportHeader) {
297      var getOffsetTop = function getOffsetTop(el) {
298        if (!el) el = document.querySelector('.research-report-top');
299        var rect = el.getBoundingClientRect(),
300            scrollTop = window.pageYOffset || document.documentElement.scrollTop;
301        return rect.top + scrollTop;
302      };
303
304      var sticky = function sticky() {
305        if (document.body.classList.contains('no-sticky')) return; // const getOffs
306
307        var stickyNum = function stickyNum() {
308          var num = isReportNavInHeader ? getOffsetTop(null) - window.fwaHeaderItems.reportHeader.offsetHeight : window.fwaHeaderItems.reportHeader ? getOffsetTop(null) : item === window.fwaHeaderItems.postSocialShare ? 500 : item === window.fwaHeaderItems.jobPostHeader || item === window.fwaHeaderItems.jobPostDetails ? window.fwaHeaderItems.jobPostHeader.offsetHeight - 40 : 0;
309          return num;
310        };
311
312        var isSticky = window.pageYOffset > window.fwaHeaderItems.header.offsetHeight + stickyNum();
313
314        var isStickyStop = function isStickyStop() {
315          var returnIt = function returnIt(val, i) {
316            return val;
317          };
318
319          var isSocial = item === window.fwaHeaderItems.postSocialShare;
320          var triggerElement = isSocial ? document.querySelector('.blue-newsletter-block') : document.querySelector('.footer-nav-widgets-wrapper');
321          if (!triggerElement) return returnIt(isSticky, 1);
322          var trigElTop = triggerElement.getBoundingClientRect().top,
323              itemTop = item.getBoundingClientRect().top,
324              upNum = isSocial ? 380 : triggerElement.offsetHeight,
325              downNum = isSocial ? 250 : 300;
326          if (isSticky === false) return returnIt(isSticky, 2);else if (itemTop < 0 && trigElTop > upNum) return returnIt(isSticky, 3);else if (itemTop < 0) return returnIt(false, 4);else return returnIt(trigElTop > itemTop + downNum, 5);
327        };
328
329        if (item === window.fwaHeaderItems.postSocialShare || item === window.fwaHeaderItems.jobPostDetails) {
330          isSticky = isStickyStop();
331        }
332
333        return isSticky;
334      };
335
336      var animateSticky = function animateSticky(turnOff) {
337        if (turnOff) {
338          item.style.transition = null;
339          item.style.opacity = null;
340          return;
341        }
342
343        setTimeout(function () {
344          item.style.transition = 'opacity 500ms';
345          setTimeout(function () {
346            item.style.opacity = '1';
347          }, 100);
348        }, 100);
349      };
350
351      if (sticky()) {
352        if (item.classList.contains('sticky')) return;
353
354        if (item === fwaHeaderItems.jobPostHeader) {
355          item.nextElementSibling.style.paddingTop = item.offsetHeight + 40 + 'px';
356          if (window.innerWidth < 762) item.style.top = "0";else if (window.innerWidth > 999) item.style.setProperty('top', fwaHeaderItems.header.offsetHeight + 'px', 'important');else item.style.top = fwaHeaderItems.header.offsetHeight + 'px';
357        }
358
359        if (item === fwaHeaderItems.jobPostDetails) {
360          item.style.top = fwaHeaderItems.header.offsetHeight + fwaHeaderItems.jobPostHeader.offsetHeight + 'px';
361        }
362
363        item.classList.add("sticky");
364        if (!isReportHeader) animateSticky(false);
365
366        if (isReportHeader) {
367          window.fwaHeaderItems.header.classList.toggle('contains-report-nav');
368          window.fwaHeaderItems.header.append(item);
369        }
370
371        if (isHeader) document.getElementById('head-space').style.display = 'block';
372      } else {
373        if (!item.classList.contains('sticky')) return;
374        item.classList.remove("sticky");
375        if (item === fwaHeaderItems.jobPostHeader) item.nextElementSibling.style.paddingTop = '';
376        if (!isReportHeader) animateSticky(true);
377
378        if (isReportHeader) {
379          document.querySelector('.research-report-top div').prepend(item);
380          window.fwaHeaderItems.header.classList.toggle('contains-report-nav');
381        }
382
383        if (isHeader) document.getElementById('head-space').style.display = 'none';
384      }
385    },
386        manageMenuHighlights = function manageMenuHighlights(isRoadMap) {
387      var highlightedAnchor = null;
388      var oldHighLightedAnchor = isRoadMap ? window.fwaHeaderItems.roadMap.querySelector('.road-map-nav li.active') : window.fwaHeaderItems.navHeader ? window.fwaHeaderItems.navHeader.querySelector('div.active') : window.fwaHeaderItems.reportHeader.querySelector('span.active'),
389          offSet = isRoadMap ? 300 : window.fwaHeaderItems.navHeader ? 60 : 200,
390          anchorsArr = isRoadMap ? window.fwaHeaderItems.roadMapAnchors : window.fwaHeaderItems.anchors;
391
392      if (!isRoadMap && !oldHighLightedAnchor && window.fwaHeaderItems.reportHeader) {
393        // report.js code has not run yet  
394        return;
395      }
396
397      Array.prototype.forEach.call(anchorsArr, function (anchor) {
398        if (anchor.offset < window.pageYOffset + offSet) highlightedAnchor = anchor;
399      });
400
401      if (highlightedAnchor) {
402        if (oldHighLightedAnchor) oldHighLightedAnchor.classList.remove('active');
403        if (window.fwaHeaderItems.navHeader || isRoadMap) highlightedAnchor.menuItem.parentElement.classList.add('active');else highlightedAnchor.menuItem.classList.add('active');
404      }
405    };
406
407    manageSticky(window.fwaHeaderItems.header, true, false);
408
409    if (window.fwaHeaderItems.navHeader) {
410      manageSticky(window.fwaHeaderItems.navHeader, false, false);
411      manageMenuHighlights(false);
412    } else if (window.fwaHeaderItems.reportHeader) {
413      manageSticky(window.fwaHeaderItems.reportHeader, false, true);
414      manageMenuHighlights(false);
415    } else if (window.fwaHeaderItems.postSocialShare) {
416      manageSticky(window.fwaHeaderItems.postSocialShare, false, false);
417    }
418
419    if (window.fwaHeaderItems.roadMap) {
420      manageRoadMap();
421      manageMenuHighlights(true);
422    }
423
424    if (window.fwaHeaderItems.jobPostHeader) {
425      manageSticky(window.fwaHeaderItems.jobPostHeader, false, false);
426      if (window.fwaHeaderItems.jobPostDetails && window.innerWidth > 761) manageSticky(window.fwaHeaderItems.jobPostDetails, false, false);
427    }
428  } // When the user scrolls the page, execute setFixedHeader
429
430
431  window.onscroll = function () {
432    var reportProgBar = document.querySelector('#report-progress-bar');
433    if (!this.oldScroll) this.oldScroll = this.scrollY;
434    setFixedHeader();
435    this.oldScroll = this.scrollY;
436
437    if (reportProgBar) {
438      var winScroll = document.body.scrollTop || document.documentElement.scrollTop,
439          height = document.documentElement.scrollHeight - document.documentElement.clientHeight,
440          scrolled = winScroll / height * 100;
441      reportProgBar.style.width = scrolled + "%";
442    }
443  }; // Donation block logic
444
445
446  window.setDonationAmount = function (item) {
447    var amountsWrapper = document.querySelector('#donation-amounts'),
448        amounts = amountsWrapper.getElementsByTagName('div');
449    var amount = '',
450        otherAmount = '';
451
452    for (var i = 0; i < amounts.length; i++) {
453      amounts[i].classList.remove('has-yellow-background-color');
454    }
455
456    if (item.id === 'edit-amount') {
457      var input = item.getElementsByTagName('input')[0],
458          displayTxt = item.querySelector('span'),
459          setCustomAmountDisplay = function setCustomAmountDisplay(amountStr) {
460        item.getElementsByTagName('span')[0].innerHTML = amountStr;
461        if (amountStr.length !== 0) item.classList.add('active');else item.classList.remove('active');
462      };
463
464      input.style.display = 'inline-block';
465      displayTxt.style.display = 'none';
466
467      input.onblur = function () {
468        var isPopulated = input.value && input.value !== '0' ? true : false;
469
470        if (isPopulated) {
471          setCustomAmountDisplay(input.value);
472          item.classList.add('has-yellow-background-color');
473        } else {
474          setCustomAmountDisplay('');
475
476          if (document.getElementById('donation-frequency').value === 'recurs') {
477            amountsWrapper.querySelector('.default-monthly').click();
478          } else {
479            amountsWrapper.querySelector('.default-one-time').click();
480          }
481        }
482
483        input.style.display = 'none';
484        displayTxt.style.display = 'inline-block';
485      };
486
487      item.classList.add('has-yellow-background-color');
488    } else if (item.nodeName !== 'INPUT') {
489      item.classList.add('has-yellow-background-color');
490      amount = item.querySelector('span').innerHTML.replace('$', '');
491      otherAmount = '';
492    } else {
493      amount = 'other';
494      otherAmount = item.value;
495    }
496
497    document.getElementById('donation-amount').value = amount;
498    document.getElementById('donation-amount-other').value = otherAmount;
499  };
500
501  var _donationToggled = false;
502
503  window.toggleDonationSchedule = function (item, frequency) {
504    // set amount to one-time default if frequency never toggled 
505    if (!_donationToggled) {
506      document.getElementById('donation-amount').setAttribute('value', 35);
507      document.getElementById('donation-amount-other').value = '';
508      document.querySelector('#edit-amount span').innerHTML = '';
509      document.querySelector('#edit-amount input').value = '';
510      _donationToggled = true;
511    }
512
513    var radioButtons = document.getElementsByClassName('radio-buttons')[0].getElementsByTagName('span'),
514        resetAmounts = function resetAmounts() {
515      var amounts = document.querySelectorAll('#donation-amounts div'),
516          currentAmount = document.getElementById('donation-amount').value,
517          otherAmount = document.getElementById('donation-amount-other').value,
518          editAmount = document.querySelector('#edit-amount');
519      var isAmountHighlighted = false;
520      amounts.forEach(function (amount) {
521        var amountNum = amount.querySelector('span').innerHTML.replace('$', ''),
522            trueAmount = currentAmount === 'other' ? otherAmount : currentAmount;
523
524        if (amount.id !== 'edit-amount') {
525          amount.classList.toggle('hide-this');
526          amount.classList.remove('has-yellow-background-color');
527
528          if (amountNum === trueAmount) {
529            if (!amount.classList.contains('hide-this')) {
530              amount.classList.add('has-yellow-background-color');
531              isAmountHighlighted = true;
532              document.getElementById('donation-amount').value = amountNum;
533              document.getElementById('donation-amount-other').value = '';
534            }
535          }
536        } else editAmount.classList.remove('has-yellow-background-color');
537      });
538
539      if (isAmountHighlighted) {
540        editAmount.querySelector('span').innerHTML = '';
541      } else {
542        editAmount.querySelector('span').innerHTML = currentAmount === 'other' ? otherAmount : currentAmount;
543        editAmount.classList.add('has-yellow-background-color');
544        document.getElementById('donation-amount').value = 'other';
545        document.getElementById('donation-amount-other').value = currentAmount === 'other' ? otherAmount : currentAmount;
546      }
547    };
548
549    for (var i = 0; i < radioButtons.length; i++) {
550      radioButtons[i].classList.remove('has-yellow-background-color');
551    }
552
553    item.classList.add('has-yellow-background-color');
554    document.getElementById('donation-frequency').value = frequency;
555    resetAmounts();
556  };
557
558  window.sendNewsletterSignup = function (theForm) {
559    if (!theForm) return;
560    var formBlock = theForm.closest('.wp-block-group'),
561        noGoClasses = ['error', 'success', 'loading'];
562    if (!formBlock || noGoClasses.some(function (className) {
563      return formBlock.classList.contains(className);
564    })) return;
565    formBlock.classList.add('newsletter-wrapper'); // for validity start
566
567    var sendToValidityThenPost = function sendToValidityThenPost() {
568      var oReq = new XMLHttpRequest(),
569          emailStr = theForm.querySelector('input[name="mail"]').value,
570          transferComplete = function transferComplete() {
571        if (oReq.response && oReq.response.results && oReq.response.results.status === 'invali
571d') {
572          console.log('fail', oReq.response);
573          reportError('Oops, there seems to be an error with your email address. Try again!', 'validity');
574        } else sendToReCaptcha();
575      },
576          transferFailed = function transferFailed() {
577        console.log('validity failed');
578        sendToReCaptcha();
579      },
580          transferCanceled = function transferCanceled() {
581        console.log('validity cancelled');
582        sendToReCaptcha();
583      };
584
585      console.log(emailStr);
586      oReq.responseType = 'json';
587      oReq.addEventListener("load", transferComplete);
588      oReq.addEventListener("error", transferFailed);
589      oReq.addEventListener("abort", transferCanceled);
590      oReq.open('GET', 'https://api.everest.validity.com/api/2.0/validation/address/' + emailStr);
591      oReq.setRequestHeader('X-API-KEY', '3d5903719de87a6051848c8653d46e320c6a4311');
592      oReq.send();
593    }; // for validity end 
594
595
596    var ajaxMessageBox = formBlock.querySelector('.ajax-return-message'),
597        sendToReCaptcha = function sendToReCaptcha() {
598      console.log('sent to reCaptcha');
599      grecaptcha.ready(function () {
600        // K's localhost site key 
601        // grecaptcha.execute('6LfnZtEZAAAAANRpozmuCIP9sot-BQuNdsmiPQk8', {action: 'submit'}).then(function(token) {
602        // wpengine key 
603        // 6Ld_4dEZAAAAANpwm_AEn43tLis6X-md6IHlQqZ2
604        grecaptcha.execute('6LfsgZoeAAAAAMTIZ11EHKKPqUeAyxPmDrtl5jJO', {
605          action: 'submit'
606        }).then(function (token) {
607          fetch('/grecaptcha.php?token=' + token).then(function (response) {
608            return response.json();
609          }).then(function (result) {
610            if (!result.success) {
611              console.log(result);
612              reportError('Google reCaptcha thinks this is a bot', 'captcha');
613            } else if (result.success && result.score > 0) {
614              jQuery.ajax({
615                data: jQuery(theForm).serialize(),
616                type: 'POST',
617                // url: 'https://fww.hosted.jacksonriverdev.com/springboard-api/springboard-forms/submit?api_key=de9776fe5fd6cc093e6c455e31608db5&form_id=' + 43,
618                url: 'https://secure.foodandwaterwatch.org/springboard-api/springboard-forms/submit?api_key=de9776fe5fd6cc093e6c455e31608db5&form_id=' + 10362,
619                dataType: 'text',
620                beforeSend: function beforeSend() {// $('.springboard').fadeOut("slow");
621                },
622                success: function success(data) {
623                  ajaxMessageBox.innerHTML = ajaxMessageBox.dataset.success ? ajaxMessageBox.dataset.success : 'Thank you for your submission!';
624                  formBlock.classList.toggle('success');
625                },
626                error: function error(data) {
627                  console.log(data);
628                  reportError(data.responseText, 'springboard');
629                },
630                complete: function complete(data) {// console.log('completion',data);
631                }
632              });
633            }
634          })["catch"](function (error) {
635            console.error('Error:', error);
636            reportError(error, 'captcha');
637          });
638        });
639      });
640    },
641        reportError = function reportError(errorStr, errorSource) {
642      theForm.querySelectorAll('.oops').forEach(function (item) {
643        item.classList.remove('oops');
644      });
645
646      var fixErrorStr = function fixErrorStr() {
647        var problemFieldCount = 0;
648
649        var mailRequired = errorStr.indexOf('Email field is required') > -1,
650            nameRequired = errorStr.indexOf('First Name field is required') > -1,
651            zipRequired = errorStr.indexOf('Postal Code field is required') > -1,
652            validEmail = errorStr.indexOf('Please enter a valid email address') > -1,
653            validity = errorSource.indexOf('validity') > -1,
654            highlightProblemFields = function highlightProblemFields() {
655          var somethingIsHighlighted = [false, []],
656              stopChecking = true;
657
658          var highlight = function highlight(fieldName) {
659            problemFieldCount++;
660            var problemField = theForm.querySelector('input[name="' + fieldName + '"'),
661                fieldWrapper = problemField ? problemField.parentElement : null,
662                pHolderTxt = problemField ? problemField.placeholder : null;
663            if (!fieldWrapper) return;
664            fieldWrapper.classList.toggle('oops');
665            problemField.placeholder = '*REQUIRED';
666            problemField.addEventListener('focus', function () {
667              problemField.placeholder = pHolderTxt;
668            });
669            somethingIsHighlighted[0] = true;
670            somethingIsHighlighted[1].push([problemField, problemField.value]);
671          };
672
673          if (mailRequired || validEmail || validity) {
674            console.log('should be highlighting mail');
675            highlight('mail');
676          }
677
678          if (zipRequired) highlight('zip_postal_code');
679          if (nameRequired) highlight('first_name');
680          if (somethingIsHighlighted[0]) setInterval(function () {
681            if (!somethingIsHighlighted[0]) return;
682            var changeCount = 0;
683            somethingIsHighlighted[1].forEach(function (item) {
684              if (item[0].value === item[1]) return;
685              changeCount++;
686            });
687
688            if (changeCount === somethingIsHighlighted[1].length) {
689              somethingIsHighlighted[0] = false;
690              formBlock.classList.toggle('error');
691            }
692          }, 200);
693        };
694
695        highlightProblemFields();
696        var newErrorStr = 'Please enter the required field';
697        if (!mailRequired && !zipRequired && !validEmail && !nameRequired && !validity) return;else if (problemFieldCount > 1) newErrorStr += 's';else if (validEmail) newErrorStr = 'Please enter a valid email address';else if (validity) newErrorStr = errorStr;
698        errorStr = validity ? newErrorStr : newErrorStr + '.';
699      };
700
701      if (errorSource === 'springboard' || errorSource === 'validity') {
702        fixErrorStr();
703      }
704
705      formBlock.classList.toggle('loading');
706
707      if (formBlock) {
708        if (errorSource === 'captcha') formBlock.classList.add('error-other');
709        formBlock.classList.add('error');
710      }
711
712      if (ajaxMessageBox) {
713        ajaxMessageBox.innerHTML = errorStr;
714      }
715    };
716
717    if (formBlock) formBlock.classList.toggle('loading');
718    sendToValidityThenPost();
719  }; // News type grid pages Featured Article Button 
720
721
722  function goToFeaturedArticle() {
723    var link = document.querySelector('.news-feature li a');
724    if (link && link.href) window.location.href = link.href;
725  }
726
727  var featuredArticleLinks = [document.getElementById('featured-article-link'), document.querySelector('.news-feature')];
728  Array.prototype.forEach.call(featuredArticleLinks, function (item) {
729    if (item) {
730      item.style.cursor = 'pointer';
731      item.addEventListener('click', function (e) {
732        e.preventDefault();
733        goToFeaturedArticle();
734        return false;
735      });
736    }
737  }); // clickable blocks 
738
739  function makeBlocksClickable() {
740    function setBlock(block) {
741      var linkItem = block.querySelector('a');
742      if (!linkItem) return;
743      var link = linkItem.getAttribute('href');
744      var target = !linkItem.getAttribute('target') ? '_self' : linkItem.getAttribute('target');
745      block.addEventListener('click', function (event) {
746        window.open(link, target);
747      });
748    }
749
750    var clickableBlockGroup = document.getElementsByClassName('fwa-clickable-block');
751    if (clickableBlockGroup.length === 0) return;
752    var blocks = [];
753
754    for (var i = 0; i < clickableBlockGroup.length; i++) {
755      blocks.push(clickableBlockGroup[i].getElementsByClassName('slick-slide'));
756      blocks.push(clickableBlockGroup[i].getElementsByClassName('wp-block-group'));
757      blocks.push(clickableBlockGroup[i].getElementsByTagName('li'));
758    }
759
760    for (var i = 0; i < blocks.length; i++) {
761      for (var ii = 0; ii < blocks[i].length; ii++) {
762        setBlock(blocks[i][ii]);
763      }
764    }
765  }
766
767  makeBlocksClickable();
768
769  function showLightBox() {
770    if (getCookie('fwa lightbox')) return;
771    var lightBoxItem = document.querySelector('.fwa-lightbox a');
772    if (!lightBoxItem) return;
773
774    var hideLightBox = function hideLightBox() {
775      bgDiv.style.opacity = '0';
776      lgDiv.style.opacity = '0';
777      setCookie('fwa lightbox', true, 1);
778      setTimeout(function () {
779        bgDiv.remove();
780        lgDiv.remove();
781      }, 2000);
782    },
783        bgDiv = document.createElement('div'),
784        lgDiv = document.createElement('div');
785
786    bgDiv.classList.add('fwa-lightbox-bg');
787    lgDiv.classList.add('fwa-lightbox-wrapper');
788    lightBoxItem.innerHTML += '<div class="close-it">x</div>';
789    lgDiv.append(lightBoxItem);
790    document.body.append(bgDiv);
791    document.body.append(lgDiv);
792    bgDiv.style.transition = 'opacity 2s';
793    lgDiv.style.transition = 'opacity 2s';
794    setTimeout(function () {
795      bgDiv.style.opacity = '.3';
796      lgDiv.style.opacity = '1';
797    }, 100);
798    lgDiv.querySelector('.close-it').addEventListener('click', function (e) {
799      e.preventDefault();
800      hideLightBox();
801    });
802    lgDiv.addEventListener('click', function (e) {
803      if (e.target.nodeName === 'A' || e.target.parentNode.nodeName === 'A') return;
804      e.preventDefault();
805      hideLightBox();
806    });
807
808    document.onkeyup = function (e) {
809      if (e.key === 'Escape') hideLightBox();
810    };
811  }
812
813  showLightBox();
814
815  function showAlert() {
816    if (getCookie('fwa alert')) {
817      return;
818    }
819
820    var alert = document.querySelector('.fwa-alert');
821    if (!alert) return;
822    var alertWrapper = alert.parentElement;
823    alertWrapper.style.height = 'auto';
824    alertWrapper.style.height = alertWrapper.offsetHeight + 'px';
825    alert.querySelector('.close-it').addEventListener('click', function () {
826      alertWrapper.style.height = 0;
827      setCookie('fwa alert', true, 1);
828    });
829  }
830
831  ;
832  showAlert(); // springboard forms
833
834  document.querySelectorAll('form.springboard').forEach(function (form) {
835    form.addEventListener('submit', function (e) {
836      e.preventDefault();
837      var theForm = e.target;
838
839      _this.sendNewsletterSignup(theForm);
840    });
841  });
842  var newsLetterSignupLinks = document.querySelectorAll('.newsletter-signup-link');
843  Array.prototype.forEach.call(newsLetterSignupLinks, function (item) {
844    var theForm = item.closest('form');
845
846    if (theForm) {
847      item.addEventListener('click', function () {
848        window.sendNewsletterSignup(theForm);
849      });
850    }
851  }); // move desktop search modal if alert is visible
852  // set form validation
853
854  function setSearchModal() {
855    var searchForm = document.querySelector('form.search-form');
856    var desktopSearch = document.querySelector('.desktop-search-toggle');
857
858    var searchValidation = function searchValidation() {
859      var searchField = searchForm.querySelector('.search-field');
860
861      if (searchField && searchField.value === '') {
862        searchForm.classList.add('oops');
863        searchField.placeholder = '*REQUIRED';
864        return false;
865      } else return true;
866    };
867
868    if (searchForm) {
869      var toggler = searchForm.querySelector('span.toggle-inner');
870      searchForm.addEventListener('submit', function (event) {
871        if (!searchValidation()) {
872          event.preventDefault();
873          return false;
874        }
875      });
876
877      if (toggler) {
878        toggler.addEventListener('click', function () {
879          if (searchValidation()) searchForm.submit();else return false;
880        });
881      }
882    }
883
884    if (desktopSearch) {
885      desktopSearch.addEventListener('click', function () {
886        var siteHeader = document.querySelector('#site-header');
887        var isSticky = siteHeader ? siteHeader.classList.contains('sticky') : false;
888        var styleAttributes = isSticky ? [siteHeader.style.transition, siteHeader.style.opacity] : null;
889        var alert = document.querySelector('.fwa-alert-wrapper');
890        setTimeout(function () {
891          var searchModal = document.querySelector('.search-modal.active');
892
893          if (isSticky) {
894            siteHeader.classList.add('sticky');
895            siteHeader.style.transition = styleAttributes[0];
896            siteHeader.style.opacity = styleAttributes[1];
897            searchModal.style.top = null;
898          } else if (searchModal && alert && alert.offsetHeight > 0) {
899            searchModal.style.top = alert.offsetHeight + 'px';
900          } else searchModal.style.top = null;
901        }, 50);
902      });
903    }
904  }
905
906  setSearchModal(); // activate footer menu item expand/collapse
907
908  function footerMenuToggle(clickedItem) {
909    Array.prototype.forEach.call(footerMenuTogglers, function (item) {
910      if (clickedItem !== item) item.parentElement.classList.remove('active');
911    });
912    clickedItem.parentElement.classList.toggle('active');
913  }
914
915  var footerMenuTogglers = document.querySelectorAll('#menu-footer > li > span');
916  Array.prototype.forEach.call(footerMenuTogglers, function (item) {
917    item.addEventListener('click', function () {
918      footerMenuToggle(item);
919    });
920  }); // ajax load more helpers 
921
922  window.almComplete = function (alm) {
923    var articles = document.querySelectorAll('.alm-reveal article');
924    Array.prototype.forEach.call(articles, function (item) {
925      if (item.classList.contains('is-clickable')) return;
926      item.classList.add('is-clickable');
927      item.addEventListener('click', function () {
928        var link = item.querySelector('header a');
929        if (link.hasAttribute('href')) window.location = link.href;
930      });
931    });
932  }; // springboard takeover
933  // const takeOver = ()=>{
934  //   const correctPage = document.querySelector('body.postid-3491');
935  //   if(!correctPage)return;
936  //   if(getCookie('givingtuesday'))return;
937  //   const takeOver = document.querySelector('.page-take-over');
938  //   takeOver.style.display = 'flex';
939  //   takeOver.classList.add('active');
940  //   takeOver.querySelector('div a').addEventListener('click',()=>{
941  //     setCookie('givingtuesday',true,1);
942  //     takeOver.classList.remove('active');
943  //     takeOver.style.opacity = "0";
944  //     setTimeout(()=>{
945  //       takeOver.style.display = "none";
946  //     },1000);
947  //   });
948  // };
949  // setTimeout(()=>{
950  //   takeOver();
951  // },50);
952
953});

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.