bep40 commited on
Commit
319b65d
·
verified ·
1 Parent(s): e03b8af

Upload index.html with huggingface_hub

Browse files
Files changed (1) hide show
  1. index.html +29 -10
index.html CHANGED
@@ -663,15 +663,15 @@ document.getElementById('tab-'+id).classList.add('active');
663
  }
664
 
665
  // ===== ACTIONS =====
666
- function setCat(s){S.cat=s;S.pg=1;updActive('.cat-item','data-s',s);goBackToList();render();closeMsb()}
667
- function setPrice(min,max,i){S.pmin=min;S.pmax=max;S.pg=1;document.querySelectorAll('.pr-item[data-i]').forEach((e,j)=>e.classList.toggle('active',j===i));goBackToList();render();closeMsb()}
668
- function setBrand(b){S.brand=b;S.pg=1;document.querySelectorAll('[data-b]').forEach(e=>e.classList.toggle('active',e.getAttribute('data-b')===b));goBackToList();render();closeMsb()}
669
  function goBackToList(){document.getElementById('listView').style.display='';document.getElementById('detailView').classList.remove('show');document.getElementById('detailView').innerHTML='';document.querySelector('.hero').style.display='';}
670
- function doSearch(){S.q=document.getElementById('q').value.trim();S.pg=1;render();renderMainCatSearch()}
671
- function doSort(){S.sort=document.getElementById('ss').value;S.pg=1;render()}
672
- function setV(v){S.view=v;document.getElementById('gb').classList.toggle('active',v==='g');document.getElementById('lb').classList.toggle('active',v==='l');render()}
673
- function goPg(p){let f=getF(),tp=Math.ceil(f.length/PP);if(p<1||p>tp)return;S.pg=p;render();document.querySelector('.toolbar').scrollIntoView({behavior:'smooth',block:'start'})}
674
- function resetAll(){S={cat:'all',q:'',pmin:0,pmax:1e15,sort:'default',pg:1,view:S.view,brand:'all'};document.getElementById('q').value='';document.getElementById('ss').value='default';updActive('.cat-item','data-s','all');document.querySelectorAll('.pr-item[data-i]').forEach((e,i)=>e.classList.toggle('active',i===0));document.querySelectorAll('[data-b]').forEach(e=>e.classList.toggle('active',e.getAttribute('data-b')==='all'));render();let csr=document.getElementById('catSearchResults');if(csr)csr.innerHTML='';}
675
  function updActive(sel,attr,val){document.querySelectorAll(sel).forEach(e=>e.classList.toggle('active',e.getAttribute(attr)===val))}
676
  function closeMsb(){document.getElementById('msb').classList.remove('open')}
677
  document.addEventListener('keydown',e=>{if(e.key==='Escape')goBack();if(e.key==='/'&&document.activeElement.tagName!=='INPUT'){e.preventDefault();document.getElementById('q').focus()}});
@@ -920,9 +920,10 @@ goBack();
920
  showPage('products');resetAll();
921
  }
922
 
923
- // Parse URL query params on load for direct search URLs
924
  function parseUrlParams(){
925
- let params=new URLSearchParams(location.search);
 
926
  let q=params.get('q')||params.get('search')||'';
927
  if(q){
928
  document.getElementById('q').value=q;
@@ -941,6 +942,24 @@ let p=params.get('p');
941
  if(p==='list'){S.view='l';document.getElementById('gb').classList.remove('active');document.getElementById('lb').classList.add('active');}
942
  }
943
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
944
  // Init on load
945
  document.addEventListener('DOMContentLoaded',()=>{
946
  parseUrlParams();
 
663
  }
664
 
665
  // ===== ACTIONS =====
666
+ function setCat(s){S.cat=s;S.pg=1;updActive('.cat-item','data-s',s);goBackToList();updateHash();render();closeMsb()}
667
+ function setPrice(min,max,i){S.pmin=min;S.pmax=max;S.pg=1;document.querySelectorAll('.pr-item[data-i]').forEach((e,j)=>e.classList.toggle('active',j===i));goBackToList();updateHash();render();closeMsb()}
668
+ function setBrand(b){S.brand=b;S.pg=1;document.querySelectorAll('[data-b]').forEach(e=>e.classList.toggle('active',e.getAttribute('data-b')===b));goBackToList();updateHash();render();closeMsb()}
669
  function goBackToList(){document.getElementById('listView').style.display='';document.getElementById('detailView').classList.remove('show');document.getElementById('detailView').innerHTML='';document.querySelector('.hero').style.display='';}
670
+ function doSearch(){S.q=document.getElementById('q').value.trim();S.pg=1;updateHash();render();renderMainCatSearch()}
671
+ function doSort(){S.sort=document.getElementById('ss').value;S.pg=1;updateHash();render()}
672
+ function setV(v){S.view=v;document.getElementById('gb').classList.toggle('active',v==='g');document.getElementById('lb').classList.toggle('active',v==='l');updateHash();render()}
673
+ function goPg(p){let f=getF(),tp=Math.ceil(f.length/PP);if(p<1||p>tp)return;S.pg=p;updateHash();render();document.querySelector('.toolbar').scrollIntoView({behavior:'smooth',block:'start'})}
674
+ function resetAll(){S={cat:'all',q:'',pmin:0,pmax:1e15,sort:'default',pg:1,view:S.view,brand:'all'};document.getElementById('q').value='';document.getElementById('ss').value='default';updActive('.cat-item','data-s','all');document.querySelectorAll('.pr-item[data-i]').forEach((e,i)=>e.classList.toggle('active',i===0));document.querySelectorAll('[data-b]').forEach(e=>e.classList.toggle('active',e.getAttribute('data-b')==='all'));location.hash='';render();let csr=document.getElementById('catSearchResults');if(csr)csr.innerHTML='';}
675
  function updActive(sel,attr,val){document.querySelectorAll(sel).forEach(e=>e.classList.toggle('active',e.getAttribute(attr)===val))}
676
  function closeMsb(){document.getElementById('msb').classList.remove('open')}
677
  document.addEventListener('keydown',e=>{if(e.key==='Escape')goBack();if(e.key==='/'&&document.activeElement.tagName!=='INPUT'){e.preventDefault();document.getElementById('q').focus()}});
 
920
  showPage('products');resetAll();
921
  }
922
 
923
+ // Parse URL hash params on load for direct search URLs
924
  function parseUrlParams(){
925
+ let hash=location.hash.replace(/^#/,'');
926
+ let params=new URLSearchParams(hash);
927
  let q=params.get('q')||params.get('search')||'';
928
  if(q){
929
  document.getElementById('q').value=q;
 
942
  if(p==='list'){S.view='l';document.getElementById('gb').classList.remove('active');document.getElementById('lb').classList.add('active');}
943
  }
944
 
945
+ // Update hash based on current state
946
+ function updateHash(){
947
+ let parts=[];
948
+ if(S.q)parts.push('q='+encodeURIComponent(S.q));
949
+ if(S.cat!=='all')parts.push('cat='+encodeURIComponent(S.cat));
950
+ if(S.brand!=='all')parts.push('brand='+encodeURIComponent(S.brand));
951
+ if(S.pg>1)parts.push('page='+S.pg);
952
+ if(S.sort!=='default')parts.push('sort='+encodeURIComponent(S.sort));
953
+ if(S.view==='l')parts.push('p=list');
954
+ location.hash=parts.length?'#'+parts.join('&'):'';
955
+ }
956
+
957
+ // Handle hash changes
958
+ window.addEventListener('hashchange',()=>{
959
+ parseUrlParams();
960
+ render();
961
+ });
962
+
963
  // Init on load
964
  document.addEventListener('DOMContentLoaded',()=>{
965
  parseUrlParams();