https://huntingtonsdiseasenews.com/wp-content/plugins/bionews-gf-s…/js/gf-state-refresh.js?ver=1.0.0
1(function () { 2 'use strict'; 3 4 var settings = window.bionewsGfStateRefresh || {}; 5 6 /** 7 * Fetches a fresh state token for the given form and updates the hidden 8 * state input, then invokes the callback regardless of success or failure 9 * so the submission always proceeds. 10 */ 11 function refreshState(form, formId, stateInput, callback) { 12 var data = new FormData(); 13 data.append('action', 'gf_refresh_state'); 14 data.append('form_id', formId); 15 16 fetch(settings.ajaxUrl, { method: 'POST', body: data }) 17 .then(function (r) { return r.json(); }) 18 .then(function (json) { 19 if (json.success && json.data) { 20 stateInput.value = json.data; 21 } 22 }) 23 .catch(function () { 24 // Proceed even if the refresh fails â GF will surface the 25 // validation error to the user as it normally would. 26 }) 27 .finally(callback); 28 } 29 30 /** 31 * Intercept submit button clicks during the capture phase so we run 32 * before Gravity Forms' own onclick handler. On the first click, we 33 * pause, refresh the state token, then re-trigger the click. The 34 * data-gf-state-refreshed flag prevents re-interception on the 35 * re-triggered click. 36 */ 37 document.addEventListener('click', function (e) { 38 var button = e.target.closest('button[type="submit"][id^="gform_submit_button_"]'); 39 if (!button) { 40 return; 41 } 42 43 var form = button.closest('form[id^="gform_"]'); 44 if (!form || form.dataset.gfStateRefreshed) { 45 return; 46 } 47 48 var formId = form.id.replace('gform_', ''); 49 var stateInput = form.querySelector('input[name="state_' + formId + '"]'); 50 51 if (!stateInput || !settings.ajaxUrl) { 52 return; 53 } 54 55 e.preventDefault(); 56 e.stopImmediatePropagation(); 57 58 refreshState(form, formId, stateInput, function () { 59 form.dataset.gfStateRefreshed = '1'; 60 button.click(); 61 }); 62 }, true); 63})();
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.