1(() => { 2 const getMeniuZilei = () => 3 window._meniu_zilei || 4 (window.products || []).find((p) => String(p.id).startsWith("meniu_zilei")); 5 6 const dlg = document.getElementById("productModal"); 7 if (!dlg) return; 8 9 function renderRadioGroup({ name, label, options = [] }) { 10 if (!Array.isArray(options) || options.length === 0) return ""; 11 const items = options 12 .map( 13 (opt) => ` 14 <label class="pd-radio"> 15 <input type="radio" name="${name}" value="${opt}"> 16 <span>${opt}</span> 17 </label>` 18 ) 19 .join(""); 20 21 return ` 22 <div class="pd-block mz-group"> 23 <div class="mz-group-title">${label} <span class="mz-required">(obligatoriu)</span></div> 24 <div class="mz-options">${items}</div> 25 </div> 26 `; 27 } 28 29 function openMeniuZileiModal() { 30 const p = getMeniuZilei(); 31 if (!p) return; 32 33 const img = document.getElementById("pdImg"); 34 const title = document.getElementById("pdTitle"); 35 const desc = document.getElementById("pdDesc"); 36 if (img) img.src = p.img || ""; 37 if (title) title.textContent = p.name || "Meniul Zilei"; 38 if (desc) desc.textContent = p.desc || ""; 39 40 ["pdSizes", "pdSauces", "pdNutri"].forEach((id) => { 41 const el = document.getElementById(id); 42 if (el) el.hidden = true; 43 }); 44 45 const extras = document.getElementById("pdExtras"); 46 const supe = p.variante?.supe || []; 47 const feluri = p.variante?.feluri || []; 48 const bauturi = p.variante?.bauturi || []; 49 50 const html = 51 renderRadioGroup({ name: "mz-supa", label: "Supe/Ciorbe", options: supe }) + 52 renderRadioGroup({ name: "mz-fel", label: "Fel principal", options: feluri }) + 53 renderRadioGroup({ name: "mz-baut", label: "BÄuturÄ", options: bauturi }); 54 55 if (extras) { 56 extras.innerHTML = html; 57 extras.hidden = false; 58 } 59 60 const priceEl = document.getElementById("pdPrice"); 61 if (priceEl) { 62 const price = Number(p.price || 0); 63 priceEl.textContent = `${price.toFixed(2).replace(".", ",")} lei`; 64 } 65 66 const addBtn = document.getElementById("pdAdd"); 67 if (addBtn) { 68 // DacÄ e epuizat, blocÄm butonul 69 if (p.sold_out === true || p.stock === false) { 70 addBtn.disabled = true; 71 addBtn.textContent = "Stoc epuizat"; 72 addBtn.classList.add("btn-disabled"); 73 addBtn.onclick = null; 74 } else { 75 addBtn.disabled = false; 76 addBtn.textContent = "AdaugÄ Ã®n coÈ"; 77 addBtn.classList.remove("btn-disabled"); 78 addBtn.onclick = () => { 79 const sup = document.querySelector('input[name="mz-supa"]:checked'); 80 const fel = document.querySelector('input[name="mz-fel"]:checked'); 81 const bau = document.querySelector('input[name="mz-baut"]:checked'); 82 83 if (!sup || !fel || !bau) { 84 alert("Te rugÄm sÄ alegi o opÈiune pentru SupÄ, Fel principal Èi BÄuturÄ."); 85 return; 86 } 87 88 const parts = [ 89 `SupÄ: ${sup.value}`, 90 `Fel: ${fel.value}`, 91 `BÄuturÄ: ${bau.value}`, 92 ]; 93 const variantText = parts.join(" | "); 94 95 if (typeof addToCart === "function") { 96 addToCart(p.id, 1, variantText, p.price); 97 } 98 dlg.close(); 99 }; 100 } 101 } 102 103 dlg.showModal(); 104 } 105 106 // Deschidere pe card Èi pe butonul AdaugÄ 107 document.addEventListener("click", (e) => { 108 const openEl = e.target.closest("[data-open]"); 109 if (openEl) { 110 const id = openEl.getAttribute("data-open") || ""; 111 if (id.startsWith("meniu_zilei")) { 112 e.preventDefault(); 113 openMeniuZileiModal(); 114 } else if (id.startsWith("vedeta_pranzului")) { 115 e.preventDefault();
116 openVedetaPranzuluiModal(); 117 } 118 } 119 const addBtn = e.target.closest("[data-add]"); 120 if (addBtn) { 121 const id = addBtn.getAttribute("data-add") || ""; 122 if (id.startsWith("meniu_zilei")) { 123 e.preventDefault(); 124 openMeniuZileiModal(); 125 } else if (id.startsWith("vedeta_pranzului")) { 126 e.preventDefault(); 127 openVedetaPranzuluiModal(); 128 } 129 } 130 }); 131 132 // ââ Vedeta Prânzului âââââââââââââââââââââââââââââââââââââââââââââââââââââ 133 134 function getVedetaPranzului() { 135 return ( 136 window._vedeta_pranzului || 137 (window.products || []).find((p) => String(p.id).startsWith("vedeta_pranzului")) 138 ); 139 } 140 141 function openVedetaPranzuluiModal() { 142 const p = getVedetaPranzului(); 143 if (!p) return; 144 145 const img = document.getElementById("pdImg"); 146 const title = document.getElementById("pdTitle"); 147 const desc = document.getElementById("pdDesc"); 148 if (img) img.src = p.img || ""; 149 if (title) title.textContent = p.name || "Vedeta Prânzului"; 150 if (desc) desc.textContent = p.desc || ""; 151 152 ["pdSizes", "pdSauces", "pdNutri"].forEach((id) => { 153 const el = document.getElementById(id); 154 if (el) el.hidden = true; 155 }); 156 157 const feluri = p.variante?.feluri || []; 158 const bauturi = p.variante?.bauturi || []; 159 const pretBautura = Number(p.variante?.pret_bautura ?? 2.5); 160 const pretSgr = Number(p.variante?.pret_sgr ?? 0.5); 161 162 const felItems = feluri.map((opt) => ` 163 <label class="pd-radio"> 164 <input type="radio" name="vp-fel" value="${opt}"> 165 <span>${opt}</span> 166 </label>`).join(""); 167 168 const bauturiItems = bauturi.map((opt) => ` 169 <label class="pd-radio"> 170 <input type="radio" name="vp-baut" value="${opt}" data-extra="${pretBautura}"> 171 <span>${opt} <small style="color:#fbbf24; font-weight:600">(+${pretBautura.toFixed(2).replace(".", ",")} lei + SGR ${pretSgr.toFixed(2).replace(".", ",")} lei)</small></span> 172 </label>`).join(""); 173 174 const html = 175 (feluri.length ? ` 176 <div class="pd-block mz-group"> 177 <div class="mz-group-title">Fel principal <span class="mz-required">(obligatoriu)</span></div> 178 <div class="mz-options">${felItems}</div> 179 </div>` : "") + 180 (bauturi.length ? ` 181 <div class="pd-block mz-group"> 182 <div class="mz-group-title">BÄuturÄ <span style="color:#fbbf24;font-weight:500;font-size:0.9em">(opÈional)</span></div> 183 <div class="mz-options"> 184 <label class="pd-radio"> 185 <input type="radio" name="vp-baut" value="" checked> 186 <span>FÄrÄ bÄuturÄ</span> 187 </label> 188 ${bauturiItems} 189 </div> 190 </div>` : ""); 191 192 const extras = document.getElementById("pdExtras"); 193 if (extras) { 194 extras.innerHTML = html; 195 extras.hidden = false; 196 } 197 198 const basePrice = Number(p.price || 0); 199 const priceEl = document.getElementById("pdPrice"); 200 201 function updateVPPrice() { 202 const sel = extras?.querySelector('input[name="vp-baut"]:checked'); 203 const extra = (sel && sel.value) ? Number(sel.dataset.extra || 0) : 0; 204 // bÄutura adaugÄ pretBautura; SGR (pretSgr) e adÄugat automat de updateSGR() 205 if (priceEl) priceEl.textContent = `${(basePrice + extra).toFixed(2).replace(".", ",")} lei`; 206 } 207 updateVPPrice(); 208 extras?.querySelectorAll('input[name="vp-baut"]').forEach((el) => 209 el.addEventListener("change", updateVPPrice) 210 ); 211 212 const addBtn = document.getElementById("pdAdd"); 213 if (addBtn) { 214 if (p.sold_out === true || p.stock === false) { 215 addBtn.disabled = true; 216 addBtn.textContent = "Stoc epuizat"; 217 addBtn.classList.add("btn-disabled"); 218 addBtn.onclick = null; 219 } else { 220 addBtn.disabled = false; 221 addBtn.textContent = "AdaugÄ Ã®n coÈ"; 222 addBtn.classList.remove("btn-disabled"); 223 addBtn.onclick = () => { 224 const fel = extras?.querySelector('input[name="vp-fel"]:checked'); 225 if (!fel) { 226 alert("Te rugÄm sÄ alegi o opÈiune pentru Fel principal."); 227 return; 228 } 229 const bau = extras?.querySelector('input[name="vp-baut"]:checked'); 230 const hasDrink = bau && bau.value; 231 // PreÈul bÄuturii (fÄrÄ SGR â SGR se adaugÄ automat de updateSGR) 232 const drinkExtra = hasDrink ? Number(bau.dataset.extra || 0) : 0; 233 const finalPrice = basePrice + drinkExtra; 234 235 const parts = [`Fel: ${fel.value}`]; 236 if (hasDrink) parts.push(`BÄuturÄ: ${bau.value}`); 237 const variantText = parts.join(" | "); 238 239 if (typeof addToCart === "function") { 240 addToCart(p.id, 1, variantText, finalPrice); 241 } 242 dlg.close(); 243 }; 244 } 245 } 246 247 dlg.showModal(); 248 } 249})();
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.