1jQuery( document ).ready( function($) { 2 3 var data_table; 4 var percolation_rate_selected = 0; 5 // console.log(percolation_rate_selected); 6 7 $.ajax({ 8 async: false, 9 url: "/wp-content/themes/Avada-Child-Theme/assets/json/perculation-rates.json", 10 dataType: "json", 11 method: "GET", 12 success: function(data) { 13 data_table = data.data[0]; 14 } 15 }); 16 // console.log(data_table[3]["1000"]["Chambers"]); 17 18 $(".fixture-type").on("change", function() { 19 var fixture_unit = parseInt($(this).val(), 10), 20 unit = parseInt($(this).parent().parent().find("td.center span.unit").text(),10), 21 calculated_total; 22 23 // console.log(unit); 24 if($(this).val().length < 1) { 25 alert("Please enter a value in " + $(this).attr('name')); 26 location.reload(); 27 28 } else if (isNaN($(this).val())) { 29 alert("Please enter a valid number in " + $(this).attr('name')); 30 location.reload(); 31 32 } else if ($(this).val() < 0) { 33 alert("Please enter a valid number in " + $(this).attr('name')); 34 location.reload(); 35 36 } else { 37 calculated_total = calculate_fixture_unit(fixture_unit, unit); 38 39 $(this).parent().parent().find(".fixture-unit-total").text(calculated_total).change(); 40 } 41 }); 42 43 $(".fixture-unit-total").on("change", function() { 44 45 var fixture_units = $(".fixture-unit-total"), 46 p3 = $(this).parent().parent().parent(), 47 total_fixtures_units = 0, 48 percolation_rate_selected = $("#percolation-rate option:selected").val(); 49 50 total_fixtures_units = calculate_fixture_units_total(fixture_units); 51 52 p3.find("span.total-fixtures").text(total_fixtures_units); 53 54 propagate_septic_system_sizing(total_fixtures_units, percolation_rate_selected, p3); 55 }); 56 57 $("#percolation-rate").on("change", function() { 58 59 var fixture_units = $(".fixture-unit-total"), 60 p3 = $(this).parent().parent().parent(), 61 total_fixtures_units = 0, 62 percolation_rate_selected = $("#percolation-rate option:selected").val(); 63 64 total_fixtures_units = calculate_fixture_units_total(fixture_units); 65 66 p3.find("span.total-fixtures").text(total_fixtures_units); 67 68 propagate_septic_system_sizing(total_fixtures_units, percolation_rate_selected, p3); 69 }); 70 71 $("input[type=reset]").on("click", function() { 72 var fixture_units = $(".fixture-unit-total"), 73 p3 = $(this).parent().parent().parent(); 74 75 reset_form(fixture_units, p3); 76 }); 77 78 function calculate_fixture_unit(fixture_unit, unit) { 79 return fixture_unit * unit; 80 } 81 82 function calculate_fixture_units_total(elems) { 83 var total_fixtures_units = 0; 84 85 elems.each(function() { 86 total_fixtures_units += parseInt($(this).text(),10); 87 }); 88 89 return total_fixtures_units; 90 } 91 92 function propagate_septic_system_sizing(total_fixtures_units, percolation_rate_selected, p) { 93 switch(true) { 94 case (total_fixtures_units <= 20): 95 p.find("#min-septic-tank").text(1000); 96 p.find("#min-leach-field-pipe-gravel") 97 .text(data_table[percolation_rate_selected]["1000"]["Pipe and Gravel"]); 98 p.find("#min-leach-field-chambers") 99 .text(data_table[percolation_rate_selected]["1000"]["Chambers"]); 100 break; 101 case (total_fixtures_units >= 21 && total_fixtures_units <= 25): 102 p.find("#min-septic-tank").text(1200); 103 p.find("#min-leach-field-pipe-gravel") 104 .text(data_table[percolation_rate_selected]["1200"]["Pipe and Gravel"]); 105 p.find("#min-leach-field-chambers") 106 .text(data_table[percolation_rate_selected]["1200"]["Chambers"]); 107 break; 108 case (total_fixtures_units >= 26 && total_fixtures_units <= 35): 109 p.find("#min-septic-tank").text(1500); 110 p.find("#min-leach-field-pipe-gravel") 111 .text(data_table[percolation_rate_selected]["1500"]["Pipe and Gravel"]); 112 p.find("#min-leach-field-chambers") 113 .text(data_table[percolation_rate_selected]["1500"]["Chambers"]); 114 break; 115 case (total_fixtures_units >= 36 && total_fixtures_units <= 45): 116 p.find("#min-septic-tank").text(2000); 117 p.find("#min-leach-field-pipe-gravel") 118 .text(data_table[percolation_rate_selected]["2000"]["Pipe and Gravel"]); 119 p.find("#min-leach-field-chambers") 120 .text(data_table[percolation_rate_selected]["2000"]["Chambers"]); 121 break; 122 case (total_fixtures_units >= 46 && total_fixtures_units <= 55): 123 p.find("#min-septic-tank").text(2250); 124 p.find("#min-leach-field-pipe-gravel") 125 .text(data_table[percolation_rate_selected]["2250"]["Pipe and Gravel"]); 126 p.find("#min-leach-field-chambers") 127 .text(data_table[percolation_rate_selected]["2250"]["Chambers"]); 128 break; 129 case (total_fixtures_units >= 56 && total_fixtures_units <= 60): 130 p.find("#min-septic-tank").text(2500); 131 p.find("#min-leach-field-pipe-gravel") 132 .text(data_table[percolation_rate_selected]["2500"]["Pipe and Gravel"]); 133 p.find("#min-leach-field-chambers") 134 .text(data_table[percolation_rate_selected]["2500"]["Chambers"]); 135 break; 136 default: 137 p.find("#min-septic-tank").text('Out of Range'); 138 p.find("#min-leach-field-pipe-gravel").text('Out of Range'); 139 p.find("#min-leach-field-chambers").text('Require Input from PE'); 140 } 141 } 142 143 function reset_form(el, p) { 144 145 el.each(function() { 146 $(this).text(0); 147 }); 148 149 p.find("span.total-fixtures").text(0); 150 p.find("span.min-septic-tank").text(0); 151 p.find("span.min-leach-field-pipe-gravel").text(0); 152 p.find("span.min-leach-field-chambers").text(0); 153 } 154 });
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.