← back to Dwjs Consolidation 2026 04 23

dwjs_collision_review.html

221 lines

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DWJS Collision Review — 2026-04-29</title>
<style>
  body{font:14px/1.45 system-ui,-apple-system,Segoe UI,Roboto,sans-serif;margin:0;padding:24px;background:#f6f6f6;color:#222}
  h1{margin:0 0 8px}
  .sub{color:#666;margin:0 0 20px}
  .toolbar{position:sticky;top:0;z-index:5;background:#fff;border:1px solid #ddd;padding:12px 16px;border-radius:8px;display:flex;gap:12px;align-items:center;flex-wrap:wrap;box-shadow:0 2px 6px rgba(0,0,0,.04)}
  .toolbar .stat{font-size:13px;color:#444}
  .toolbar button{padding:8px 16px;border:0;border-radius:6px;cursor:pointer;font-weight:600}
  button.export{background:#1a73e8;color:#fff}
  button.export:disabled{background:#a8c5f0;cursor:not-allowed}
  button.reset{background:#eee;color:#333}
  .group{background:#fff;border:1px solid #ddd;border-radius:10px;padding:18px;margin:18px 0;box-shadow:0 1px 3px rgba(0,0,0,.04)}
  .group-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px;flex-wrap:wrap;gap:8px}
  .mfr-tag{font-family:ui-monospace,Menlo,monospace;background:#0f172a;color:#fff;padding:4px 10px;border-radius:4px;font-size:13px}
  .york-color{font-size:13px;color:#555;background:#f0f0f0;padding:4px 10px;border-radius:4px}
  .mfr-ref{display:flex;gap:14px;align-items:center;background:#fafafa;border:1px dashed #bbb;padding:10px;border-radius:6px;margin-bottom:14px}
  .mfr-ref img{width:120px;height:120px;object-fit:cover;border-radius:4px;background:#eee}
  .mfr-ref .lbl{font-size:12px;color:#666;line-height:1.5}
  .mfr-ref .lbl b{color:#222}
  .mfr-ref a{color:#1a73e8;text-decoration:none;font-size:11px}
  .pair{display:grid;grid-template-columns:1fr 1fr;gap:16px}
  @media(max-width:740px){.pair{grid-template-columns:1fr}}
  .card{border:2px solid #ddd;border-radius:8px;padding:14px;cursor:pointer;transition:.15s;background:#fff}
  .card:hover{border-color:#bbb}
  .card.keep{border-color:#16a34a;background:#f0fdf4}
  .card.archive{border-color:#dc2626;background:#fef2f2;opacity:.65}
  .card .img{width:100%;height:180px;object-fit:cover;background:#eee;border-radius:4px;margin-bottom:10px}
  .card .img-empty{display:flex;align-items:center;justify-content:center;color:#999;font-size:12px}
  .card .title{font-weight:600;margin:0 0 6px;font-size:14px}
  .card .meta{font-size:12px;color:#555;line-height:1.5}
  .card .meta b{color:#222;font-family:ui-monospace,Menlo,monospace}
  .card .actions{margin-top:10px;display:flex;gap:6px}
  .card .actions button{flex:1;padding:6px;border:1px solid #ccc;border-radius:4px;cursor:pointer;background:#fff;font-size:13px}
  .card .actions button.act-keep:hover{background:#dcfce7;border-color:#16a34a}
  .card .actions button.act-arch:hover{background:#fee2e2;border-color:#dc2626}
  .card.keep .actions button.act-keep,.card.archive .actions button.act-arch{font-weight:700}
  .card.keep .actions button.act-keep{background:#16a34a;color:#fff;border-color:#16a34a}
  .card.archive .actions button.act-arch{background:#dc2626;color:#fff;border-color:#dc2626}
  .verdict{margin-top:10px;padding:8px;border-radius:4px;font-size:13px;display:none}
  .verdict.shown{display:block}
  .verdict.complete{background:#dcfce7;color:#166534}
  .verdict.partial{background:#fef9c3;color:#854d0e}
  .badge{display:inline-block;padding:2px 7px;border-radius:3px;font-size:11px;margin-left:6px;font-weight:600}
  .badge-active{background:#dcfce7;color:#166534}
  .badge-archived{background:#fee2e2;color:#991b1b}
  .badge-newly{background:#dbeafe;color:#1e40af}
  .badge-pre{background:#f3e8ff;color:#6b21a8}
</style>
</head>
<body>
<h1>DWJS Collision Review</h1>
<p class="sub">10 collision groups, 20 products. Click <b>KEEP</b> on the one you want to keep, <b>ARCHIVE</b> on the one to archive. Decisions saved automatically. When all 10 groups are decided, click Export.</p>

<div class="toolbar">
  <div class="stat">Decided: <b id="stat-decided">0</b> / 10 groups</div>
  <button class="export" id="btn-export" disabled>Export decisions JSON</button>
  <button class="reset" id="btn-reset">Reset all</button>
</div>

<div id="groups"></div>

<script>
const DATA = [{"mfr": "DE8994", "products": [{"id": "gid://shopify/Product/1498044792944", "sku": "TRF-56864-sample", "title": "Avea Impressions", "source": "13MB-fmpro-master", "live": {"title": "Avea Impressions | Jeffrey Stevens", "status": "ACTIVE", "vendor": "Jeffrey Stevens", "handle": "avea-impressions-wallpaper-trf-56864", "createdAt": "2018-09-30T21:04:21Z", "totalInventory": 1967, "image": "https://cdn.shopify.com/s/files/1/0015/4117/7456/products/31f767dfb93e4e1dcdd1211a13875719.jpg?v=1750789724", "variants": [{"sku": "DWJS-90053-Sample", "title": "Sample", "price": "4.25", "inventoryQuantity": 973}, {"sku": "DWJS-90053", "title": "Sold Per Single Roll (4 yards)", "price": "196.08", "inventoryQuantity": 994}], "currentMfr": "DE8994"}}, {"id": "gid://shopify/Product/6702976139315", "sku": "DWJS-17186-Sample", "title": "Jeffrey Stevens", "source": "fmpro-DWJS-direct
", "live": {"title": "Point O'Woods Ivory Wallcovering | Jeffrey Stevens", "status": "ACTIVE", "vendor": "Jeffrey Stevens", "handle": "dwjs-17186", "createdAt": "2022-04-06T22:43:32Z", "totalInventory": 4025, "image": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/DE8994.jpg?v=1740774065", "variants": [{"sku": "DWJS-17186-Sample", "title": "Sample", "price": "4.25", "inventoryQuantity": 1999}, {"sku": "DWJS-17186", "title": "Price Per Single Roll (Shipped in Doubles Only)", "price": "196.08", "inventoryQuantity": 2026}], "currentMfr": "DE8994"}}], "mfr_image": "https://www.wallpaperstogo.com/cdn/shop/files/255010.jpg?v=1755822231", "mfr_source": "www.wallpaperstogo.com", "mfr_title": "Impression Grey DE8994 Wallpaper by York"}, {"mfr": "ST5691", "products": [{"id": "gid://shopify/Product/1498047545456", "sku": "TRF-56879-sample", "title": "Suva 3 Stripe", "source": "13MB-fmpro-master", "live": {"title": "Suva 3\" Stripe | Jeffrey Stevens", "status": "ACTIVE", "vendor": "Jeffrey Stevens", "handle": "suva-3-stripe-wallpaper-trf-56879", "createdAt": "2018-09-30T21:05:49Z", "totalInventory": 1984, "image": "https://cdn.shopify.com/s/files/1/0015/4117/7456/products/989293ed0eb7e36e5cc0331f35f50c36.jpg?v=1750789688", "variants": [{"sku": "DWJS-90068-Sample", "title": "Sample", "price": "4.25", "inventoryQuantity": 998}, {"sku": "DWJS-90068", "title": "Sold Per Single Roll", "price": "73.53", "inventoryQuantity": 986}], "currentMfr": "ST5691"}}, {"id": "gid://shopify/Product/6702922891315", "sku": "DWJS-17403-Sample", "title": "Jeffrey Stevens", "source": "fmpro-DWJS-direct
", "live": {"title": "Gualala Charcoal Wallcovering | Jeffrey Stevens", "status": "ACTIVE", "vendor": "Jeffrey Stevens", "handle": "dwjs-17403", "createdAt": "2022-04-06T21:43:29Z", "totalInventory": 4026, "image": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/ST5691.jpg?v=1740774560", "variants": [{"sku": "DWJS-17403-Sample", "title": "Sample", "price": "4.25", "inventoryQuantity": 2000}, {"sku": "DWJS-17403", "title": "Price Per Single Roll (Shipped in Doubles Only)", "price": "73.53", "inventoryQuantity": 2026}], "currentMfr": "ST5691"}}], "mfr_image": "https://wallcoveringsmart.com/cdn/shop/products/st5691ex_1024x1024.jpg?v=1620042539", "mfr_source": "wallcoveringsmart.com", "mfr_title": null}, {"mfr": "LL4785", "products": [{"id": "gid://shopify/Product/6702921678899", "sku": "DWJS-16388-Sample", "title": "Ames Gray Aspen Charcoal & Olive Wallcovering", "source": "fmpro-DWJS-direct", "live": {"title": "Eureka Charcoal Wallcovering | Jeffrey Stevens", "status": "ACTIVE", "vendor": "Jeffrey Stevens", "handle": "dwjs-16388", "createdAt": "2022-04-06T21:41:56Z", "totalInventory": 3026, "image": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/LL4785.jpg?v=1740772431", "variants": [{"sku": "DWJS-16388-Sample", "title": "Sample", "price": "4.25", "inventoryQuantity": 1000}, {"sku": "DWJS-16388", "title": "Price Per Single Roll (Shipped in Doubles Only)", "price": "98.04", "inventoryQuantity": 2026}], "currentMfr": "LL4785"}}, {"id": "gid://shopify/Product/6702921711667", "sku": "DWJS-17333-Sample", "title": "Jeffrey Stevens", "source": "fmpro-DWJS-direct
", "live": {"title": "Bodega Charcoal Wallcovering | Jeffrey Stevens", "status": "ACTIVE", "vendor": "Jeffrey Stevens", "handle": "dwjs-17333", "createdAt": "2022-04-06T21:41:58Z", "totalInventory": 4025, "image": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/LL4785_1348d508-9632-487e-861d-e7112b7886e7.jpg?v=1740774385", "variants": [{"sku": "DWJS-17333-Sample", "title": "Sample", "price": "4.25", "inventoryQuantity": 1999}, {"sku": "DWJS-17333", "title": "Price Per Single Roll (Shipped in Doubles Only)", "price": "98.04", "inventoryQuantity": 2026}], "currentMfr": "LL4785"}}], "mfr_image": "https://mahoneswallpapershop.com/cdn/shop/products/ShowProductImage_20d45f69-eac7-4433-946b-2341a912af25.jpg?v=1666655467", "mfr_source": "mahoneswallpapershop.com", "mfr_title": "LL4785 | Ronald Redding Traveler, Aspen Gray Ronald Redding Wallpaper"}, {"mfr": "TD1009N", "products": [{"id": "gid://shopify/Product/6703048130611", "sku": "DWJS-16983-Sample", "title": "Wido Well Teal & Silver Wallcovering", "source": "fmpro-DWJS-direct", "live": {"title": "Salerno Charcoal Wallcovering | Jeffrey Stevens", "status": "ACTIVE", "vendor": "Jeffrey Stevens", "handle": "dwjs-16983", "createdAt": "2022-04-07T00:19:27Z", "totalInventory": 4026, "image": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/TD1009N.jpg?v=1740773673", "variants": [{"sku": "DWJS-16983-Sample", "title": "Sample", "price": "4.25", "inventoryQuantity": 2000}, {"sku": "DWJS-16983", "title": "Price Per Single Roll (Shipped in Doubles Only)", "price": "98.04", "inventoryQuantity": 2026}], "currentMfr": "TD1009N"}}, {"id": "gid://shopify/Product/6703048163379", "sku": "DWJS-16984-Sample", "title": "Jeffrey Stevens", "source": "fmpro-DWJS-direct
", "live": {"title": "Paestum Blue Wallcovering | Jeffrey Stevens", "status": "ACTIVE", "vendor": "Jeffrey Stevens", "handle": "dwjs-16984", "createdAt": "2022-04-07T00:19:29Z", "totalInventory": 4026, "image": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/TD1009N_905652ea-f0b8-4dca-a397-d7dd15725927.jpg?v=1740773675", "variants": [{"sku": "DWJS-16984-Sample", "title": "Sample", "price": "4.25", "inventoryQuantity": 2000}, {"sku": "DWJS-16984", "title": "Price Per Single Roll (Shipped in Doubles Only)", "price": "98.04", "inventoryQuantity": 2026}], "currentMfr": "TD1009N"}}], "mfr_image": "https://mahoneswallpapershop.com/cdn/shop/products/td1009nex_3.jpg?v=1665499096", "mfr_source": "mahoneswallpapershop", "mfr_title": null}, {"mfr": "TD1010N", "products": [{"id": "gid://shopify/Product/6703048196147", "sku": "DWJS-16985-Sample", "title": "Wido Well Slate & Smoke Wallcovering", "source": "fmpro-DWJS-direct", "live": {"title": "Palinuro Ash Wallcovering | Jeffrey Stevens", "status": "ACTIVE", "vendor": "Jeffrey Stevens", "handle": "dwjs-16985", "createdAt": "2022-04-07T00:19:31Z", "totalInventory": 4026, "image": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/TD1010N.jpg?v=1740773677", "variants": [{"sku": "DWJS-16985-Sample", "title": "Sample", "price": "4.25", "inventoryQuantity": 2000}, {"sku": "DWJS-16985", "title": "Price Per Single Roll (Shipped in Doubles Only)", "price": "98.04", "inventoryQuantity": 2026}], "currentMfr": "TD1010N"}}, {"id": "gid://shopify/Product/6703048228915", "sku": "DWJS-16986-Sample", "title": "Jeffrey Stevens", "source": "fmpro-DWJS-direct
", "live": {"title": "Wido Black & Slate Multi | Jeffrey Stevens", "status": "ACTIVE", "vendor": "Jeffrey Stevens", "handle": "dwjs-16986", "createdAt": "2022-04-07T00:19:32Z", "totalInventory": 4026, "image": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/TD1010N_53874948-5e97-4483-8f82-bd00ec2258c8.jpg?v=1740773680", "variants": [{"sku": "DWJS-16986-Sample", "title": "Sample", "price": "4.25", "inventoryQuantity": 2000}, {"sku": "DWJS-16986", "title": "Price Per Single Roll (Shipped in Doubles Only)", "price": "98.04", "inventoryQuantity": 2026}], "currentMfr": "TD1010N"}}], "mfr_image": "https://mahoneswallpapershop.com/cdn/shop/products/td1010nex.jpg?v=1665499096", "mfr_source": "mahoneswallpapershop", "mfr_title": null}, {"mfr": "TD1012N", "products": [{"id": "gid://shopify/Product/6703048359987", "sku": "DWJS-16989-Sample", "title": "Wido Oranges Rust & Tan Fabric", "source": "fmpro-DWJS-direct", "live": {"title": "Wido Oranges Rust & Tan Fabric | Jeffrey Stevens", "status": "ACTIVE", "vendor": "Jeffrey Stevens", "handle": "dwjs-16989", "createdAt": "2022-04-07T00:19:38Z", "totalInventory": 4026, "image": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/TD1012N.jpg?v=1740773689", "variants": [{"sku": "DWJS-16989-Sample", "title": "Sample", "price": "4.25", "inventoryQuantity": 2000}, {"sku": "DWJS-16989", "title": "Price Per Single Roll (Shipped in Doubles Only)", "price": "98.04", "inventoryQuantity": 2026}], "currentMfr": "TD1012N"}}, {"id": "gid://shopify/Product/6703048392755", "sku": "DWJS-16990-Sample", "title": "Jeffrey Stevens", "source": "fmpro-DWJS-direct
", "live": {"title": "Wido Oranges Sand & Coral Fabric | Jeffrey Stevens", "status": "ACTIVE", "vendor": "Jeffrey Stevens", "handle": "dwjs-16990", "createdAt": "2022-04-07T00:19:39Z", "totalInventory": 4026, "image": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/TD1012N_263cf893-d4a1-472a-a300-3063225d7026.jpg?v=1740773691", "variants": [{"sku": "DWJS-16990-Sample", "title": "Sample", "price": "4.25", "inventoryQuantity": 2000}, {"sku": "DWJS-16990", "title": "Price Per Single Roll (Shipped in Doubles Only)", "price": "98.04", "inventoryQuantity": 2026}], "currentMfr": "TD1012N"}}], "mfr_image": "https://mahoneswallpapershop.com/cdn/shop/products/td1012nex.jpg?v=1665499097", "mfr_source": "mahoneswallpapershop", "mfr_title": null}, {"mfr": "TD1013N", "products": [{"id": "gid://shopify/Product/6703048425523", "sku": "DWJS-16991-Sample", "title": "Wido White Off Ivory Fabric Ivory Fabric", "source": "fmpro-DWJS-direct", "live": {"title": "Wido White Off Ivory Fabric Ivory Fabric | Jeffrey Stevens", "status": "ACTIVE", "vendor": "Jeffrey Stevens", "handle": "dwjs-16991", "createdAt": "2022-04-07T00:19:41Z", "totalInventory": 4026, "image": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/TD1013N.jpg?v=1740773694", "variants": [{"sku": "DWJS-16991-Sample", "title": "Sample", "price": "4.25", "inventoryQuantity": 2000}, {"sku": "DWJS-16991", "title": "Price Per Single Roll (Shipped in Doubles Only)", "price": "98.04", "inventoryQuantity": 2026}], "currentMfr": "TD1013N"}}, {"id": "gid://shopify/Product/6703048458291", "sku": "DWJS-16992-Sample", "title": "Jeffrey Stevens", "source": "fmpro-DWJS-direct
", "live": {"title": "Wido White Off Cream Fabric Cream Fabric | Jeffrey Stevens", "status": "ACTIVE", "vendor": "Jeffrey Stevens", "handle": "dwjs-16992", "createdAt": "2022-04-07T00:19:43Z", "totalInventory": 4026, "image": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/TD1013N_cd5810e1-561d-4f3f-902f-f0b27183f202.jpg?v=1740773697", "variants": [{"sku": "DWJS-16992-Sample", "title": "Sample", "price": "4.25", "inventoryQuantity": 2000}, {"sku": "DWJS-16992", "title": "Price Per Single Roll (Shipped in Doubles Only)", "price": "98.04", "inventoryQuantity": 2026}], "currentMfr": "TD1013N"}}], "mfr_image": "https://mahoneswallpapershop.com/cdn/shop/products/td1013nex.jpg?v=1665499097", "mfr_source": "mahoneswallpapershop", "mfr_title": null}, {"mfr": "TD1014N", "products": [{"id": "gid://shopify/Product/6703048491059", "sku": "DWJS-16993-Sample", "title": "Wido Beige Well Oatmeal Wallcov Oatmeal Fabric", "source": "fmpro-DWJS-direct", "live": {"title": "Wido Beige Well Oatmeal Wallcov Oatmeal Fabric | Jeffrey Stevens", "status": "ACTIVE", "vendor": "Jeffrey Stevens", "handle": "dwjs-16993", "createdAt": "2022-04-07T00:19:45Z", "totalInventory": 4026, "image": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/TD1014N.jpg?v=1740773701", "variants": [{"sku": "DWJS-16993-Sample", "title": "Sample", "price": "4.25", "inventoryQuantity": 2000}, {"sku": "DWJS-16993", "title": "Price Per Single Roll (Shipped in Doubles Only)", "price": "98.04", "inventoryQuantity": 2026}], "currentMfr": "TD1014N"}}, {"id": "gid://shopify/Product/6703048523827", "sku": "DWJS-16994-Sample", "title": "Jeffrey Stevens", "source": "fmpro-DWJS-direct
", "live": {"title": "Wido Well Sand & Cream Fabric | Jeffrey Stevens", "status": "ACTIVE", "vendor": "Jeffrey Stevens", "handle": "dwjs-16994", "createdAt": "2022-04-07T00:19:46Z", "totalInventory": 4026, "image": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/TD1014N_9e719c2f-d01f-4084-b8ac-ce489f0de6a2.jpg?v=1740773704", "variants": [{"sku": "DWJS-16994-Sample", "title": "Sample", "price": "4.25", "inventoryQuantity": 2000}, {"sku": "DWJS-16994", "title": "Price Per Single Roll (Shipped in Doubles Only)", "price": "98.04", "inventoryQuantity": 2026}], "currentMfr": "TD1014N"}}], "mfr_image": "https://mahoneswallpapershop.com/cdn/shop/products/td1014nex.jpg?v=1665499097", "mfr_source": "mahoneswallpapershop", "mfr_title": null}, {"mfr": "TD1015N", "products": [{"id": "gid://shopify/Product/6703048556595", "sku": "DWJS-16995-Sample", "title": "Wido Well Tan & Ash Fabric", "source": "fmpro-DWJS-direct", "live": {"title": "Wido Well Tan & Ash Fabric | Jeffrey Stevens", "status": "ACTIVE", "vendor": "Jeffrey Stevens", "handle": "dwjs-16995", "createdAt": "2022-04-07T00:19:48Z", "totalInventory": 4026, "image": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/TD1015N.jpg?v=1740773707", "variants": [{"sku": "DWJS-16995-Sample", "title": "Sample", "price": "4.25", "inventoryQuantity": 2000}, {"sku": "DWJS-16995", "title": "Price Per Single Roll (Shipped in Doubles Only)", "price": "98.04", "inventoryQuantity": 2026}], "currentMfr": "TD1015N"}}, {"id": "gid://shopify/Product/6703048622131", "sku": "DWJS-16996-Sample", "title": "Jeffrey Stevens", "source": "fmpro-DWJS-direct
", "live": {"title": "Wido Black & Sand Multi | Jeffrey Stevens", "status": "ACTIVE", "vendor": "Jeffrey Stevens", "handle": "dwjs-16996", "createdAt": "2022-04-07T00:19:50Z", "totalInventory": 4026, "image": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/TD1015N_89518a74-677a-43a2-a985-054426326604.jpg?v=1740773709", "variants": [{"sku": "DWJS-16996-Sample", "title": "Sample", "price": "4.25", "inventoryQuantity": 2000}, {"sku": "DWJS-16996", "title": "Price Per Single Roll (Shipped in Doubles Only)", "price": "98.04", "inventoryQuantity": 2026}], "currentMfr": "TD1015N"}}], "mfr_image": "https://mahoneswallpapershop.com/cdn/shop/products/td1015nex.jpg?v=1665499097", "mfr_source": "mahoneswallpapershop", "mfr_title": null}, {"mfr": "TD1016N", "products": [{"id": "gid://shopify/Product/6703048654899", "sku": "DWJS-16997-Sample", "title": "Wido Off Sand & Tan Fabric", "source": "fmpro-DWJS-direct", "live": {"title": "Wido Off Sand & Tan Fabric | Jeffrey Stevens", "status": "ACTIVE", "vendor": "Jeffrey Stevens", "handle": "dwjs-16997", "createdAt": "2022-04-07T00:19:52Z", "totalInventory": 4026, "image": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/TD1016N.jpg?v=1740773712", "variants": [{"sku": "DWJS-16997-Sample", "title": "Sample", "price": "4.25", "inventoryQuantity": 2000}, {"sku": "DWJS-16997", "title": "Price Per Single Roll (Shipped in Doubles Only)", "price": "98.04", "inventoryQuantity": 2026}], "currentMfr": "TD1016N"}}, {"id": "gid://shopify/Product/6703048687667", "sku": "DWJS-16998-Sample", "title": "Jeffrey Stevens", "source": "fmpro-DWJS-direct
", "live": {"title": "Wido White & Tan Multi | Jeffrey Stevens", "status": "ACTIVE", "vendor": "Jeffrey Stevens", "handle": "dwjs-16998", "createdAt": "2022-04-07T00:19:53Z", "totalInventory": 4026, "image": "https://cdn.shopify.com/s/files/1/0015/4117/7456/files/TD1016N_2d8982fb-0b0b-4f1b-b5d9-d9d80e933f96.jpg?v=1740773714", "variants": [{"sku": "DWJS-16998-Sample", "title": "Sample", "price": "4.25", "inventoryQuantity": 2000}, {"sku": "DWJS-16998", "title": "Price Per Single Roll (Shipped in Doubles Only)", "price": "98.04", "inventoryQuantity": 2026}], "currentMfr": "TD1016N"}}], "mfr_image": "https://mahoneswallpapershop.com/cdn/shop/products/td1016nex.jpg?v=1665499098", "mfr_source": "mahoneswallpapershop", "mfr_title": null}];
const YORK_COLORS = {
  TD1009N: 'Blue',
  TD1010N: 'Black',
  TD1011N: 'Purples',
  TD1012N: 'Orange',
  TD1013N: 'White/Off White',
  TD1014N: 'Beige',
  TD1015N: 'Black (variant)',
  TD1016N: 'White/Off White (variant)',
  TD1017N: '?',
};

const STATE_KEY = 'dwjs_collision_choices_v1';
let state = JSON.parse(localStorage.getItem(STATE_KEY) || '{}');

function save() {
  localStorage.setItem(STATE_KEY, JSON.stringify(state));
  render();
}

function setChoice(mfr, pid, choice) {
  state[mfr] = state[mfr] || {};
  // toggle: if same choice clicked, clear it
  if (state[mfr][pid] === choice) delete state[mfr][pid];
  else state[mfr][pid] = choice;
  // exclusivity: if you keep one, archive the other (when there are exactly 2)
  const group = DATA.find(g => g.mfr === mfr);
  if (group && group.products.length === 2 && state[mfr][pid] === choice) {
    const other = group.products.find(p => p.id !== pid);
    state[mfr][other.id] = (choice === 'keep') ? 'archive' : 'keep';
  }
  save();
}

function isComplete(mfr) {
  const g = DATA.find(x => x.mfr === mfr);
  if (!g) return false;
  const decided = g.products.filter(p => state[mfr]?.[p.id]).length;
  const keeps = g.products.filter(p => state[mfr]?.[p.id] === 'keep').length;
  return decided === g.products.length && keeps >= 1;
}

function render() {
  const root = document.getElementById('groups');
  root.innerHTML = '';
  for (const g of DATA) {
    const div = document.createElement('div');
    div.className = 'group';
    const yorkColor = YORK_COLORS[g.mfr] || '';
    div.innerHTML = `
      <div class="group-head">
        <div>
          <span class="mfr-tag">${g.mfr}</span>
          ${yorkColor ? `<span class="york-color">York: ${yorkColor}</span>` : ''}
        </div>
        <div class="verdict ${isComplete(g.mfr) ? 'shown complete' : ''}">${isComplete(g.mfr) ? '✓ decided' : ''}</div>
      </div>
      ${g.mfr_image ? `
      <div class="mfr-ref">
        <img src="${g.mfr_image}" alt="${g.mfr}" loading="lazy">
        <div class="lbl">
          <b>York reference</b> &middot; ${g.mfr}${g.mfr_title ? ` &middot; ${escapeHtml(g.mfr_title)}` : ''}
          ${g.mfr_source ? `<br><a href="https://${g.mfr_source.replace(/^https?:\\/\\//,'')}" target="_blank" rel="noopener">${g.mfr_source}</a>` : ''}
          <br><i>Compare to DW listings below — pick whichever DW image best matches this manufacturer image.</i>
        </div>
      </div>` : ''}
      <div class="pair">
        ${g.products.map(p => renderCard(g.mfr, p)).join('')}
      </div>
    `;
    root.appendChild(div);
  }
  // attach handlers
  for (const btn of document.querySelectorAll('button[data-action]')) {
    btn.onclick = (e) => {
      e.stopPropagation();
      setChoice(btn.dataset.mfr, btn.dataset.pid, btn.dataset.action);
    };
  }
  for (const card of document.querySelectorAll('.card')) {
    card.onclick = () => {
      const cur = state[card.dataset.mfr]?.[card.dataset.pid];
      // single click toggles between keep / archive / unset
      const next = cur === 'keep' ? 'archive' : cur === 'archive' ? null : 'keep';
      if (next === null) { delete state[card.dataset.mfr][card.dataset.pid]; save(); }
      else setChoice(card.dataset.mfr, card.dataset.pid, next);
    };
  }
  // toolbar
  const decided = DATA.filter(g => isComplete(g.mfr)).length;
  document.getElementById('stat-decided').textContent = decided;
  document.getElementById('btn-export').disabled = decided !== DATA.length;
}

function renderCard(mfr, p) {
  const live = p.live || {};
  const choice = state[mfr]?.[p.id] || '';
  const skus = (live.variants || []).map(v => v.sku).filter(Boolean);
  const boltSku = skus.find(s => !/-sample$/i.test(s)) || skus[0] || p.sku;
  const cls = choice === 'keep' ? 'keep' : choice === 'archive' ? 'archive' : '';
  const isNew = p.source && p.source.includes('fmpro-DWJS-direct');
  return `
    <div class="card ${cls}" data-mfr="${mfr}" data-pid="${p.id}">
      ${live.image ? `<img class="img" src="${live.image}" loading="lazy">` : `<div class="img img-empty">no image</div>`}
      <div class="title">${escapeHtml(live.title || p.title)}</div>
      <div class="meta">
        <b>${boltSku}</b>
        <span class="badge ${live.status === 'ACTIVE' ? 'badge-active' : 'badge-archived'}">${live.status || '?'}</span>
        <span class="badge ${isNew ? 'badge-newly' : 'badge-pre'}">${isNew ? 'newly written today' : 'pre-existing MFR'}</span>
        <br>created ${(live.createdAt || '').slice(0,10)} · inv ${live.totalInventory ?? '?'} · current MFR <b>${live.currentMfr || '(none)'}</b>
        <br><a href="https://designer-laboratory-sandbox.myshopify.com/admin/products/${p.id.split('/').pop()}" target="_blank" rel="noopener" onclick="event.stopPropagation()">open in Shopify ↗</a>
      </div>
      <div class="actions">
        <button class="act-keep" data-action="keep" data-mfr="${mfr}" data-pid="${p.id}">KEEP</button>
        <button class="act-arch" data-action="archive" data-mfr="${mfr}" data-pid="${p.id}">ARCHIVE</button>
      </div>
    </div>
  `;
}

function escapeHtml(s) { return (s || '').replace(/[&<>"']/g, c => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c])); }

document.getElementById('btn-export').onclick = () => {
  const out = [];
  for (const g of DATA) {
    const choices = state[g.mfr] || {};
    for (const p of g.products) {
      out.push({
        mfr: g.mfr,
        product_id: p.id,
        sku: p.sku,
        title: p.live?.title || p.title,
        decision: choices[p.id] || 'undecided',
      });
    }
  }
  const blob = new Blob([JSON.stringify(out, null, 2)], { type: 'application/json' });
  const url = URL.createObjectURL(blob);
  const a = document.createElement('a');
  a.href = url;
  a.download = 'dwjs_collision_decisions.json';
  a.click();
  URL.revokeObjectURL(url);
};

document.getElementById('btn-reset').onclick = () => {
  if (confirm('Reset all decisions?')) { state = {}; save(); }
};

render();
</script>
</body>
</html>