6 lines
1.3 KiB
JavaScript
6 lines
1.3 KiB
JavaScript
(()=>{
|
|
const frame=document.querySelector('#company-workspace');if(!frame)return;const cp='https://cp.dunerealms.com',pages=new Set(['overview','boards','people','treasury','commerce','claims','patronage','company-patronage','acquisitions','subsidiaries','projects','settings']),uuid=/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i;
|
|
function show(){const url=new URL(cp+'/company-cp'),page=location.hash.replace(/^#/,'').split('/').at(-1),company=new URL(location.href).searchParams.get('company');if(uuid.test(company||''))url.searchParams.set('company',company);url.hash='company/'+(pages.has(page)?page:'overview');if(frame.src!==url.href)frame.src=url.href;}
|
|
frame.addEventListener('load',()=>frame.contentWindow?.postMessage({type:'dune-embed-measure'},cp));window.addEventListener('hashchange',show);
|
|
window.addEventListener('message',event=>{if(event.origin!==cp||event.source!==frame.contentWindow)return;const data=event.data;if(data?.type==='dune-embed-size'&&Number.isFinite(data.height)&&data.height>=100&&data.height<=200000)frame.style.height=Math.ceil(data.height)+'px';if(data?.type==='dune-company-route'&&pages.has(data.page)){const url=new URL(location.href);url.hash='company/'+data.page;if(uuid.test(data.company||''))url.searchParams.set('company',data.company);history.replaceState(null,'',url);}});show();
|
|
})();
|

Staff