btn.addEventListener('click',()=>{ document.body.removeChild(back); root.style.display='none'; }); box.appendChild(btn); back.appendChild(box); document.body.appendChild(back); root.style.display='block'; } // Enforce mutual exclusion between IPC Class 3 and No X-Outs function handleMutualExclusion(){ const noX = $('#noXouts'); const ipc = $('#ipc3'); // when selecting yes on one, disable yes on other; if attempted both yes, show modal and revert noX.addEventListener('change',()=>{ if(noX.value==='yes' && ipc.value==='yes'){ // invalid - revert noX to no and show modal noX.value='no'; showModal("IPC Class 3 and No X-Outs cannot both be 'Yes'."); } // toggle other's yes option disabled state const ipcYes = ipc.querySelector('option[value="yes"]'); ipcYes.disabled = (noX.value==='yes'); // show test note $('#noX-note').style.display = (noX.value==='yes')? 'block':'none'; update(); }); ipc.addEventListener('change',()=>{ if(ipc.value==='yes' && noX.value==='yes'){ ipc.value='no'; showModal("IPC Class 3 and No X-Outs cannot both be 'Yes'."); } const noXYes = noX.querySelector('option[value="yes"]'); noXYes.disabled = (ipc.value==='yes'); update(); }); } // upload form behavior: NOTE: you must replace /YOUR_SERVER_ENDPOINT with your real server API. function bindUpload(){ const btn = $('#uploadButton'); btn.addEventListener('click', async ()=>{ const files = $('#u_files').files; const name = $('#u_name').value; const comp = $('#u_company').value; const email = $('#u_email').value; const notes = $('#u_notes').value; // basic validation if(!email){ alert('Please enter contact email before uploading.'); return; } // create FormData const fd = new FormData(); fd.append('name', name); fd.append('company', comp); fd.append('email', email); fd.append('notes', notes); // attach current quote summary (as JSON) const s = getState(); const c = calc(s); fd.append('quote', JSON.stringify({specs:s,calc:c})); for(let i=0;i{ el.addEventListener('input', update); el.addEventListener('change', update); }); handleMutualExclusion(); bindUpload(); } function update(){ const s = getState(); const c = calc(s); render(s,c); } if(document.readyState==='loading') document.addEventListener('DOMContentLoaded', ()=>{ bind(); update(); }); else { bind(); update(); } })();