diff --git a/site/search.html b/site/search.html
index f194bfa..7ff4136 100644
--- a/site/search.html
+++ b/site/search.html
@@ -408,10 +408,9 @@ function toolReorg(){ return `
๐ฏ Filters
Price โค
Year
-
๐ฆ Distribution Target
-
Start
-
Count
-
Slots
+
๐ฆ Distribution Target โ sorted AโZ, poured into these crates in order
+
Target crates
+ Slots/crate
@@ -432,7 +431,8 @@ async function reorgScan(){
ST.pick=ids; renderPick();
const d=await post('/nav/reorg/scan',{crate_ids:ids}); roItems=d.items||[];
$('#roScanOut').innerHTML=`
${d.count} items ยท ${ids.length} crate(s)`;
- $('#roStart').value=ids[0]; $('#roCount').value=ids.length; $('#roPlanArea').style.display='block';
+ // targets default to the picked crates sorted ascending (4,3,2,1 โ fill 1,2,3,4) โ editable
+ $('#roTargets').value=[...new Set(ids)].sort((a,b)=>a-b).join(', '); $('#roPlanArea').style.display='block';
}
function roCmp(m){ return (a,b)=>{
if(m==='title') return (a.title||'').localeCompare(b.title||'');
@@ -445,15 +445,19 @@ function reorgPlan(){
const pmax=parseFloat($('#roPmax').value)||null, ymin=parseInt($('#roYmin').value)||null, ymax=parseInt($('#roYmax').value)||null;
let items=roItems.filter(i=> (pmax==null||(i.price!=null&&i.price<=pmax)) && (ymin==null||(i.year&&i.year>=ymin)) && (ymax==null||(i.year&&i.year<=ymax)) );
items.sort(roCmp($('#roSort').value));
- const start=parseInt($('#roStart').value), count=parseInt($('#roCount').value)||1, slots=parseInt($('#roSlots').value)||50;
- const targets=[]; for(let i=0;i
set at least one target crate '; return; }
roMoves=[]; roLeftovers=[]; let ti=0, slot=1;
for(const it of items){
if(ti>=targets.length){ roLeftovers.push(it); continue; }
roMoves.push({sku:it.sku, new_crate_id:targets[ti], new_slot:slot, title:it.title, artist:it.artist, from:`${it.crate_id||'โ'}/${it.slot||'โ'}`});
slot++; if(slot>slots){ slot=1; ti++; }
}
- $('#roPlanOut').innerHTML=`
${roMoves.length} โ crates ${targets.join(', ')}${roLeftovers.length?' ยท '+roLeftovers.length+' leftover':''}
`
+ const perT={}; roMoves.forEach(m=>perT[m.new_crate_id]=(perT[m.new_crate_id]||0)+1);
+ const summary=targets.map(t=>`
${t}: ${perT[t]||0}`).join(' ยท ');
+ $('#roPlanOut').innerHTML=`
${roMoves.length} items${roLeftovers.length?' ยท '+roLeftovers.length+' leftover (need more crates)':''}
`
+ +`
into โ ${summary}
`
+'
| โ Crate/Slot | Title | Artist | From |
'
+roMoves.slice(0,300).map(m=>`| ${m.new_crate_id} / ${m.new_slot} | ${esc(m.title||m.sku)} | ${esc(m.artist||'')} | ${esc(m.from)} |
`).join('')
+(roMoves.length>300?`| โฆ+${roMoves.length-300} more |
`:'')+'
';