سامپرواز

انتخاب مبدا

انتخاب تاریخ
۲۳ پرواز یافت شد
// ─── INIT FROM URL (safe: runs after ALL let declarations) ─────────────────── function initFromURL() { const p = new URLSearchParams(window.location.search); // Cities const from = p.get('from'), fromCity = p.get('fromCity'); const to = p.get('to'), toCity = p.get('toCity'); if(from) { sbOriginIata = from; const e=document.getElementById('sb-origin'); if(e) e.textContent = fromCity||from; } if(to) { sbDestIata = to; const e=document.getElementById('sb-dest'); if(e) e.textContent = toCity||to; } // Flight type const type = p.get('type'); if(type) { flightType = type; document.querySelectorAll('.sb-type-btn').forEach(b=>b.classList.remove('active')); const btn = document.getElementById(type==='domestic'?'btn-domestic':'btn-international'); if(btn) btn.classList.add('active'); } // Date const ds = p.get('date'); if(ds) { const pts = ds.split('-'); if(pts.length===3) { const y=parseInt(pts[0]),m=parseInt(pts[1]),d=parseInt(pts[2]); if(!isNaN(y)&&y>1300&&m>=1&&m<=12&&d>=1&&d<=31) { dpYear=y; dpMonth=m; dpDay=d; const el=document.getElementById('sb-date-val'); if(el) el.textContent = toPersian(d)+' '+shamsiMonths[m-1]; } } } // Passengers const adt=parseInt(p.get('adt')), chd=parseInt(p.get('chd')), inf=parseInt(p.get('inf')); if(!isNaN(adt)&&adt>=1) sbPax.adult=adt; if(!isNaN(chd)&&chd>=0) sbPax.child=chd; if(!isNaN(inf)&&inf>=0) sbPax.infant=inf; if(p.get('adt')||p.get('chd')||p.get('inf')) { const ea=document.getElementById('sb-adult-num'); const ec=document.getElementById('sb-child-num'); const ei=document.getElementById('sb-infant-num'); if(ea) ea.textContent=toPersian(sbPax.adult); if(ec) ec.textContent=toPersian(sbPax.child); if(ei) ei.textContent=toPersian(sbPax.infant); updateSbPaxField(); } } initFromURL();