[object Object]

← back to Dw Photo Capture

auto-save: 2026-07-31T09:26:15 (1 files) — server.js

bd293119c72eb4270bf4218a56675dd5a7e59d03 · 2026-07-31 09:26:23 -0700 · Steve Abrams

Files touched

Diff

commit bd293119c72eb4270bf4218a56675dd5a7e59d03
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Fri Jul 31 09:26:23 2026 -0700

    auto-save: 2026-07-31T09:26:15 (1 files) — server.js
---
 server.js | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/server.js b/server.js
index 4c68f5e..3336bb3 100644
--- a/server.js
+++ b/server.js
@@ -1073,6 +1073,29 @@ const appHandler = (req, res) => {
       const hex = /^#?[0-9a-fA-F]{6}$/.test(rawHex) ? ('#' + rawHex.replace('#', '').toLowerCase()) : '';
       if (!hex) return send(res, 400, { err: 'hex required (#rrggbb)' }, CORS);
       const k = Math.max(1, Math.min(parseInt(p.k, 10) || 36, 60));
+      // ── Coordinate filters (Steve TK-10085) ──────────────────────────────────
+      // Narrow the color-matched set by product TYPE (wallcovering / fabric /
+      // other) and USE (commercial vs residential). Both derive purely from each
+      // item's product_type (it.p) — no index rebuild needed. Blank/unknown = the
+      // "All" default (no filter). USE has an explicit commercial/contract signal;
+      // "residential" is the honest complement (everything not commercial/contract).
+      const rawType = (typeof p.type === 'string' ? p.type : '').toLowerCase();
+      const rawUse  = (typeof p.use  === 'string' ? p.use  : '').toLowerCase();
+      const CI_TYPE = ['wallcovering', 'fabric', 'other'].indexOf(rawType) >= 0 ? rawType : '';
+      const CI_USE  = ['commercial', 'residential'].indexOf(rawUse) >= 0 ? rawUse : '';
+      const ciKeep = (ptype) => {
+        if (!CI_TYPE && !CI_USE) return true;
+        const s = (ptype || '').toLowerCase();
+        const isWall = /wallcover|wallpaper|mural/.test(s);
+        const isFab  = /fabric|upholst|drapery|multipurpose|pillow/.test(s);
+        if (CI_TYPE === 'wallcovering' && !isWall) return false;
+        if (CI_TYPE === 'fabric' && !isFab) return false;
+        if (CI_TYPE === 'other' && (isWall || isFab)) return false;
+        const isCommercial = /commercial|contract/.test(s);
+        if (CI_USE === 'commercial' && !isCommercial) return false;
+        if (CI_USE === 'residential' && isCommercial) return false;
+        return true;
+      };
       try {
         const idx = loadColorIndex();               // cached, loaded once
         const target = hexToLab(hex);
@@ -1082,7 +1105,7 @@ const appHandler = (req, res) => {
           const it = idx[i];
           const dl = it.l - target.l, da = it.a - target.a, db = it.b - target.b;
           const de = Math.sqrt(dl * dl + da * da + db * db);
-          if (de <= ceil) within.push({ it, de });
+          if (de <= ceil && ciKeep(it.p)) within.push({ it, de });
         }
         within.sort((x, y) => x.de - y.de);          // nearest first
         const results = within.slice(0, k).map(w => ({

← b890acb auto-save: 2026-07-31T04:23:41 (1 files) — data/color-dots.j  ·  back to Dw Photo Capture  ·  auto-save: 2026-08-01T03:33:03 (1 files) — data/color-dots.j 1ae3d54 →