'; return; } empty.style.display = 'none'; content.style.display = ''; document.getElementById('out-cbm').textContent = fmt(totalCbm, 4); document.getElementById('out-unit-cbm').textContent = fmt(unitCbm, 4); document.getElementById('out-total-wt').textContent = totalWt > 0 ? fmt(totalWt, 1) + ' kg' : 'β'; document.getElementById('out-chw').textContent = totalWt > 0 || totalCbm > 0 ? fmt(chw, 1) + ' kg' : 'β'; document.getElementById('out-qty').textContent = Math.round(qty).toLocaleString(); // Containers document.getElementById('con-rows').innerHTML = containers.map(c => { const pct = totalCbm / c.cap * 100; const fillPct = Math.min(pct, 100); const needed = Math.ceil(totalCbm / c.cap); const over = pct > 100; const color = over ? '#E6212A' : c.color; return `
${c.icon}
${fmt(pct, 1)}%
${needed} container${needed > 1 ? 's' : ''}
`; }).join(''); } /* ββ Multi-item βββββββββββββββββββββββββββββββββββββββββββ */ function addItem() { items.push({ id: iid++, name: '', l: '', w: '', h: '', qty: 1 }); renderItems(); } function removeItem(id) { items = items.filter(i => i.id !== id); renderItems(); } function setField(id, f, v, el) { const item = items.find(i => i.id === id); if (item) { item[f] = v; // renderItems(); updateItemCBM(el.closest('.item-row'), item); // β
ζ΄ζ°ζ»ζ° updateTotal(); } } function renderItems() { const list = document.getElementById('items-list'); list.innerHTML = items.map(item => { const l = parseFloat(item.l) || 0; const w = parseFloat(item.w) || 0; const h = parseFloat(item.h) || 0; const q = parseFloat(item.qty) || 1; const cbm = (l / 100) * (w / 100) * (h / 100) * q; const cbmStr = cbm > 0 ? fmt(cbm, 4) : 'β'; return `
`; }).join(''); const total = items.reduce((s, item) => { const l = parseFloat(item.l) || 0, w = parseFloat(item.w) || 0, h = parseFloat(item.h) || 0, q = parseFloat(item.qty) || 1; return s + (l / 100) * (w / 100) * (h / 100) * q; }, 0); document.getElementById('multi-total').textContent = total > 0 ? fmt(total, 4) + ' mΒ³' : 'β'; } function updateItemCBM(row, item) { const l = parseFloat(item.l) || 0; const w = parseFloat(item.w) || 0; const h = parseFloat(item.h) || 0; const q = parseFloat(item.qty) || 1; const cbm = (l / 100) * (w / 100) * (h / 100) * q; const cbmStr = cbm > 0 ? fmt(cbm, 4) : 'β'; row.querySelector('.item-cbm').textContent = cbmStr; } function updateTotal() { const total = items.reduce((s, item) => { const l = parseFloat(item.l) || 0; const w = parseFloat(item.w) || 0; const h = parseFloat(item.h) || 0; const q = parseFloat(item.qty) || 1; return s + (l / 100) * (w / 100) * (h / 100) * q; }, 0); document.getElementById('multi-total').textContent = total > 0 ? fmt(total, 4) + ' mΒ³' : 'β'; } /* ββ Init βββββββββββββββββββββββββββββββββββββββββββββββββ */ addItem(); addItem();