[ASL_STORELOCATOR]
Start Adventure
const $=id=>root.querySelector("#"+id);
(function buildMenu(){
for(const g in DESTINATIONS){
const og=document.createElement("optgroup");
og.label=g;
DESTINATIONS[g].forEach(d=>{
const o=document.createElement("option");
o.value=d.miles;
o.textContent=d.name+" ("+d.miles+" mi)";
og.appendChild(o);
});
$("preset").appendChild(og);
}
})();
function updateIncluded(){
$("included").value=(Math.max(3,$("nights").value)+1)*DAILY_MILES+" miles";
}
$("nights").oninput=updateIncluded;
updateIncluded();
root.querySelectorAll("input[name=mode]").forEach(r=>{
r.onchange=()=>{
$("preset").disabled=r.value==="custom";
$("custom").disabled=r.value!=="custom";
};
});
$("start").onclick=function(){
const totalDays=Number($("nights").value)+1;
const mpg=Number($("van").value);
const gas=Number($("gas").value);
const miles=(root.querySelector("input[name=mode]").value==="custom")
?Number($("custom").value)
($("preset").value);
// SEND DATA TO ANIMATION
window.dispatchEvent(new CustomEvent("VANDER_START",{detail:{totalDays,miles,mpg,gas}}));
$("form").style.display="none";
// CALCULATE REPORT
const included=totalDaysDAILY_MILES;
const diff=Math.round(miles-included);
const fuel=miles/mpggas;
$("report").style.display="block";
$("r1").textContent="Trip Miles: "+Math.round(miles);
$("r2").textContent="Included: "+included;
$("r3").textContent=diff>0?"Overage: $"+(diff*.40).toFixed(2):"Mileage buffer remaining";
$("r4").textContent="Fuel Est: $"+fuel.toFixed(2);
};
})();




