diff --git a/website/control-panel/public/cp-v2/v2.js b/website/control-panel/public/cp-v2/v2.js index ac70fdd6..c4572530 100644 --- a/website/control-panel/public/cp-v2/v2.js +++ b/website/control-panel/public/cp-v2/v2.js @@ -181,7 +181,7 @@ if(wid==='clan'&&!context.clanWorkspace){disposePage();disposePage=()=>{};conten if(wid==='post'&&!context.mailDirectoryReady&&Date.now()-postMenuTime>30000){disposePage();disposePage=()=>{};current='post';sidebar.replaceChildren(el('p','','Loading your inboxes…'));content.replaceChildren(el('p','cp-v2-news-status','Loading your authorised inboxes…'));document.querySelector('#sidebar-right').replaceChildren();if(!postMenuRequest)postMenuRequest=import('/v2/cp-v2-post-menu.mjs').then(({loadMailboxMenu})=>loadMailboxMenu()).finally(()=>{postMenuRequest=null;});postMenuRequest.then(inboxes=>{if(navigation!==renderSequence)return;const post=menu.workspaces.find(w=>w.id==='post'),channels=post.groups.find(g=>g.label==='Channels')?.items||[];post.groups=[{label:'Inboxes',items:inboxes},{label:'Channels',items:channels.filter(item=>item.id!=='shared-inbox')}];postMenuTime=Date.now();go('post',pid,{...context,mailDirectoryReady:true});}).catch(error=>{if(navigation!==renderSequence)return;const retry=el('button','gold-button','Retry inbox directory');retry.onclick=()=>go('post',pid);content.replaceChildren(el('p','cp-v2-news-status',error.message),retry);});return;} const initialTab=route.initialTab||context.initialTab;const requestedDesignTab=pid; if(['realm','market'].includes(wid)&&['company-directory','company-registration','company-profile','company-members','company-finance','company-permissions','company-applications'].includes(pid))pid='companies';if(wid==='bureau'&&pid==='dev-approvals'){wid='forge';pid='dev-approvals';}disposePage();disposePage=()=>{};if(wid==='bureau'&&pid==='luckperms')pid='permissions';const originalWorkspace=menu.workspaces.find(x=>x.id===wid)||menu.workspaces[0],clanRecord=context.clanWorkspace?.clans.find(c=>c.id===context.clanWorkspace.selected);const w=originalWorkspace.id==='clan'?{...originalWorkspace,groups:originalWorkspace.groups.map(g=>({...g,items:g.items.filter(item=>context.clanSwitcher?.clanPageAllowed(clanRecord,item.id)!==false)})).filter(g=>g.items.length)}:originalWorkspace;current=w.id;document.body.dataset.workspace=w.id;const items=w.groups.flatMap(g=>g.items);const item=items.find(x=>x.id===pid)||items[0];if(clanSurface&&parent!==window)parent.postMessage({type:'dune-clan-route',workspace:w.id,page:item.id,...(w.id==='clan'&&context.accountId?{accountId:context.accountId}:{})},clanParentOrigin);for(const b of portals.children)b.setAttribute('aria-selected',String(b.dataset.id===w.id));sidebar.replaceChildren();const sidebarRight=document.querySelector('#sidebar-right');sidebarRight.replaceChildren();renderComfortNavigation(w.id);const banner=el('div','side-hero',w.id==='forge'?'DEV':w.label.toUpperCase());sidebar.append(banner);sidebarRight.append(el('div','side-hero',w.id==='forge'?'DUNEGIT':w.label.toUpperCase()+' · DIRECTORY'));if(w.id==='realm'){const mail=el('button','mail-shortcut','✉ You’ve Got Mail');mail.onclick=()=>go('post','mail-inbox');sidebar.append(mail)} if(w.id==='clan'&&context.clanSwitcher){sidebar.append(context.clanSwitcher.createOrganisationSwitcher({kind:'clan',records:context.clanWorkspace.clans,selected:context.clanWorkspace.selected,onSelect:id=>{const u=new URL(location.href);u.searchParams.set('clan',id);history.replaceState(null,'',u);go('clan','clan-overview',{accountId:id});}}));} -if(item.href){location.assign(item.href);return;}const groups=w.groups.map(g=>({...g,items:g.items.filter(x=>!x.dashboardOnly)})).filter(g=>g.items.length);let split=groups.length,best=Infinity;for(let i=1;in+g.items.length+2,0),b=groups.slice(i).reduce((n,g)=>n+g.items.length+2,0),delta=Math.abs(a-b);if(deltag.label==='DuneGit');if(w.id==='post')split=1;for(const [gi,g] of groups.entries()){const target=sidebar;const block=el('details','category-block');block.open=window.matchMedia('(min-width:721px)').matches||g.items.some(x=>x.id===item.id);const heading=el('summary','category-heading');heading.append(categoryTitleImage(g.label,w.id),el('span','category-name',g.label),el('span','category-count',String(g.items.length)));block.append(heading);const links=el('div','category-links');for(const x of g.items){const b=el(x.href?'a':'button','navitem');if(x.href)b.href=x.href;else b.type='button';b.append(submenuArtwork(x,g,w.id),el('span','',x.label));b.setAttribute('aria-current',x.id===item.id?'page':'false');if(!x.href)b.onclick=()=>go(w.id,x.id);links.append(b)}block.append(links);target.append(block)}content.replaceChildren();const hero=el('div','hero');hero.append(image(art[w.id]));const title=el('div');title.append(el('h1','',item.label),el('p','',w.id==='clan'?'Your household, its banner and the people who carry it.':'Realm management, account tools and personal operations.'));hero.append(title);content.append(hero); +if(item.href){location.assign(item.href);return;}const groups=w.groups.map(g=>({...g,items:g.items.filter(x=>!x.dashboardOnly)})).filter(g=>g.items.length);let split=groups.length,best=Infinity;for(let i=1;in+g.items.length+2,0),b=groups.slice(i).reduce((n,g)=>n+g.items.length+2,0),delta=Math.abs(a-b);if(deltag.label==='DuneGit');if(w.id==='post')split=1;for(const [gi,g] of groups.entries()){const target=sidebar;const block=el('details','category-block');block.open=g.items.some(x=>x.id===item.id);const heading=el('summary','category-heading');heading.append(categoryTitleImage(g.label,w.id),el('span','category-name',g.label),el('span','category-count',String(g.items.length)));block.append(heading);const links=el('div','category-links');for(const x of g.items){const b=el(x.href?'a':'button','navitem');if(x.href)b.href=x.href;else b.type='button';b.append(submenuArtwork(x,g,w.id),el('span','',x.label));b.setAttribute('aria-current',x.id===item.id?'page':'false');if(!x.href)b.onclick=()=>go(w.id,x.id);links.append(b)}block.append(links);target.append(block)}content.replaceChildren();const hero=el('div','hero');hero.append(image(art[w.id]));const title=el('div');title.append(el('h1','',item.label),el('p','',w.id==='clan'?'Your household, its banner and the people who carry it.':'Realm management, account tools and personal operations.'));hero.append(title);content.append(hero); const cards=el('div','cards');content.append(cards); function card(name,icon,full=false){const c=el('article','card'+(full?' full':''));const h=el('h2');h.append(image(icon),document.createTextNode(name));c.append(h);cards.append(c);return c} function button(name,fn){const b=el('button','gold-button',name);b.onclick=fn;return b} diff --git a/website/scripts/main-menu.mjs b/website/scripts/main-menu.mjs index 3bd56c7d..524c836b 100644 --- a/website/scripts/main-menu.mjs +++ b/website/scripts/main-menu.mjs @@ -1,5 +1,5 @@ export const MAIN_MENU=[["Home","https://www.dunerealms.com/","nav-home-v2.webp"],["Discover","https://wiki.dunerealms.com/","nav-manual-v2.webp"],["Community","https://forums.dunerealms.com/","nav-boards-v2.webp"],["Trade","https://www.dunerealms.com/exchange.html","nav-exchange-v2.webp"],["The realm","https://www.dunerealms.com/realm-hub.html","nav-clan-v2.webp"],["My Account","https://cp.dunerealms.com/","nav-account-v2.webp"]]; -export const MAIN_MENU_GROUPS={"Discover":[["Explore worlds","https://www.dunerealms.com/#worlds","nav-home-v2.webp"],["New player guide","https://wiki.dunerealms.com/","nav-manual-v2.webp"]],"Community":[["Forums","https://forums.dunerealms.com/","nav-boards-v2.webp"],["Discord","https://www.dunerealms.com/discord.html","nav-discord-v2.webp"],["People of the realm","https://www.dunerealms.com/staff.html","nav-staff-v2.webp"],["News & updates","https://www.dunerealms.com/news-archive.html","nav-boards-v2.webp"],["Events","https://cp.dunerealms.com/#events/events-calendar","nav-home-v2.webp"],["Latest bans & appeals","https://www.dunerealms.com/community-records.html","nav-support-v2.webp"]],"Trade":[["Player Exchange","https://www.dunerealms.com/exchange.html","nav-exchange-v2.webp"],["Equipment & kits","https://www.dunerealms.com/exchange.html?type=kits","imperial-atelier-v1.webp"],["Imperial Postbank","https://cp.dunerealms.com/#bank/bank-overview","imperial-postbank-v2.png"],["Community shop","https://shop.dunerealms.com/","nav-shop-v1.webp"]],"The realm":[["Clans","https://www.dunerealms.com/realm-hub.html#clan","nav-clan-v2.webp"],["Companies","https://www.dunerealms.com/realm-hub.html#company","exchange-company-jobs-v1.png"],["Politics & offices","https://www.dunerealms.com/realm-hub.html#politics","seals/office-landsraad.png"]],"My Account":[["My profile","https://cp.dunerealms.com/","nav-account-v2.webp"],["Mail","https://cp.dunerealms.com/#post/mail-inbox","nav-support-v2.webp"],["Quests","https://clans.dunerealms.com/#quests/quests","exchange-quests-v1.png"],["Support","https://support.dunerealms.com/","nav-support-v2.webp"],["Staff sign in","https://cp.dunerealms.com/#bureau/user-management","nav-staff-v2.webp"]]}; +export const MAIN_MENU_GROUPS={"Discover":[["Explore worlds","https://www.dunerealms.com/#worlds","nav-home-v2.webp"],["New player guide","https://wiki.dunerealms.com/","nav-manual-v2.webp"]],"Community":[["Forums","https://forums.dunerealms.com/","nav-boards-v2.webp"],["Discord","https://www.dunerealms.com/discord.html","nav-discord-v2.webp"],["People of the realm","https://www.dunerealms.com/staff.html","nav-staff-v2.webp"],["News & updates","https://www.dunerealms.com/news-archive.html","nav-boards-v2.webp"],["Events","https://cp.dunerealms.com/#events/events-calendar","nav-home-v2.webp"],["Latest bans & appeals","https://www.dunerealms.com/community-records.html","nav-support-v2.webp"]],"Trade":[["Player Exchange","https://www.dunerealms.com/exchange.html","nav-exchange-v2.webp"],["Equipment & kits","https://www.dunerealms.com/exchange.html?type=kits","imperial-atelier-v1.webp"],["Imperial Postbank","https://cp.dunerealms.com/#bank/bank-overview","imperial-postbank-v2.png"],["Community shop","https://shop.dunerealms.com/","nav-shop-v1.webp"]],"The realm":[["Clans","https://www.dunerealms.com/realm-hub.html#clan","nav-clan-v2.webp"],["Companies","https://www.dunerealms.com/realm-hub.html#company","exchange-company-jobs-v1.png"],["Politics & offices","https://www.dunerealms.com/realm-hub.html#politics","seals/office-landsraad.png"]],"My Account":[["My dashboard","https://cp.dunerealms.com/","nav-account-v2.webp"],["Mail","https://cp.dunerealms.com/#post/mail-inbox","nav-support-v2.webp"],["Quests","https://clans.dunerealms.com/#quests/quests","exchange-quests-v1.png"],["Support","https://support.dunerealms.com/","nav-support-v2.webp"],["Staff sign in","https://cp.dunerealms.com/#bureau/user-management","nav-staff-v2.webp"]]}; export const menuLeafLinks=rows=>rows.flatMap(row=>Array.isArray(row[3])?menuLeafLinks(row[3]):[row]); export const ALL_MENU_LINKS=[...MAIN_MENU,...menuLeafLinks(Object.values(MAIN_MENU_GROUPS).flat())].filter((row,i,rows)=>rows.findIndex(r=>r[1]===row[1])===i); export function canonicalMenuHref(value){const u=new URL(value,'https://www.dunerealms.com');if(u.hostname==='dunerealms.com')u.hostname='www.dunerealms.com';if(u.hostname==='www.dunerealms.com'&&/^\/(manual|wiki)\.html$/.test(u.pathname))return'https://wiki.dunerealms.com/';if(u.hostname==='cp.dunerealms.com'&&u.pathname==='/'){if(u.hash==='#shop')return'https://shop.dunerealms.com/';if(u.hash==='#exchange')return'https://www.dunerealms.com/exchange.html';}if(['forums','support','cp','clans','corp','wiki'].some(h=>u.hostname===h+'.dunerealms.com'))return u.origin+'/';const kits=u.pathname==='/exchange.html'&&/^kits(?:-(?:clan|office|player|legendary))?$/.test(u.searchParams.get('type')||'');return u.origin+(u.pathname==='/index.html'?'/':u.pathname)+(kits?'?type=kits':'');}