[object Object]

← back to Japan Enrich

japan viewer: URL-param deep-link + sharable state for every left-panel facet (readURL/syncURL)

8b2471aeaeafc67a507ece5731a44a46d8ed48d7 · 2026-07-06 14:27:00 -0700 · Steve

Files touched

Diff

commit 8b2471aeaeafc67a507ece5731a44a46d8ed48d7
Author: Steve <steve@designerwallcoverings.com>
Date:   Mon Jul 6 14:27:00 2026 -0700

    japan viewer: URL-param deep-link + sharable state for every left-panel facet (readURL/syncURL)
---
 viewer-local/public/index.html | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/viewer-local/public/index.html b/viewer-local/public/index.html
index 9bf120e..9eed1de 100644
--- a/viewer-local/public/index.html
+++ b/viewer-local/public/index.html
@@ -460,6 +460,24 @@ function applyFilters(){
   $('#total').textContent=VIEW.length.toLocaleString()+' SKUs';
   $('#empty').style.display=VIEW.length?'none':'block';
   renderSide();
+  syncURL();
+}
+// ── URL <-> filter sync: EVERY left-panel facet is deep-linkable + shareable ──
+// read on load (?distributor=Goodrich%20(Thailand) lands pre-filtered); write on
+// every change (copy the address bar to share the exact filtered view).
+function syncURL(){
+  const p=new URLSearchParams();
+  for(const [k] of FIELDS){if(FIL[k])p.set(k,FIL[k]);}
+  const q=$('#q').value.trim(); if(q)p.set('q',q);
+  const pat=$('#pattern').value.trim(); if(pat)p.set('pattern',pat);
+  const qs=p.toString();
+  history.replaceState(null,'',qs?('?'+qs):location.pathname);
+}
+function readURL(){
+  const p=new URLSearchParams(location.search);
+  for(const [k] of FIELDS){const v=p.get(k); if(v!=null)FIL[k]=v;}
+  const q=p.get('q'); if(q!=null)$('#q').value=q;
+  const pat=p.get('pattern'); if(pat!=null)$('#pattern').value=pat;
 }
 function renderMore(){
   const slice=VIEW.slice(shown,shown+PAGE);
@@ -550,7 +568,7 @@ async function loadAll(){
   }));
   try{const q=await fetch(location.origin+'/api/import-queue').then(r=>r.json());QUEUED=new Set(q.skus||[]);}catch(e){}
   updateQueueBadge();
-  buildFacetCache(); applyFilters();
+  buildFacetCache(); readURL(); applyFilters();
 }
 loadFX().finally(loadAll);
 </script>

← f26fe66 deploy: japan viewer distributor feature LIVE on japan.desig  ·  back to Japan Enrich  ·  japan viewer: contrarian-gate fixes — nginx port 9934, no-sp 955be29 →