bep40 commited on
Commit
48a00d7
·
verified ·
1 Parent(s): 5f9cb53

Fix catalogue: sandboxed iframe to Publitas, blocks redirect, shows flipbook directly

Browse files
Files changed (1) hide show
  1. index.html +7 -15
index.html CHANGED
@@ -646,7 +646,7 @@ function updActive(sel,attr,val){document.querySelectorAll(sel).forEach(e=>e.cla
646
  function closeMsb(){document.getElementById('msb').classList.remove('open')}
647
  document.addEventListener('keydown',e=>{if(e.key==='Escape')goBack();if(e.key==='/'&&document.activeElement.tagName!=='INPUT'){e.preventDefault();document.getElementById('q').focus()}});
648
 
649
- // ===== CATALOGUE (Publitas Embed — no iframe, no redirect) =====
650
  const CAT_LIST=[
651
  {name:'Bếp',slug:'catalogue-bep',pages:64},
652
  {name:'Máy Hút',slug:'catalogue-may-hut',pages:66},
@@ -657,29 +657,21 @@ const CAT_LIST=[
657
  {name:'Master',slug:'malloca_catalog_master',pages:174},
658
  ];
659
  let catLoaded=false;
 
660
 
661
  function loadCatalogue(idx){
662
- idx=idx||0;
 
663
  document.querySelectorAll('.ctab').forEach((t,i)=>{
664
  t.style.background=i===idx?'var(--p)':'#fff';
665
  t.style.color=i===idx?'#fff':'var(--d)';
666
  t.style.borderColor=i===idx?'var(--p)':'var(--gl)';
667
  });
668
  let c=CAT_LIST[idx];
 
669
  let container=document.getElementById('catEmbed');
670
- container.innerHTML='';
671
- let pubEl=document.createElement('div');
672
- pubEl.className='publitas-embed';
673
- pubEl.setAttribute('data-publication','https://view.publitas.com/malloca/'+c.slug);
674
- pubEl.style.cssText='width:100%;height:100%';
675
- container.appendChild(pubEl);
676
- let old=document.getElementById('publitasScript');
677
- if(old)old.remove();
678
- let s=document.createElement('script');
679
- s.id='publitasScript';
680
- s.src='https://view.publitas.com/embed.js';
681
- s.async=true;
682
- document.body.appendChild(s);
683
  }
684
 
685
  function initCatTabs(){
 
646
  function closeMsb(){document.getElementById('msb').classList.remove('open')}
647
  document.addEventListener('keydown',e=>{if(e.key==='Escape')goBack();if(e.key==='/'&&document.activeElement.tagName!=='INPUT'){e.preventDefault();document.getElementById('q').focus()}});
648
 
649
+ // ===== CATALOGUE (direct render, no redirect) =====
650
  const CAT_LIST=[
651
  {name:'Bếp',slug:'catalogue-bep',pages:64},
652
  {name:'Máy Hút',slug:'catalogue-may-hut',pages:66},
 
657
  {name:'Master',slug:'malloca_catalog_master',pages:174},
658
  ];
659
  let catLoaded=false;
660
+ let activeCat=0;
661
 
662
  function loadCatalogue(idx){
663
+ if(idx===undefined)idx=0;
664
+ activeCat=idx;
665
  document.querySelectorAll('.ctab').forEach((t,i)=>{
666
  t.style.background=i===idx?'var(--p)':'#fff';
667
  t.style.color=i===idx?'#fff':'var(--d)';
668
  t.style.borderColor=i===idx?'var(--p)':'var(--gl)';
669
  });
670
  let c=CAT_LIST[idx];
671
+ let url='https://view.publitas.com/malloca/'+c.slug;
672
  let container=document.getElementById('catEmbed');
673
+ // Create iframe with sandbox to block top-navigation but allow scripts
674
+ container.innerHTML=`<iframe src="${url}" sandbox="allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox" style="width:100%;height:100%;border:none;border-radius:16px" allowfullscreen></iframe>`;
 
 
 
 
 
 
 
 
 
 
 
675
  }
676
 
677
  function initCatTabs(){