1(function(){ 2 function esc(s){ return String(s||'').replace(/[&<>"']/g, m=>({ '&':'&','<':'<','>':'>','"':'"',"'":''' }[m])); } 3 function getVariantSummaryText(){ 4 const vs = document.getElementById('pd-variant-summary'); 5 if (!vs) return ''; 6 const items = Array.from(vs.querySelectorAll('.vs-item strong')).map(el => el.textContent.trim()).filter(Boolean); 7 return items.length ? items.join(' / ') : ''; 8 } 9 window.addToCartSubmit = async function(e, productId){ 10 e.preventDefault(); 11 try { 12 const form = e.target; 13 const qty = parseInt(form.querySelector('[name=qty]')?.value || '1', 10) || 1; 14 const variantId = parseInt(document.getElementById('pd-variant-id')?.value || '0', 10) || 0; 15 await (window.addToCart ? window.addToCart(productId, qty, variantId) : Promise.reject(new Error('addToCart tidak tersedia'))); 16 17 if (window.PlazaAnalytics) { 18 window.PlazaAnalytics.track('add_to_cart', { slug: String(window._pit_slug || '') }); 19 } 20 21 const name = (window.PD_NAME !== undefined) ? String(window.PD_NAME) : (document.getElementById('pd-title')?.textContent || ''); 22 const sku = (function(){ const el=document.getElementById('pd-sku'); return el?el.textContent.trim(): (window.PD_SKU||''); })(); 23 const variantText = getVariantSummaryText(); 24 25 if (window.showToast) { 26 window.showToast({ 27 type: 'success', 28 title: 'Berhasil ditambahkan ke Keranjang', 29 message: `<strong>${esc(name)}</strong>${variantText?` ÷ <em>${esc(variantText)}</em>`:''}<br>SKU: ${esc(sku)} ÷ Qty: ${qty}`, 30 duration: 5000, 31 actions: [ 32 { label: 'Lihat Keranjang', onClick: ()=> { window.location.href = '/keranjang'; } }, 33 { label: 'Lanjut Belanja', variant: 'alt', onClick: ()=>{} } 34 ] 35 }); 36 } 37 } catch (err) { 38 if (window.showToast) { 39 window.showToast({ type:'warn', title:'Gagal menambahkan', message: String(err?.message||'Terjadi kesalahan'), duration: 4500 }); 40 } else { 41 console.error(err); 42 } 43 } 44 return false; 45 }; 46})();
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.