Spaces:
Running
Running
Transaction as multi-select axis (none/for sale/wanted/rent/lost/found/stolen); retire rentals and lost-found subtypes; add goods/property; animals/livestock no longer encodes sale
Browse files102 unmodified lines10310410510610710810911041 unmodified lines15215315415515615748 unmodified lines20620720820921021121221321421521610 unmodified lines2272282292302312326 unmodified lines239240241242243244245246247248249250251252253103 unmodified lines35735835936036136236332 unmodified lines39639739839940040116 unmodified lines41841942042142242342442542642742842943043150 unmodified lines482483484485486487488185 unmodified lines674675676677678679680102 unmodified lines<input id="f_unit" type="number" min="1" step="1"/><button id="linkunit" class="secondary" style="margin-top:6px;width:100%">Link selected boxes (u)</button><div id="txnrow" style="display:none"><label>Transaction <span class="hint">(ads & legal notices)</span></label><select id="f_txn"><option>for sale</option><option>wanted</option><option>rent</option><option>lost</option><option>found</option><option>stolen</option></select></div><label>Confidence</label><select id="f_conf"><option>certain</option><option>unsure</option></select><button id="del" class="secondary" style="margin-top:12px;background:#8a2b2b">Delete box</button>41 unmodified lines"Date":"Publication Metadata" };// Renamed subtypes: old -> new, applied on load for the same reason.const SUB_ALIAS = { "extract from another paper":"from another paper","volume/number line":"volume/whole number" };const DEFS = {"Masthead/Nameplate":"The paper's title banner (e.g. PORTLAND GAZETTE).",48 unmodified lines"Jokes/Humor":["anecdote/jest","epigram","satire/burlesque","other/uncertain"],"Death/Marriage notices":["death/obituary","marriage","birth","combined vital-record column","other/uncertain"],"Advertisement":["patent","runaway (servant/enslaved person)","slave sale/hire","dry-goods/mercantile","auction/vendue (public sale)","private sale","real estate/land","estate/probate notice","rentals","lottery","shipping/freight/stage","help wanted/labor","lost/found animals","lost/found people","lost/found property","books/printing/self-promotion","financial/stockholder/bank","public/official notice","professional services","domestic/marital notice","education/school","entertainment/exhibition","animals/livestock for sale","hospitality (tavern/inn/coffeehouse)","wholesale","retail","date","name","other/uncertain"],"Legal/Official notice":["sheriff's sale","estate/probate notice","court order/summons","notice to creditors","tax/collector's notice","commissioners'/trustees' notice","bankruptcy/insolvency","other/uncertain"],10 unmodified linesconst subsFor = t => SUBTYPES_BY_TYPE[t] || [];// Transaction mode is a separate axis from subtype, and only these types take one.const TXN_TYPES = new Set(["Advertisement","Legal/Official notice"]);const wantsTxn = b => b.types.some(t=>TXN_TYPES.has(t));const SUBDEFS = {"sheriff's sale":"Court-ordered sale by the sheriff. Publication is legally compelled, so this is a Legal notice, not a paid ad.",6 unmodified lines"patent":"Patent medicines / remedies.","runaway (servant/enslaved person)":"Seeking escaped servants / enslaved people.","slave sale/hire":"Sale or hire of enslaved people.","dry-goods/mercantile":"Merchants selling goods.","real estate/land":"Land or property for sale.","estate/probate notice":"Settling estates (often also Legal).","rentals":"To-let / lease.","lottery":"Lottery schemes or tickets.","shipping/freight/stage":"Vessels, freight, stage lines.","help wanted/labor":"Seeking apprentices / workers.","lost/found animals":"Strayed / found livestock.","lost/found people":"Missing persons.","lost/found property":"Lost items / rewards.","books/printing/self-promotion":"Books, or the printer's own services.","financial/stockholder/bank":"Banks, stock, financial notices.","public/official notice":"Public meeting / official matter (advertised).","professional services":"Doctors, lawyers, tradesmen.","domestic/marital notice":"Elopement / 'will not pay her debts' / family disclaimers.","education/school":"Academies, schools, tuition, instructors.","entertainment/exhibition":"Theatre, concerts, exhibitions, museums, dancing.","animals/livestock for sale":"Horses, cattle, sheep &c. offered for sale (not strayed or lost).","hospitality (tavern/inn/coffeehouse)":"Taverns, inns, coffeehouses, boarding — food, drink and lodging services.","wholesale":"Goods offered by the quantity to retailers.","retail":"Goods offered singly to the public.",103 unmodified linesconst b={el,tag,v:{x:v.x,y:v.y,width:v.width,height:v.height},types, subs:normSubs(v,types), unit:(v.unit ?? v.ad_unit) || "",conf:v.confidence||"certain", text:text||v._text||"",txn:v.transaction||"for sale",autoType:(types.length===1 && types[0]==="Article" && !v.types)};styleBox(b); imgwrap.appendChild(el);el.addEventListener("mousedown",ev=>{ if(ev.shiftKey) return; startDrag(ev,b,"move"); });32 unmodified lineshost.appendChild(lab);});}function dropStaleSubs(b){ const ok=new Set(subsForTypes(b.types)); b.subs=b.subs.filter(s=>ok.has(s)); }function toggleType(b,n,on){if(on){16 unmodified linesif(!b) return;$("f_type").value=b.types[0]; $("f_unit").value=b.unit; $("f_conf").value=b.conf;$("txnrow").style.display = wantsTxn(b) ? "block" : "none";$("f_txn").value = b.txn || "for sale";renderTypeChecks(b); renderSubChecks(b);$("tasktext").textContent=b.text||"";}// ---- undo + dirty ----function markDirty(){ dirty=true; }function snapshot(){ return boxes.map(b=>({x:b.v.x,y:b.v.y,width:b.v.width,height:b.v.height,types:b.types.slice(),subs:b.subs.slice(),unit:b.unit,conf:b.conf,text:b.text,txn:b.txn,autoType:b.autoType})); }function pushUndo(){ undoStack.push(snapshot()); if(undoStack.length>60) undoStack.shift(); }function restore(state){boxes.slice().forEach(b=>b.el.remove()); boxes=[]; clearMulti();50 unmodified lines// ---- editor fields ----$("f_type").onchange=e=>{ pushUndo(); setPrimary(selected,e.target.value); markDirty(); };$("f_txn").onchange=e=>{ pushUndo(); selected.txn=e.target.value; markDirty(); };$("f_unit").onchange=e=>{ pushUndo(); selected.unit=e.target.value; styleBox(selected); markDirty(); };$("f_conf").onchange=e=>{ pushUndo(); selected.conf=e.target.value; markDirty(); };$("del").onclick=()=>{ if(!selected)return; pushUndo(); selected.el.remove(); boxes=boxes.filter(x=>x!==selected); selectBox(null); markDirty(); };185 unmodified linesrectanglelabels:b.types, types:b.types, type:b.types[0],subtypes:b.subs.length?b.subs:undefined, subtype:b.subs[0]||undefined,unit:b.unit||undefined, confidence:b.conf,transaction: wantsTxn(b) ? (b.txn||"for sale") : undefined,_text:b.text })),custom_labels: customLabels() };try {102 unmodified lines10310410510610710810911041 unmodified lines15215315415515615715815916016116216316448 unmodified lines21321421521621721821922022122222310 unmodified lines2342352362372382392402412422432446 unmodified lines251252253254255256257258259260261262263264103 unmodified lines36836937037137237337432 unmodified lines40740840941041141241341441541641741841942042142242342442516 unmodified lines44244344444544644744844945045145245345445550 unmodified lines506507508509510511185 unmodified lines697698699700701702703102 unmodified lines<input id="f_unit" type="number" min="1" step="1"/><button id="linkunit" class="secondary" style="margin-top:6px;width:100%">Link selected boxes (u)</button><div id="txnrow" style="display:none"><label>Transaction <span class="hint">(any that apply — an ad can be part sale, part let)</span></label><div id="f_txn" class="chk"></div></div><label>Confidence</label><select id="f_conf"><option>certain</option><option>unsure</option></select><button id="del" class="secondary" style="margin-top:12px;background:#8a2b2b">Delete box</button>41 unmodified lines"Date":"Publication Metadata" };// Renamed subtypes: old -> new, applied on load for the same reason.const SUB_ALIAS = { "extract from another paper":"from another paper","animals/livestock for sale":"animals/livestock","lost/found animals":"animals/livestock","lost/found property":"goods/property",// not safely mappable: "rentals" could be land, horses or pews;// "lost/found people" covers runaways AND criminal committals."rentals":"other/uncertain","lost/found people":"other/uncertain","volume/number line":"volume/whole number" };const DEFS = {"Masthead/Nameplate":"The paper's title banner (e.g. PORTLAND GAZETTE).",48 unmodified lines"Jokes/Humor":["anecdote/jest","epigram","satire/burlesque","other/uncertain"],"Death/Marriage notices":["death/obituary","marriage","birth","combined vital-record column","other/uncertain"],"Advertisement":["patent","runaway (servant/enslaved person)","slave sale/hire","dry-goods/mercantile","auction/vendue (public sale)","private sale","real estate/land","estate/probate notice","lottery","shipping/freight/stage","help wanted/labor","goods/property","books/printing/self-promotion","financial/stockholder/bank","public/official notice","professional services","domestic/marital notice","education/school","entertainment/exhibition","animals/livestock","hospitality (tavern/inn/coffeehouse)","wholesale","retail","date","name","other/uncertain"],"Legal/Official notice":["sheriff's sale","estate/probate notice","court order/summons","notice to creditors","tax/collector's notice","commissioners'/trustees' notice","bankruptcy/insolvency","other/uncertain"],10 unmodified linesconst subsFor = t => SUBTYPES_BY_TYPE[t] || [];// Transaction mode is a separate axis from subtype, and only these types take one.const TXN_TYPES = new Set(["Advertisement","Legal/Official notice"]);// "none" is explicit: about half of advertisements are not transactions at all,// so nothing is pre-selected and "for sale" has to be chosen deliberately.const TXN_OPTS = ["none","for sale","wanted","rent","lost","found","stolen"];const normTxn = v => Array.isArray(v) ? v.filter(x=>TXN_OPTS.includes(x)): (TXN_OPTS.includes(v) ? [v] : []);const wantsTxn = b => b.types.some(t=>TXN_TYPES.has(t));const SUBDEFS = {"sheriff's sale":"Court-ordered sale by the sheriff. Publication is legally compelled, so this is a Legal notice, not a paid ad.",6 unmodified lines"patent":"Patent medicines / remedies.","runaway (servant/enslaved person)":"Seeking escaped servants / enslaved people.","slave sale/hire":"Sale or hire of enslaved people.","dry-goods/mercantile":"Merchants selling goods.","real estate/land":"Land or property for sale.","estate/probate notice":"Settling estates (often also Legal).","goods/property":"Movable goods, wares or chattels — the object, not the transaction.","lottery":"Lottery schemes or tickets.","shipping/freight/stage":"Vessels, freight, stage lines.","help wanted/labor":"Seeking apprentices / workers.","books/printing/self-promotion":"Books, or the printer's own services.","financial/stockholder/bank":"Banks, stock, financial notices.","public/official notice":"Public meeting / official matter (advertised).","professional services":"Doctors, lawyers, tradesmen.","domestic/marital notice":"Elopement / 'will not pay her debts' / family disclaimers.","education/school":"Academies, schools, tuition, instructors.","entertainment/exhibition":"Theatre, concerts, exhibitions, museums, dancing.","animals/livestock":"Horses, cattle, sheep &c. The transaction field says whether they are\n for sale, to let (stud), strayed or found.","hospitality (tavern/inn/coffeehouse)":"Taverns, inns, coffeehouses, boarding — food, drink and lodging services.","wholesale":"Goods offered by the quantity to retailers.","retail":"Goods offered singly to the public.",103 unmodified linesconst b={el,tag,v:{x:v.x,y:v.y,width:v.width,height:v.height},types, subs:normSubs(v,types), unit:(v.unit ?? v.ad_unit) || "",conf:v.confidence||"certain", text:text||v._text||"",txn:normTxn(v.transaction),autoType:(types.length===1 && types[0]==="Article" && !v.types)};styleBox(b); imgwrap.appendChild(el);el.addEventListener("mousedown",ev=>{ if(ev.shiftKey) return; startDrag(ev,b,"move"); });32 unmodified lineshost.appendChild(lab);});}function renderTxnChecks(b){const host=$("f_txn"); host.innerHTML="";TXN_OPTS.forEach(n=>{const lab=document.createElement("label");lab.innerHTML=`<input type="checkbox" ${b.txn.includes(n)?"checked":""}><span>${n}</span>`;lab.querySelector("input").onchange=e=>{ pushUndo();if(e.target.checked){b.txn = n==="none" ? ["none"] : [...b.txn.filter(x=>x!=="none"), n];} else b.txn = b.txn.filter(x=>x!==n);renderTxnChecks(b); markDirty(); };host.appendChild(lab);});}function dropStaleSubs(b){ const ok=new Set(subsForTypes(b.types)); b.subs=b.subs.filter(s=>ok.has(s)); }function toggleType(b,n,on){if(on){16 unmodified linesif(!b) return;$("f_type").value=b.types[0]; $("f_unit").value=b.unit; $("f_conf").value=b.conf;$("txnrow").style.display = wantsTxn(b) ? "block" : "none";if(wantsTxn(b)) renderTxnChecks(b);renderTypeChecks(b); renderSubChecks(b);$("tasktext").textContent=b.text||"";}// ---- undo + dirty ----function markDirty(){ dirty=true; }function snapshot(){ return boxes.map(b=>({x:b.v.x,y:b.v.y,width:b.v.width,height:b.v.height,types:b.types.slice(),subs:b.subs.slice(),unit:b.unit,conf:b.conf,text:b.text,txn:b.txn.slice(),autoType:b.autoType})); }function pushUndo(){ undoStack.push(snapshot()); if(undoStack.length>60) undoStack.shift(); }function restore(state){boxes.slice().forEach(b=>b.el.remove()); boxes=[]; clearMulti();50 unmodified lines// ---- editor fields ----$("f_type").onchange=e=>{ pushUndo(); setPrimary(selected,e.target.value); markDirty(); };$("f_unit").onchange=e=>{ pushUndo(); selected.unit=e.target.value; styleBox(selected); markDirty(); };$("f_conf").onchange=e=>{ pushUndo(); selected.conf=e.target.value; markDirty(); };$("del").onclick=()=>{ if(!selected)return; pushUndo(); selected.el.remove(); boxes=boxes.filter(x=>x!==selected); selectBox(null); markDirty(); };185 unmodified linesrectanglelabels:b.types, types:b.types, type:b.types[0],subtypes:b.subs.length?b.subs:undefined, subtype:b.subs[0]||undefined,unit:b.unit||undefined, confidence:b.conf,transaction: (wantsTxn(b) && b.txn.length) ? b.txn : undefined,_text:b.text })),custom_labels: customLabels() };try {
index.html+37-14