1( function( $ ) { 2const incentiveGroup = [ 3 { 4 name: "Vehicle purchase", 5 display: "Vehicle Tax Credits and Rebates" 6 }, 7 { 8 name: "Charging station", 9 display: "Charging Station Incentives" 10 }, 11 { 12 name: "Electricity", 13 display: "Electricity Discounts" 14 }, 15 { 16 name: "Driving electric", 17 display: "Driving Perks" 18 } 19]; 20 21function loadIncentives(zipcodeform) { 22 var incentivesData = []; 23 $("#incentives-results").remove(); 24 $.ajax({ 25 type: 'POST', 26 url: ajax_object.ajax_url, 27 data : zipcodeform, 28 dataType: 'json', 29 success: function (data, textStatus, request) { 30 var selectedGroup = []; 31 var incentiveResults = ''; 32 if (data.code == 200 && data.incentives.length > 0) { 33 for (var h = 0; h < data.incentives.length; h++) { 34 incentivesData.push(data.incentives[h]); 35 } 36 incentiveGroup.forEach(s => { 37 var IncentiveID = s.name; 38 IncentiveID = IncentiveID.replace(/\s+/g, '-').toLowerCase(); 39 40 selectedGroup = GroupIncArray(incentivesData, s.name); 41 //get only display here 42 if (selectedGroup) { 43 incentiveResults += ` 44 <h2 class="incentive-header">${s.display}</h2>`; 45 if(s.name == 'Vehicle purchase'){ 46 incentiveResults += `<div class="incentive-filter" data-category="${s.name}"> 47 <label for="incentive-filter-list">FILTER BY: </label> 48 <select name="incentive-filter-list" id="credit-rebate-filter-list"> 49 <option value="all">-All-</option> 50 <option value="income-requirement">Income Requirement</option> 51 <option value="used-car-eligible">Used Car Eligible</option> 52 </select> 53 <p>Quickly filter incentive credits and rebates to view by eligibiity requirements (e.g., income, used EV, etc.) to narrow your search.</p> 54</div>`; 55 } 56 incentiveResults += `<div class="incentive-box used-box" id="${IncentiveID}"> 57 ${selectedGroup.map(incentiveTemplate).join("")} 58 </div> 59 <div class="CAdvisor" data-category="${s.name}"> 60 <div class="incentive-title">Home Charging Advisor</div> 61 <div>Find chargers and apply for incentives for charging your EV at home.</div> 62 <div><a class="btn" title="Find Your Home Charger" href="https://homecharging.electricforall.org/" target="_blank" rel="noopener">Find your charger</a></div> 63 </div> 64 `; 65 } 66 }); 67 } 68 else { 69 incentiveResults = ` 70 <p>We could not find any result with the ZIP code supplied. Please try again with a different ZIP code.</p> 71 `; 72 } 73 $("#incentives-form").after(`<div id="incentives-results" class="incentives-results">${incentiveResults}</div>`); 74 }, 75 error: function (request, textStatus, errorThrown) { 76 incentiveResults = `<p>We could not find any result with the ZIP code supplied. Please try again with a different ZIP code.</p>`; 77 $("#incentives-form").after(`<div id="incentives-results">${incentiveResults}</div>`); 78 } 79 }) 80} 81 82function filterCreditsRebates(){ 83 var purchase = $('#vehicle-purchase .incentive'); 84 var crf = $('#credit-rebate-filter-list').val(); 85 purchase.hide(); 86 purchase.filter(function() { 87 if(crf == 'income-requirement'){ 88 if($(this).find('[data-eligibility="true"]').length) 89 return true; 90 else 91 return false; 92 }else if(crf == 'used-car-eligible'){ 93 if($(this).find('[data-used="true"]').length) 94 return true; 95 else 96 return false; 97 }else{ 98 return true; 99 } 100 }).show(); 101} 102 103$(document).ready(function() { 104 if($('#incentives-form #zipcode-input').val()){ 105 var zipcode = $.trim($('#zipcode-input').val()); 106 var zipcodeform = $("#incentives-form").serialize(); 107 loadIncentives(zipcodeform); 108 $.fn.updateZipAddress(zipcode); 109 } 110 $("#incentives-form").submit(function (event) { 111 event.preventDefault(); 112 var zipcode = $.trim($('#zipcode-input').val()); 113 var zipcodeform = $("#incentives-form").serialize(); 114 if (zipcode == "") { 115 alert('Zip code field is required.'); 116 } else { 117 loadIncentives(zipcodeform); 118 $.fn.updateZipAddress(zipcode); 119 } 120 return false; 121 }); 122 $(document).on("change", '#credit-rebate-filter-list', function(event) { 123 filterCreditsRebates(); 124 }); 125}); 126} )( 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.