(function(){ "use strict"; var RATES={sandy:{lime:40,sulfur:8},loam:{lime:70,sulfur:12},clay:{lime:100,sulfur:18}}; function num(v,d){v=parseFloat(v);return isFinite(v)?v:d;} /* Pure โ€” node-tested. diff capped at 1.5 units per application. */ function phAmendment(areaSqFt,currentPh,targetPh,texture){ var r=RATES[texture]||RATES.loam,diff=targetPh-currentPh; if(Math.abs(diff)<0.05)return {material:null,lbs:0,units:0,capped:false}; var capped=Math.abs(diff)>1.5,units=capped?1.5*Math.sign(diff):diff; var material=diff>0?"lime":"sulfur", lbs=r[material]*Math.abs(units)*areaSqFt/1000; return {material:material,lbs:+lbs.toFixed(1),units:+Math.abs(units).toFixed(1),capped:capped, name:material==="lime"?"ground limestone":"elemental sulfur"}; } function render(){ var r=phAmendment(num(document.getElementById("ppPhArea").value,100), num(document.getElementById("ppPhCur").value,5.8), num(document.getElementById("ppPhTgt").value,6.5), document.getElementById("ppPhTex").value), el=document.getElementById("ppPhResults"),h=""; if(!r.material){ h='
No change needed
Your pH is already at target. โœ…
'; }else{ h='
'+r.lbs+' lbs
'+ '
of '+r.name+' for '+num(document.getElementById("ppPhArea").value,100)+' sq ft
'+ '
๐Ÿงช Rough estimate โ€” get a soil test before buying in bulk.
'; if(r.capped)h+='
โš ๏ธ That\'s a big swing: apply for 1.5 pH units now ('+r.lbs+' lbs), retest, then adjust again next season.
'; } el.innerHTML=h; } ["ppPhCur","ppPhTgt","ppPhArea","ppPhTex"].forEach(function(id){ document.getElementById(id).addEventListener("input",render); document.getElementById(id).addEventListener("change",render); }); render(); if(typeof module!=="undefined"){module.exports={phAmendment:phAmendment,RATES:RATES};} })();