[object Object]

← back to Commercialrealestate

CRCP per-city scope: filter property grids (sales/direct-listings/just-listed/fha/valley-pools) on city subdomains; directories stay statewide

dff786b9e3098cfa86a9da57a294439a7cbad698 · 2026-08-20 14:02:59 -0700 · Steve

Files touched

Diff

commit dff786b9e3098cfa86a9da57a294439a7cbad698
Author: Steve <steve@designerwallcoverings.com>
Date:   Thu Aug 20 14:02:59 2026 -0700

    CRCP per-city scope: filter property grids (sales/direct-listings/just-listed/fha/valley-pools) on city subdomains; directories stay statewide
---
 public/crcp-scope.js | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/public/crcp-scope.js b/public/crcp-scope.js
index bc9186d..ddebebf 100644
--- a/public/crcp-scope.js
+++ b/public/crcp-scope.js
@@ -14,6 +14,17 @@
   if (!CITY) return;                                        // base crcp / recities / localhost -> no scope
 
   var scoped = { ranked: 0, total: 0 };
+
+  // Property-level grids that carry a flat top-level .city and should be city-filtered on a subdomain.
+  // (rent-rolls is intentionally excluded — its city is nested and it's a single sample row.)
+  var SCOPED_ARRAYS = [
+    { re: /\/api\/closed-sales/, key: "rows" },
+    { re: /\/api\/direct-listings/, key: "listings" },
+    { re: /\/data\/listings\.json/, key: "listings" },
+    { re: /\/data\/fha-loans\.json/, key: "rows" },
+    { re: /\/data\/valley-pools\.json/, key: "homes" }
+  ];
+
   var _fetch = window.fetch;
   window.fetch = function (input, init) {
     var url = (typeof input === "string") ? input : (input && input.url) || "";
@@ -39,6 +50,19 @@
         }).catch(function () { return r; });
       });
     }
+    for (var i = 0; i < SCOPED_ARRAYS.length; i++) {
+      var cfg = SCOPED_ARRAYS[i];
+      if (cfg.re.test(url)) {
+        return p.then(function (key) {
+          return function (r) {
+            return r.clone().json().then(function (d) {
+              if (d && Array.isArray(d[key])) d[key] = d[key].filter(function (item) { return window.CRCP_CITIES.sameCity(item.city, CITY); });
+              return new Response(JSON.stringify(d), { status: 200, headers: { "Content-Type": "application/json" } });
+            }).catch(function () { return r; });               // parse failure -> pass original through
+          };
+        }(cfg.key));
+      }
+    }
     return p;
   };
 
@@ -51,8 +75,13 @@
       "justify-content:center;padding:9px 16px;background:#12305a;color:#eaf1fb;font:13px/1.4 -apple-system," +
       "BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;border-bottom:1px solid #24487e";
     var n = scoped.ranked;
+    var DIRECTORY_PAGES = ["/brokers.html", "/broker-grid.html", "/firms.html", "/lenders.html",
+      "/loan-officers.html", "/lending.html", "/gov-agents.html", "/licensed-agents.html",
+      "/licensed.html", "/residential-brokers.html", "/linkedin.html"];
+    var isDirectory = DIRECTORY_PAGES.indexOf(location.pathname) !== -1;
     bar.innerHTML =
       '<span>Scoped to <b>' + CITY.label + '</b>' + (n ? ' · ' + n + ' listing' + (n === 1 ? '' : 's') : '') + '</span>' +
+      (isDirectory ? '<span style="color:#8aa2c4;font-size:12px">· directories are statewide</span>' : '') +
       '<a href="https://crcp.agentabrams.com/" style="color:#9ecbff;text-decoration:none;border:1px solid #2f5da3;border-radius:8px;padding:3px 10px">View all markets →</a>' +
       '<a href="https://recities.crcp.agentabrams.com/" style="color:#9ecbff;text-decoration:none;border:1px solid #2f5da3;border-radius:8px;padding:3px 10px">All cities</a>';
     document.body.insertBefore(bar, document.body.firstChild);

← d1d3af2 chore: v0.23.0 — recities+firecities hubs, per-city scoping,  ·  back to Commercialrealestate  ·  auto-data-snapshot: 2026-08-20T14:07:04 (2 data files) — pac 22ec0ea →