MC/website/web/portal-navigation.js

70 lines
34 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(()=>{let menuIndex=0;for(const header of document.querySelectorAll('.dune-site-header')){if(window.top!==window.self){header.hidden=true;continue;}const toggle=header.querySelector('.menu-toggle'),nav=header.querySelector('nav');if(!toggle||!nav)continue;if(!nav.id){do{nav.id='dune-main-navigation-'+(++menuIndex);}while(document.getElementById(nav.id)!==nav);}toggle.setAttribute('aria-controls',nav.id);const setOpen=open=>{nav.classList.toggle('open',open);toggle.setAttribute('aria-expanded',String(open));toggle.setAttribute('aria-label',open?'Close navigation':'Open navigation');};setOpen(nav.classList.contains('open'));toggle.addEventListener('click',event=>{event.stopImmediatePropagation();setOpen(!nav.classList.contains('open'));},true);header.addEventListener('keydown',event=>{if(event.key==='Escape'&&nav.classList.contains('open')){event.preventDefault();setOpen(false);toggle.focus();}});for(const a of nav.querySelectorAll('a')){const url=new URL(a.href);if(url.host===location.host&&url.pathname===location.pathname&&url.hash===location.hash)a.setAttribute('aria-current','page');}}})();(()=>{if(window.top!==window.self){document.documentElement.classList.add('dune-embedded');return;}const links=[["Home","https://www.dunerealms.com/","nav-home-v2.webp"],["Boards","https://forums.dunerealms.com/","nav-boards-v2.webp"],["Exchange","https://www.dunerealms.com/exchange.html","nav-exchange-v2.webp"],["Kit Exchange","https://www.dunerealms.com/kits.html","items/office_water.png"],["Discord","https://www.dunerealms.com/discord.html","nav-discord-v2.webp"],["Manual/wiki","https://wiki.dunerealms.com/","nav-manual-v2.webp"],["Staff roster","https://www.dunerealms.com/staff.html","nav-staff-v2.webp"],["Support center","https://support.dunerealms.com/","nav-support-v2.webp"],["Account center","https://cp.dunerealms.com/","nav-account-v2.webp"],["Clan center","https://clans.dunerealms.com/","nav-clan-v2.webp"]],choose=function pageContextFor(value,links=PORTAL_LINKS){
const url=new URL(value),host=url.hostname;if(host==='corp.dunerealms.com')return {label:'Company CP',icon:'clans/vaerkring-v1.png'};if(url.pathname==='/dunemark-collection.html')return {label:'Dunemark Collection',icon:'imperial-postbank-v2.png'};if(url.pathname==='/government.html')return {label:'Realm & Politics',icon:'seals/office-landsraad.png'};if(url.pathname==='/kits.html')return {label:'Kit Exchange',icon:'items/office_water.png'};if(url.pathname==='/shop.html')return {label:'Shop',icon:'nav-exchange-v2.webp'}; if(host==='wiki.dunerealms.com')return {label:'Manual/wiki',icon:'nav-manual-full-v2.webp'};
if(url.pathname.startsWith('/news/'))return {label:'News dispatch',icon:'nav-discord-full-v2.webp'};
if(url.pathname==='/news-archive.html')return {label:url.searchParams.has('post')?'News dispatch':'News archive',icon:'nav-discord-full-v2.webp'};
if(host==='cp.dunerealms.com'){const pages={'#website-posts':['Website posts','discord'],'#permissions':['Website ranks','account'],'#staff-manual':['Staff manual','manual'],'#server-operations':['Server operations','home'],'#staff-tickets':['Staff ticket desk','support'],'#forum-admin':['Forum moderation','boards'],'#exchange-admin':['Exchange administration','exchange'],'#staff':['Administration','account']};const page=pages[url.hash];if(page)return {label:page[0],icon:'nav-'+page[1]+'-full-v2.webp'};}
const name=host==='forums.dunerealms.com'?'Boards':host==='support.dunerealms.com'?'Support center':host==='clans.dunerealms.com'?'Clan center':host==='cp.dunerealms.com'?(url.hash==='#exchange'?'Exchange':url.hash==='#tickets'?'Support center':url.hash==='#forum-admin'?'Boards':'Account center'):/\/(manual|wiki)\.html$/.test(url.pathname)?'Manual/wiki':/\/staff\.html$/.test(url.pathname)?'Staff roster':/\/discord\.html$/.test(url.pathname)?'Discord':/\/exchange\.html$/.test(url.pathname)?'Exchange':['/','/index.html'].includes(url.pathname)?'Home':null;
const link=links.find(x=>x[0]===name);
return !link?{label:typeof document!=='undefined'?(document.querySelector('h1')?.textContent.trim()||'Field guide'):'Field guide',icon:'nav-manual-full-v2.webp'}:{label:link[0],icon:link[2].replace('-v2.webp','-full-v2.webp')};
};let welcomeName='traveller';fetch('https://cp.dunerealms.com/api/welcome',{credentials:'include',cache:'no-store'}).then(r=>r.ok?r.json():null).then(data=>{if(typeof data?.username==='string'&&data.username.length<=32){welcomeName=data.username;render();}}).catch(()=>{});function render(){if(location.hostname==='support.dunerealms.com')document.body.classList.add('dune-support');const item=choose(location.href,links);let worlds=document.querySelector('.world-status');if(!worlds){worlds=document.createElement('aside');worlds.className='world-status';worlds.setAttribute('aria-label','Live server status');const heading=document.createElement('h2');heading.textContent='Worlds online';const list=document.createElement('ul');list.className='world-status-list';const note=document.createElement('p');note.className='world-status-note';note.textContent='Checking the caravan network…';worlds.append(heading,list,note);}worlds.remove();document.querySelector('.dune-page-marker')?.remove();if(!item)return;const header=document.querySelector('.dune-site-header');if(!header)return;const panel=document.createElement('section');panel.className='dune-page-marker';panel.setAttribute('aria-label','Welcome to '+item.label);const image=document.createElement('img');image.src='https://www.dunerealms.com/assets/'+item.icon;image.alt='';image.width=160;image.height=160;const text=document.createElement('div'),small=document.createElement('small'),title=document.createElement('p');small.textContent='THE CARAVAN GUIDE';title.textContent='Welcome, '+welcomeName+', to the '+item.label+'.';const lore=document.createElement('small');const quotes={Home:['The caravan gathers here; the latest word travels with the wind.','Rest beneath our banners and hear what stirs beyond the dunes.','Every journey begins with news from the road.'],Boards:['A shared tale can light the way for another traveller.','Trade your stories beneath the awning; every voice has a place.','Listen well: the quietest traveller may know the safest passage.'],Exchange:['Weigh your Dunemarks carefully; a fair bargain outlasts a fortune.','Count the coin, inspect the wares, and leave with honour.','Even in a sea of sand, a good bargain is worth finding.'],Discord:['Tune to the caravan frequency; familiar voices shorten the crossing.','Across the dunes, a friendly voice is its own shelter.','The signal is clear. Join the conversation beyond the horizon.'],'Manual/wiki':['A well-read field guide saves more water than a hurried journey.','Learn the trail before you challenge the dunes.','Turn the page; knowledge is the lightest provision you can carry.'],'Staff roster':['A watchful crew keeps the caravan moving.','Every banner is stronger with a trusted hand behind it.','Meet the keepers of the caravan and the worlds beyond.'],'Support center':['Set down your burden; the caravan clerks are here to help.','A troubled journey deserves a patient listener.','Bring us the details, and we will help find the next step.'],'Account center':['Your journey has a place in the caravan ledger.','Keep your records in order and your next crossing within reach.','Behind every banner stands a traveller with a story of their own.'],'Clan center':['Raise your banner; the strongest caravan travels together.','Choose your companions well, and no horizon is too distant.','A shared purpose binds a clan more firmly than any crest.']};const choices=quotes[item.label]||['May your water last and your journey bring good fortune.'];const key=location.hostname+location.pathname+location.hash;let seed=0;for(const character of key)seed=(seed*31+character.charCodeAt(0))>>>0;lore.textContent=choices[seed%choices.length];text.append(lore);const npc=document.createElement('img');npc.src='https://www.dunerealms.com/assets/nav-account-v2.webp';npc.alt='Caravan guide';npc.style.cssText='width:48px;height:48px;object-fit:contain';text.prepend(npc);text.append(small,title);if(worlds&&!worlds.querySelector('.dune-join-box')){const join=document.createElement('div');join.className='dune-join-box';const address=document.createElement('code');address.textContent='play.dunerealms.com';const button=document.createElement('button');button.type='button';button.textContent='Join now';button.setAttribute('aria-label','Join now: copy Minecraft server address');const help=document.createElement('p');help.className='dune-join-help';help.textContent='Java & Bedrock · copy the server address';help.setAttribute('role','status');button.addEventListener('click',async()=>{try{await navigator.clipboard.writeText('play.dunerealms.com');button.textContent='Copied ✓';help.textContent='Address copied · choose Add Server in Java or Bedrock.';}catch{help.textContent='In Minecraft Java, add a server with address play.dunerealms.com.';}});const ports=document.createElement('div');ports.className='dune-join-ports';for(const [edition,port]of [['Bedrock','19132'],['Java','25565']]){const box=document.createElement('span'),label=document.createElement('small'),value=document.createElement('code');label.textContent=edition+' port';value.textContent=port;const icon=document.createElement('img');icon.className='edition-icon';icon.alt='';icon.width=12;icon.height=12;icon.src='https://www.dunerealms.com/assets/edition-'+(edition==='Java'?'java':'bedrock')+'.svg';box.append(icon,label,value);ports.append(box);}join.append(address,button,ports,help);worlds.append(join);}if(worlds&&!worlds.querySelector('.world-network-art')){worlds.querySelector('.eyebrow')?.remove();const plate=document.createElement('img');plate.className='world-network-art';plate.src='https://www.dunerealms.com/assets/vaerkring-network-title-v1.webp';plate.alt='Vaerkring Network';plate.width=280;plate.height=80;worlds.prepend(plate);}panel.append(image,text);if(worlds)panel.append(worlds);header.after(panel);if(!document.querySelector('.dune-shared-footer')){const old=document.querySelector('body>footer,.site-footer'),foot=old||document.createElement('footer');foot.className='dune-shared-footer';foot.replaceChildren();const brand=document.createElement('a');brand.href='https://www.dunerealms.com/';brand.textContent='✦ dunerealms.com';brand.className='dune-footer-brand';const links=document.createElement('nav');links.setAttribute('aria-label','Footer navigation');for(const [label,href]of [['Manual/wiki','https://wiki.dunerealms.com/'],['Support','https://support.dunerealms.com/'],['Account','https://cp.dunerealms.com/'],['Disclaimer & contact','https://www.dunerealms.com/wiki.html']]){const a=document.createElement('a');a.textContent=label;a.href=href;links.append(a);}const note=document.createElement('small');note.textContent='Independent fan project · Not affiliated with Dune rights holders, Mojang or Microsoft.';foot.append(brand,links);const host=document.createElement('a');host.className='dune-hosting-badge';host.href='https://www.hetzner.com/';host.target='_blank';host.rel='noopener noreferrer';host.setAttribute('aria-label','Powered by Hetzner — visit Hetzner');const server=document.createElement('span');server.className='dune-hosting-art';server.textContent='▤';server.setAttribute('aria-hidden','true');const hostText=document.createElement('span');const powered=document.createElement('span');powered.textContent='POWERED BY';const hostLogo=document.createElement('img');hostLogo.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxODEuNDIgMjIuMjQiPjxkZWZzPjxzdHlsZT4uY2xzLTF7ZmlsbDojZDUwYzJkO308L3N0eWxlPjwvZGVmcz48dGl0bGU+RWxlbWVudCAxPC90aXRsZT48ZyBpZD0iRWJlbmVfMiIgZGF0YS1uYW1lPSJFYmVuZSAyIj48ZyBpZD0iTG9nb19QdXIiIGRhdGEtbmFtZT0iTG9nbyBQdXIiPjxnIGlkPSJMb2dvIj48ZyBpZD0iSEVUWk5FUiI+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNMTc0LjA1LDE0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S0xLTFIMUMuMjksMCwwLC4yOSwwLDFWMjEuMjVjMCwuNzEuMjksMSwxLDFINC4xM2MuNywwLDEtLjI4LDEtMXYtOGgxMi40djhjMCwuNy4yOSwxLDEsMWgzLjExYy43LDAsMS0uMjksMS0xVjFDMjIuNjIuMzIsMjIuMzMsMCwyMS42MywwWiIvPjwvZz48L2c+PC9nPjwvZz48L3N2Zz4=";hostLogo.alt='Hetzner';hostLogo.width=120;hostLogo.height=20;hostText.append(powered,hostLogo);host.append(server,hostText);host.title='Hosting infrastructure · Logo: Hetzner Online GmbH';foot.append(host);foot.append(note);const legal=document.querySelector('.legal-notice');if(legal){const details=document.createElement('details'),summary=document.createElement('summary');summary.textContent='Unofficial fan project';details.className='dune-footer-legal';details.append(summary,legal);foot.append(details);}if(['www.dunerealms.com','dunerealms.com'].includes(location.hostname)&&['/','/index.html'].includes(location.pathname)){const box=document.createElement('div');box.className='dune-footer-parental';const heading=document.createElement('strong');heading.textContent='Parents & guardians';const copy=document.createElement('span');copy.textContent='Parental consent or a child’s account-data request? Contact our support team.';const link=document.createElement('a');link.href='https://support.dunerealms.com/open.php';link.textContent='Parental help →';box.append(heading,copy,link);foot.append(box);}if(!old)document.body.append(foot);}const pin=()=>document.documentElement.style.setProperty('--dune-nav-height',header.getBoundingClientRect().height+'px');pin();if(!header.dataset.pinObserved){new ResizeObserver(pin).observe(header);header.dataset.pinObserved='1';}}render();async function refreshWorlds(){try{const response=await fetch('https://cp.dunerealms.com/api/worlds',{cache:'no-store',credentials:'omit',signal:AbortSignal.timeout(7000)});if(!response.ok)throw Error();const data=await response.json(),panel=document.querySelector('.dune-page-marker .world-status');if(!panel)return;const list=panel.querySelector('.world-status-list');list.replaceChildren();const glyphs={Arrakduin:'serevan',Kaladam:'pelareth',Giedermark:'varkesh',Kaiterhof:'orivane','Sigmadraken IV':'nivareth'};list.setAttribute('role','table');list.setAttribute('aria-label','World and connection status');for(const server of data.servers){const row=document.createElement('li'),name=document.createElement('span'),state=document.createElement('span'),icon=document.createElement('img');const display=server.name==='Velocity'?'Proxi':server.name;row.setAttribute('role','row');name.setAttribute('role','cell');name.className='world-name';name.title=display;icon.alt='';icon.width=14;icon.height=14;icon.src=glyphs[server.name]?'https://www.dunerealms.com/assets/planet-glyphs/'+glyphs[server.name]+'.svg':server.name==='Velocity'?'https://www.dunerealms.com/assets/network-proxy.svg':'https://www.dunerealms.com/assets/nav-home-v2.webp';name.append(icon,document.createTextNode(display));const status=server.state==='online'?'Online':server.state==='offline'?'Offline':'Unknown';state.setAttribute('role','cell');state.setAttribute('aria-label',status);state.title=status;state.className='world-state traffic-light '+server.state;for(const color of ['red','amber','green']){const lamp=document.createElement('i');lamp.className='lamp-'+color;lamp.setAttribute('aria-hidden','true');state.append(lamp);}row.append(name,state);list.append(row);}panel.querySelector('.world-status-note').textContent=data.available?'Live check · updates every 30s':'Status check unavailable';}catch{const note=document.querySelector('.dune-page-marker .world-status-note');if(note)note.textContent='Status check unavailable · retrying';}}refreshWorlds();setInterval(()=>{if(!document.hidden)refreshWorlds();},30000);addEventListener('hashchange',()=>{render();refreshWorlds();});})();
/* DuneRealms action system v1 */
(()=>{
const selector='button,input[type=submit],input[type=button],input[type=reset],a.button,a.btn,a.action-button,[role=button],.ui.button,.cp-area-tabs>button,.tabs>a,.git-control-actions>a,.exchange-actions>a';
const admin='#staff,#staff-home,#server-operations,#permissions,#staff-manual,#luckperms,#bans,#git-admin,#forum-admin,#staff-tickets,#website-posts,.staff-controls,.admin-panel';
const eco='#exchange,#exchange-admin,#planetary-inventory,.exchange-desk,.kit-shop-dock,.kit-ledger';
function assign(element){element.classList.add('dune-button');if(element.dataset.duneAction&&!element.dataset.duneAutoAction)return;const label=(element.getAttribute('aria-label')||element.value||element.textContent||'').trim().replace(/\s+/g,' '),href=element.getAttribute('href')||'';let kind='default';
if(/^(?:approve|accept appeal|unban|confirm unban)\b/i.test(label)||/[?&]action=approve(?:&|$)/.test(href))kind='approve';
else if(/^(?:deny|reject)\b/i.test(label)||/[?&]action=deny(?:&|$)/.test(href))kind='deny';
else if(/^(?:reopen)\b/i.test(label)||/[?&]action=reopen(?:&|$)/.test(href))kind='reopen';
else if(/^(?:delete|purge|stop|suspend|ban player|confirm ban)\b/i.test(label))kind='danger';
else if(/^(?:cancel|reset|back|copy|close)\b/i.test(label))kind='neutral';
else if(element.closest(eco)||/^(?:buy|sell|shop|trade|exchange|redeem|claim reward)\b/i.test(label))kind='economy';
else if(element.closest(admin)||element.dataset.area==='staff'||/^(?:admin|manage|staff|permissions|server|moderation)\b/i.test(label)||location.pathname.startsWith('/scp/')||location.pathname.startsWith('/git/admin')||location.pathname.startsWith('/admin/'))kind='admin';
element.dataset.duneAction=kind;element.dataset.duneAutoAction='true';
}
function scan(root){if(root.nodeType!==1&&root!==document)return;if(root.matches?.(selector))assign(root);root.querySelectorAll(selector).forEach(assign);}
scan(document);let scheduled=false;const roots=new Set();new MutationObserver(records=>{for(const record of records){if(record.type==='childList'){roots.add(record.target);for(const child of record.addedNodes)roots.add(child);}else roots.add(record.target);}if(scheduled)return;scheduled=true;queueMicrotask(()=>{scheduled=false;for(const root of roots)scan(root);roots.clear();});}).observe(document.documentElement,{childList:true,subtree:true,characterData:true});
window.addEventListener('hashchange',()=>scan(document));
})();
(()=>{const stamp=()=>{const brand=document.querySelector('.dune-site-header .wordmark');if(!brand)return false;if(!brand.querySelector('.dune-release-badge')){const badge=document.createElement('span');badge.className='dune-release-badge';badge.textContent='Alpha';brand.append(badge);fetch('/release.json',{cache:'no-store'}).then(r=>r.ok?r.json():null).then(release=>{if(release&&release.stage==='alpha'&&/^\d+(?:\.\d+){3}$/.test(release.version))badge.textContent='Alpha '+release.version;}).catch(()=>{});}return true;};if(!stamp()){const observer=new MutationObserver(()=>{if(stamp())observer.disconnect();});observer.observe(document.documentElement,{childList:true,subtree:true});}})();
/* Unified main menu Shop v1 */
(()=>{const update=()=>{for(const nav of document.querySelectorAll('header nav[aria-label="Main navigation"]')){if(nav.querySelector('a[data-dune-shop],a[href="https://www.dunerealms.com/shop.html"]'))continue;const a=document.createElement('a');a.href='https://www.dunerealms.com/shop.html';a.dataset.duneShop='1';const i=document.createElement('img');i.src='https://www.dunerealms.com/assets/nav-exchange-v2.webp';i.alt='';i.width=34;i.height=34;const t=document.createElement('span');t.textContent='Shop';a.append(i,t);const exchange=[...nav.querySelectorAll('a')].find(a=>a.textContent.trim()==='Exchange'||a.textContent.trim()==='Exchange');if(exchange)exchange.after(a);else nav.append(a);}};update();new MutationObserver(update).observe(document.body,{childList:true,subtree:true});})();
/* Main menu order v2 */
/* Shop SALES indicator v1: inactive until a real promotion is active */
(()=>{let active=new URLSearchParams(location.search).get('sale-preview')==='1';if(active)document.body.classList.add('dune-sale-preview');const draw=()=>{for(const a of document.querySelectorAll('header nav[aria-label="Main navigation"] a[href="https://www.dunerealms.com/shop.html"]')){let badge=a.querySelector('.dune-sales-overlay');if(active&&!badge){badge=document.createElement('span');badge.className='dune-sales-overlay';badge.textContent='SALE';badge.setAttribute('aria-label','Shop sale active');a.append(badge);}else if(!active&&badge)badge.remove();a.classList.toggle('dune-shop-sale-active',active);}};window.addEventListener('dune:shop-promotions',e=>{active=e.detail?.active===true;draw();});draw();new MutationObserver(draw).observe(document.body,{childList:true,subtree:true});})();
/* Sir Patrick Stewart header memorial */
(()=>{const place=()=>{const header=document.querySelector('header.dune-site-header')||document.querySelector('body>header');if(!header||header.querySelector('.dune-memorial'))return;const tribute=document.createElement('aside');tribute.className='dune-memorial';tribute.setAttribute('aria-label','In memory of Sir Patrick Stewart');tribute.title='In memory of Sir Patrick Stewart';const portrait=document.createElement('img');portrait.src='https://www.dunerealms.com/assets/sir-patrick-stewart-memorial-v1.webp';portrait.alt='Sir Patrick Stewart, remembered within a heraldic shield with a black mourning ribbon';portrait.width=96;portrait.height=96;const text=document.createElement('span');text.textContent='In memory of';const name=document.createElement('strong');name.textContent='Sir Patrick Stewart';tribute.append(portrait,text,name);header.append(tribute);};place();new MutationObserver(place).observe(document.body,{childList:true,subtree:true});})();
/* Memorial dedication box and candle */
(()=>{function enhance(){const box=document.querySelector('.dune-memorial');if(!box||box.querySelector('.dune-memorial-dedication'))return;const dedication=document.createElement('div');dedication.className='dune-memorial-dedication';const role=document.createElement('p');role.textContent='Gurney Halleck · Dune (1984)';const quote=document.createElement('blockquote');quote.textContent='“May thy knife chip and shatter.”';const credit=document.createElement('small');credit.textContent='— Dune';dedication.append(role,quote,credit);const candle=document.createElement('span');candle.className='dune-memorial-candle';candle.setAttribute('role','img');candle.setAttribute('aria-label','A burning candle in remembrance');const flame=document.createElement('i');flame.className='dune-memorial-flame';candle.append(flame);box.append(dedication,candle);}enhance();new MutationObserver(enhance).observe(document.body,{childList:true,subtree:true});})();
/* DuneGit repository footer link */
(()=>{function link(){const foot=document.querySelector('.dune-shared-footer');if(!foot)return;const nav=foot.querySelector('nav');if(!nav)return;let a=nav.querySelector('[data-dune-git-footer]');if(!a){a=document.createElement('a');a.dataset.duneGitFooter='1';nav.append(a);}a.href='https://www.dunerealms.com/git/unimatrix/MC';a.textContent='DuneGit';}link();new MutationObserver(link).observe(document.body,{childList:true});addEventListener('hashchange',link);})();
/* Dune canonical menu begin */
(()=>{if(window.top!==window.self)return;const MAIN_MENU=[["Home","https://www.dunerealms.com/","nav-home-v2.webp"],["Shop","https://www.dunerealms.com/shop.html","nav-exchange-full-v2.webp"],["Boards","https://forums.dunerealms.com/","nav-boards-v2.webp"],["Staff roster","https://www.dunerealms.com/staff.html","nav-staff-v2.webp"],["Discord","https://www.dunerealms.com/discord.html","nav-discord-v2.webp"],["Exchange","https://www.dunerealms.com/exchange.html","nav-exchange-v2.webp"],["Kit Exchange","https://www.dunerealms.com/kits.html","items/office_water.png"],["Support center","https://support.dunerealms.com/","nav-support-v2.webp"],["Account center","https://cp.dunerealms.com/","nav-account-v2.webp"],["Clan center","https://clans.dunerealms.com/","nav-clan-v2.webp"],["Dunopedia","https://wiki.dunerealms.com/","nav-manual-v2.webp"]];const canonicalMenuHref=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://www.dunerealms.com/shop.html';if(u.hash==='#exchange')return'https://www.dunerealms.com/exchange.html';}if(['forums','support','cp','clans','wiki'].some(h=>u.hostname===h+'.dunerealms.com'))return u.origin+'/';return u.origin+(u.pathname==='/index.html'?'/':u.pathname);};const normalizeMainMenus=function normalizeMainMenus(doc,currentUrl,links=MAIN_MENU){let changes=0;const set=(node,key,value)=>{if(node.getAttribute(key)!==value){node.setAttribute(key,value);changes++;}};
for(const nav of doc.querySelectorAll('header nav[aria-label="Main navigation"]')){const old=[...nav.querySelectorAll('a')],ordered=[];for(const[name,href,icon]of links){let a=old.find(x=>!ordered.includes(x)&&canonicalMenuHref(x.href)===href);if(!a){a=doc.createElement('a');changes++;}set(a,'href',href);let image=a.querySelector('img');if(!image){image=doc.createElement('img');a.insertBefore(image,a.firstChild);changes++;}set(image,'src','https://www.dunerealms.com/assets/'+icon);set(image,'alt','');set(image,'width','34');set(image,'height','34');let label=[...a.children].find(x=>x.tagName==='SPAN'&&!x.classList.contains('dune-new-overlay')&&!x.classList.contains('dune-sales-overlay'));if(!label){label=doc.createElement('span');a.append(label);changes++;}set(label,'data-dune-nav-label','1');if(label.textContent!==name){label.textContent=name;changes++;}for(const n of [...a.childNodes])if(n.nodeType===3){n.remove();changes++;}const active=canonicalMenuHref(currentUrl)===href;if(active)set(a,'aria-current','page');else if(a.hasAttribute('aria-current')){a.removeAttribute('aria-current');changes++;}ordered.push(a);}
for(const a of old)if(!ordered.includes(a)){a.remove();changes++;}let cursor=nav.firstElementChild;for(const a of ordered){if(a!==cursor){nav.insertBefore(a,cursor);changes++;}cursor=a.nextElementSibling;}}
return changes;
};const sync=()=>normalizeMainMenus(document,location.href,MAIN_MENU);sync();new MutationObserver(sync).observe(document.body,{childList:true,subtree:true});})();
/* Dune canonical menu end */
/* Public developer API portal link in the shared footer */
(()=>{function sync(){const nav=document.querySelector('.dune-shared-footer nav');if(!nav)return;let a=nav.querySelector('[data-dune-api-footer]');if(!a){a=document.createElement('a');a.dataset.duneApiFooter='1';nav.append(a);}a.href='https://www.dunerealms.com/api.html';a.textContent='Developer API';}sync();new MutationObserver(sync).observe(document.body,{childList:true});})();
(()=>{function sync(){const nav=document.querySelector('.dune-shared-footer nav');if(!nav||nav.querySelector('[data-bank-rates]'))return;const a=document.createElement('a');a.dataset.bankRates='1';a.href='https://www.dunerealms.com/rates-and-charges.html';a.textContent='Rates & Charges';nav.append(a);}sync();new MutationObserver(sync).observe(document.body,{childList:true,subtree:true});})();
/* Central automatic release menu badges */
(()=>{let items=[{"href":"https://cp.dunerealms.com/#shop","introducedIn":"1.0.0.2","badge":"NEW"},{"href":"https://wiki.dunerealms.com/","introducedIn":"1.0.0.2","badge":"NEW"},{"href":"https://clans.dunerealms.com/","introducedIn":"1.0.0.2","badge":"NEW"},{"href":"https://cp.dunerealms.com/","badge":"NEW","updatedIn":"1.0.1.0","introducedIn":"1.0.1.0"},{"href":"https://cp.dunerealms.com/#exchange","updatedIn":"1.0.0.2","badge":"UPDATE"},{"href":"https://support.dunerealms.com/","updatedIn":"1.0.0.3","badge":"UPDATE"},{"href":"https://www.dunerealms.com/staff.html","updatedIn":"1.0.0.5","badge":"UPDATE"},{"href":"https://www.dunerealms.com/","badge":"NEW","introducedIn":"1.0.0.3","updatedIn":"1.0.0.3"},{"href":"https://www.dunerealms.com/shop.html","updatedIn":"1.0.0.5","badge":"UPDATE"},{"href":"https://www.dunerealms.com/kits.html","introducedIn":"1.0.0.5","badge":"NEW"},{"href":"https://cp.dunerealms.com/#kits-exchange","introducedIn":"1.0.0.5","badge":"NEW"},{"href":"https://cp.dunerealms.com/#realm","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#bureau","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#forge","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#politics","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#post","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#bank","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#market","badge":"NEW","introducedIn":"v2-api"},{"href":"https://www.dunerealms.com/rates-and-charges.html","updatedIn":"1.0.1.0","badge":"UPDATE"}];function mark(){const release=document.querySelector('.dune-release-badge')?.textContent.match(/\d+(?:\.\d+){3}/)?.[0];for(const a of document.querySelectorAll('header nav[aria-label="Main navigation"] a,#portals .portal[data-id]')){const href=a.matches('#portals .portal')?(document.body.dataset.cpMode==='clan'?'https://clans.dunerealms.com/#':'https://cp.dunerealms.com/#')+a.dataset.id:a.href;const item=items.find(x=>x.href===href),label=['NEW','UPDATE'].includes(item?.badge)?item.badge:null;let tag=a.querySelector('.dune-new-overlay');if(label){if(!tag){tag=document.createElement('span');tag.className='dune-new-overlay';a.append(tag);}if(tag.textContent!==label)tag.textContent=label;tag.classList.toggle('dune-update-overlay',label==='UPDATE');tag.setAttribute('aria-label',label==='NEW'?'New this release':'Updated this release');}else if(tag)tag.remove();}}fetch('https://cp.dunerealms.com/api/menu-badges',{cache:'no-store'}).then(r=>r.ok?r.json():null).then(data=>{if(Array.isArray(data?.items)){items=data.items;mark();}}).catch(()=>{});mark();new MutationObserver(mark).observe(document.body,{childList:true,subtree:true,characterData:true});})();
/* Shared contextual page banner */
(()=>{if(window.top!==window.self)return;const titles={'dunemark-collection.html':['IMPERIAL POSTBANK','The Dunemark Collection'],'staff.html':['STAFF & ORGANISATION','The people behind the realms'],'government.html':['REALM & POLITICS','Government, Houses and elected offices'],'rates-and-charges.html':['IMPERIAL POSTBANK','Rates & Charges'],'shop.html':['DUNEFORGE SHOP','Goods and services for your journey'],'kits.html':['KIT EXCHANGE','Equip your next adventure'],'exchange.html':['CHOAM EXCHANGE','Trade across the realms'],'discord.html':['COMMUNITY DISCORD','The caravan frequency'],'news.html':['NEWS FROM THE REALM','The Imperial Dispatch'],'news-archive.html':['NEWS ARCHIVE','Dispatches from across the realms']};
function sync(){const marker=document.querySelector('.dune-page-marker');if(!marker)return;if(document.querySelector('.command-banner')){document.querySelector('.dune-context-banner')?.remove();return;}let banner=document.querySelector('.dune-context-banner');if(!banner){banner=document.createElement('section');banner.className='dune-context-banner';const brand=document.createElement('strong');brand.textContent='✦ DuneRealms';const copy=document.createElement('div'),title=document.createElement('span'),sub=document.createElement('small');copy.append(title,sub);banner.append(brand,copy);marker.after(banner);}const file=location.pathname.split('/').pop(),host=location.hostname.split('.')[0],welcome=marker.getAttribute('aria-label')?.replace('Welcome to ','')||'The realms';let context=titles[file]||(['','index.html'].includes(file)&&host==='www'?['HOME','Your journey begins here']:host==='forums'?['COMMUNITY BOARDS','Stories, discussions and community life']:host==='support'?['SUPPORT CENTER','Help for your journey']:host==='clans'?['CLANS & ALLIANCES','Raise your banner']:host==='wiki'?['DUNOPEDIA','Your guide to the realms']:location.pathname.startsWith('/people/')?['CITIZEN PROFILE','The Imperial Citizen Register']:location.pathname.startsWith('/memorial/')?['IN REMEMBRANCE','The community memorial']:['DUNEREALMS',welcome]);const title=banner.children[1].children[0],sub=banner.children[1].children[1];if(title.textContent!==context[0])title.textContent=context[0];if(sub.textContent!==context[1])sub.textContent=context[1];if(marker.nextElementSibling!==banner)marker.after(banner);}
sync();new MutationObserver(sync).observe(document.body,{childList:true,subtree:true});addEventListener('hashchange',sync);})();