1(function ($) { 2 "use strict"; 3 4 var billing = 5 typeof wcDonationCheckoutPrefill !== "undefined" && 6 wcDonationCheckoutPrefill.billing 7 ? wcDonationCheckoutPrefill.billing 8 : {}; 9 10 if (!billing || !Object.keys(billing).length) { 11 return; 12 } 13 14 function triggerInput(el) { 15 if (!el) { 16 return; 17 } 18 el.dispatchEvent(new Event("input", { bubbles: true })); 19 el.dispatchEvent(new Event("change", { bubbles: true })); 20 } 21 22 function setIfEmpty(selectors, value) { 23 if (!value) { 24 return; 25 } 26 for (var i = 0; i < selectors.length; i++) { 27 var nodes = document.querySelectorAll(selectors[i]); 28 for (var j = 0; j < nodes.length; j++) { 29 var el = nodes[j]; 30 if (!el || (el.value && String(el.value).trim() !== "")) { 31 continue; 32 } 33 el.value = value; 34 triggerInput(el); 35 } 36 } 37 } 38 39 function applyPrefill() { 40 var fields = { 41 billing_first_name: [ 42 "#billing_first_name", 43 'input[name="billing_first_name"]', 44 'input[id="billing-first_name"]', 45 'input[id="billing-first-name"]', 46 '.wc-block-components-text-input input[id*="first"]', 47 ], 48 billing_last_name: [ 49 "#billing_last_name", 50 'input[name="billing_last_name"]', 51 'input[id="billing-last_name"]', 52 'input[id="billing-last-name"]', 53 ], 54 billing_email: [ 55 "#billing_email", 56 'input[name="billing_email"]', 57 'input[id="billing-email"]', 58 'input[type="email"][id*="billing"]', 59 ], 60 billing_phone: [ 61 "#billing_phone", 62 'input[name="billing_phone"]', 63 'input[id="billing-phone"]', 64 'input[type="tel"][id*="billing"]', 65 ], 66 billing_address_1: [ 67 "#billing_address_1", 68 'input[name="billing_address_1"]', 69 'input[id="billing-address_1"]', 70 'input[id="billing-address-1"]', 71 ], 72 billing_city: [ 73 "#billing_city", 74 'input[name="billing_city"]', 75 'input[id="billing-city"]', 76 ], 77 billing_postcode: [ 78 "#billing_postcode", 79 'input[name="billing_postcode"]', 80 'input[id="billing-postcode"]', 81 ], 82 }; 83 84 Object.keys(fields).forEach(function (key) { 85 if (billing[key]) { 86 setIfEmpty(fields[key], billing[key]); 87 } 88 }); 89 } 90 91 $(function () { 92 applyPrefill(); 93 setTimeout(applyPrefill, 400); 94 setTimeout(applyPrefill, 1200); 95 }); 96})(jQuery);
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.