Add Company CP, office decision menus and clan directory cards

This commit is contained in:
unimatrixgit 2026-11-16 05:40:07 +01:00
commit 3263573f2f
43 changed files with 754 additions and 36 deletions

View file

@ -1 +1 @@
export function clanCPDocument(source){return source.replace('<title>DuneRealms · Account Centre</title>','<title>DuneRealms · Clan CP</title>').replace(/<header class="dune-site-header">[\s\S]*?<\/header>/,'').replace(/<footer class="site-footer"><\/footer>/,'').replace(/<script src="https:\/\/www\.dunerealms\.com\/portal-navigation\.js" defer><\/script>/,'').replace(/<link rel="stylesheet" href="https:\/\/www\.dunerealms\.com\/portal-navigation\.css">/,'').replace('<body>','<body data-cp-mode="clan" class="clan-cp-shell">').replace(/<section class="command-banner">[\s\S]*?<\/section>/,'').replace('</head>','<link rel="stylesheet" href="/v2/cp-v2-clan-shell.css?v=single-scroll-2"></head>').replace('</body>','<script type="module" src="/v2/cp-v2-clan-size.mjs"></script></body>');}
export function clanCPDocument(source){return source.replace('<title>DuneRealms · Account Centre</title>','<title>DuneRealms · Clan CP</title>').replace(/<header class="dune-site-header">[\s\S]*?<\/header>/,'').replace(/<footer class="site-footer"><\/footer>/,'').replace(/<script src="https:\/\/www\.dunerealms\.com\/portal-navigation\.js" defer><\/script>/,'').replace(/<link rel="stylesheet" href="https:\/\/www\.dunerealms\.com\/portal-navigation\.css">/,'').replace('<body>','<body data-cp-mode="clan" class="clan-cp-shell">').replace(/<section class="command-banner">[\s\S]*?<\/section>/,'').replace('</head>','<link rel="stylesheet" href="/v2/cp-v2-clan-shell.css?v=single-scroll-2"><link rel="stylesheet" href="/v2/cp-v2-claims.css"></head>').replace('</body>','<script type="module" src="/v2/cp-v2-clan-size.mjs"></script></body>');}

View file

@ -33,7 +33,7 @@ export function createClans(db,{origin='https://cp.dunerealms.com',authenticate=
const own=await membership(user.id);
if(request.method==='GET'){
if(!match[1]){
const {results}=await db.prepare('SELECT c.id,c.name,c.tag,c.description,c.home_world,c.version,c.created_at,(SELECT COUNT(*) FROM site_clan_members m WHERE m.clan_id=c.id) AS member_count FROM site_clans c WHERE c.active=1 ORDER BY c.name_key,c.id LIMIT 500').all();
const {results}=await db.prepare('SELECT c.id,c.name,c.tag,c.description,c.home_world,c.version,c.created_at,i.institution_key,i.member_limit,(SELECT COUNT(*) FROM site_clan_members m WHERE m.clan_id=c.id) AS member_count FROM site_clans c LEFT JOIN site_clan_institutions i ON i.clan_id=c.id WHERE c.active=1 ORDER BY c.name_key,c.id LIMIT 500').all();
const {results:applications}=await db.prepare("SELECT r.clan_id,r.status,c.name,c.tag FROM site_clan_requests r JOIN site_clans c ON c.id=r.clan_id WHERE r.user_id=? AND r.status='pending' AND c.active=1 ORDER BY r.created_at DESC").bind(user.id).all();
return json({homeworlds:CLAN_HOMEWORLDS,clans:results.map(row=>({...row,realm:CLAN_HOMEWORLDS.find(w=>w.key===row.home_world)?.realm||null,emblem:clanEmblemUrl(row.id)})),membership:own,applications,linked,username:user.username});
}

View file

@ -0,0 +1,7 @@
import {clanCPDocument} from './clan-cp-shell.mjs';
export function companyCPDocument(source){return clanCPDocument(source)
.replace('<title>DuneRealms · Clan CP</title>','<title>DuneRealms · Company CP</title>')
.replace('data-cp-mode="clan" class="clan-cp-shell"','data-cp-mode="company" class="clan-cp-shell company-cp-shell"')
.replace(/<script src="\/v2\/v2\.js(?:\?[^\"]*)?" defer><\/script>/,'<script type="module" src="/v2/cp-v2-company-shell.mjs"></script>')
.replace('<script type="module" src="/v2/cp-v2-clan-size.mjs"></script>','')
.replace('</head>','<link rel="stylesheet" href="/v2/cp-v2-company-shell.css"></head>');}

View file

@ -0,0 +1,3 @@
export function filterClanDirectory(clans,{query='',world='',kind='',sort='name'}={}){
const q=query.trim().toLowerCase();return clans.filter(c=>(!q||[c.name,c.tag,c.description,c.realm].some(v=>String(v||'').toLowerCase().includes(q)))&&(!world||c.home_world===world)&&(!kind||(kind==='institution'?!!c.institution_key:!c.institution_key))).slice().sort((a,b)=>sort==='members'?Number(b.member_count)-Number(a.member_count)||a.name.localeCompare(b.name):a.name.localeCompare(b.name));
}

View file

@ -6,6 +6,10 @@ html.clan-embedded,body.clan-embedded{height:auto!important;min-height:0!importa
.clan-commerce input[type=color]{min-height:48px;padding:5px;cursor:pointer}
/* Existing directory, presented as illustrated household register cards. */
.clan-center .clan-toolbar{display:grid;grid-template-columns:minmax(180px,2fr) repeat(3,minmax(130px,1fr)) auto;align-items:center;gap:12px}.clan-center .clan-toolbar input,.clan-center .clan-toolbar select{min-width:0;width:100%;box-sizing:border-box;background:#102d26;color:#ece3c8;border:1px solid #927f51;border-radius:6px;padding:12px;font:14px Georgia,serif}.clan-directory-count{color:#cbb887;font:12px Arial,sans-serif;letter-spacing:.04em;margin:20px 0}.clan-center .clan-grid{grid-template-columns:repeat(auto-fill,minmax(min(100%,290px),1fr));gap:22px}.clan-center .clan-card.clan-recruit-card{display:block;padding:0;overflow:hidden;border:3px double #b69a61;border-radius:10px;background:linear-gradient(140deg,#234637,#102c27);box-shadow:0 8px 20px #061a1644}.clan-directory-portrait{position:relative;display:flex;align-items:center;justify-content:center;min-height:185px;background:linear-gradient(#14352b44,#102920b0),url('https://www.dunerealms.com/assets/clan-atelier-v1.webp') center/cover;border-bottom:1px solid #b69a6188}.clan-directory-portrait .clan-directory-crest{display:block;width:140px;height:140px;max-width:75%;object-fit:contain;filter:drop-shadow(0 7px 9px #03161188);border:0;background:none}.clan-directory-portrait>span{position:absolute;bottom:12px;left:16px;font:9px Arial,sans-serif;letter-spacing:.14em;color:#f1d99d}.clan-directory-body{padding:22px}.clan-directory-body .clan-directory-tag{color:#bca76d;font:bold 11px Arial,sans-serif;letter-spacing:.1em}.clan-center .clan-directory-body h3{font:28px/1.1 Georgia,serif;color:#f0d292;margin:9px 0 12px;overflow-wrap:anywhere}.clan-directory-body>p{line-height:1.65;font-size:14px;color:#d0d8c6}.clan-directory-bio{display:-webkit-box;-webkit-line-clamp:4;-webkit-box-orient:vertical;overflow:hidden;min-height:90px}.clan-directory-footer{display:flex;align-items:center;justify-content:space-between;gap:12px;border-top:1px solid #9b875244;padding-top:17px}.clan-directory-footer>span{font:12px Arial,sans-serif;color:#c5bc99}.clan-directory-footer button{white-space:nowrap}.clan-center .clan-toolbar select:focus-visible{outline:3px solid #dcc47c;outline-offset:2px}
@media(max-width:1100px){.clan-center .clan-toolbar{grid-template-columns:repeat(2,minmax(0,1fr))}.clan-center .clan-toolbar>input{grid-column:1/-1}}@media(max-width:600px){.clan-directory-portrait{min-height:170px}.clan-directory-body{padding:18px}.clan-center .clan-toolbar{gap:9px}}
/* Clan portal subpages */
[data-own-clan-card]{position:relative;overflow:hidden;background:linear-gradient(100deg,#1c402fef,#112c24dd),url('https://www.dunerealms.com/assets/sietch.webp') center/cover!important;border-color:#a58c4e!important;padding:24px!important}
.clan-hub-menu{display:flex;flex-wrap:wrap;gap:10px;margin:20px 0}.clan-hub-menu>a,.quest-submenu>a{display:flex;align-items:center;gap:8px;padding:9px 15px;border:1px solid #837343;border-radius:8px;background:linear-gradient(140deg,#244735,#102b24);color:#ead49d;text-decoration:none;font-weight:600;min-height:44px;box-sizing:border-box}.clan-hub-menu img{height:36px;width:36px;object-fit:contain}.clan-hub-menu>a[aria-current=page],.quest-submenu>a[aria-current=page]{border-color:#8db996;box-shadow:inset 0 0 0 1px #69a880;background:#254e39}.clan-hub-menu>a[aria-disabled=true],.quest-submenu>a[aria-disabled=true]{opacity:.45;cursor:not-allowed}.clan-page-hero{display:flex;align-items:center;gap:22px;padding:26px;border:1px solid #a98d49;border-radius:12px;background:linear-gradient(110deg,#183c2fee,#142d25cc),url('https://www.dunerealms.com/assets/sietch.webp') center/cover}.clan-page-hero>img{width:104px;height:104px;object-fit:contain}.clan-page-hero h2{font-size:30px;color:#ead49d;margin:7px 0}.clan-page-hero p:first-child{font-size:10px;letter-spacing:.16em;color:#d8bd77}.clan-page-hero p{color:#ccdbca}.clan-portal-grid,.quest-plan-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,260px),1fr));gap:18px;margin:25px 0}.clan-portal-grid>a,.quest-plan-grid>article{padding:24px;border:1px solid #7e8052;border-radius:12px;background:linear-gradient(135deg,#214633,#102b24);text-decoration:none;color:#d9dfcd}.clan-portal-grid img{width:86px;height:86px;object-fit:contain}.clan-portal-grid h3{color:#e6c781}.clan-shop-card{display:grid;grid-template-columns:minmax(200px,1fr) 1fr;gap:24px;margin:24px 0;border:1px solid #96804c;border-radius:12px;background:#17382b;overflow:hidden}.clan-shop-card>img{width:100%;height:100%;max-height:360px;object-fit:cover}.clan-shop-card>div{padding:24px}.clan-shop-card strong{display:block;color:#e9ca75;font-size:26px;margin:16px 0}.clan-shop-card span:first-child{font-size:11px;color:#8fcd9e;letter-spacing:.1em}.clan-stat-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:14px;margin:24px 0}.clan-stat-grid article{padding:20px;border:1px solid #6b8056;border-radius:10px;background:#1b3c2f}.clan-stat-grid strong{display:block;font-size:28px;color:#e7cc89;margin-top:12px}.clan-stat-grid small{color:#bfcdb9;font-size:10px;letter-spacing:.1em}.clan-stat-grid [data-quality=rare]{border-color:#5c87ab}.clan-stat-grid [data-quality=very_rare]{border-color:#9874b8}.clan-stat-grid [data-quality=legendary]{border-color:#bba04f}.quest-submenu,.quest-preview-filters{display:flex;flex-wrap:wrap;gap:10px;margin:24px 0}.quest-preview-notice{padding:18px;border-left:3px solid #b49850;background:#45402144;margin:22px 0}.quest-preview-notice strong{font-size:11px;letter-spacing:.14em;color:#d8bd77}.quest-plan-grid img{height:84px;width:84px;object-fit:contain;float:right;margin:0 0 15px 15px}.quest-plan-grid small{color:#c0ad76;font-size:10px;letter-spacing:.1em}.quest-plan-grid h3{color:#ead190}.quest-entry-callout>img{width:70px;height:70px;object-fit:contain;float:right}.clan-subpage .clan-form input[type=color]{min-height:48px}.clan-subpage>.clan-details{margin-top:22px}.clan-hub-link{display:inline-block;padding:12px 18px;border:1px solid #a28a4a;border-radius:7px;text-decoration:none;background:#122f24}@media(max-width:650px){.clan-page-hero{padding:18px;gap:12px}.clan-page-hero>img{width:64px;height:64px}.clan-page-hero h2{font-size:24px}.clan-hub-menu>a{flex:1 1 125px;padding:8px 10px}.clan-hub-menu img{width:28px;height:28px}.clan-shop-card{grid-template-columns:1fr}.clan-shop-card>img{max-height:180px}.clan-hub-menu{gap:8px}}

View file

@ -1,3 +1,4 @@
import {filterClanDirectory} from './clan-directory-model.mjs';
import {createClanRequestGate} from './clan-request-gate.mjs';
import {organiseClanProfile} from './clan-profile-panels.mjs';
const gate=createClanRequestGate();
@ -8,9 +9,9 @@ const section=el('section');section.id='clans';section.className='clan-center';s
const hero=el('header'),art=el('img');art.src='https://www.dunerealms.com/assets/nav-clan-v2.webp';art.alt='';art.width=100;art.height=100;
const heroText=el('div');heroText.append(el('p','THE CLAN & QUEST REGISTER'),el('h2','Clans & Quests'),el('p','Raise your banner, manage your clan and plan your next adventure.'));const questArt=el('img');questArt.src='https://www.dunerealms.com/assets/nav-manual-full-v2.webp';questArt.alt='Quest journal';questArt.className='clan-quest-hero-art';hero.append(art,heroText,questArt);
const notice=el('p');notice.role='status';notice.className='clan-notice';const toolbar=el('div');toolbar.className='clan-toolbar';
const refresh=el('button','Refresh clans'),search=el('input');refresh.type='button';search.type='search';search.placeholder='Find a clan by name or tag';search.setAttribute('aria-label','Search clans');toolbar.append(search,refresh);
const refresh=el('button','Refresh clans'),search=el('input');refresh.type='button';search.type='search';search.placeholder='Find a clan by name or tag';search.setAttribute('aria-label','Search clans');const worldFilter=el('select'),kindFilter=el('select'),sortFilter=el('select'),count=el('p');worldFilter.setAttribute('aria-label','Filter clans by homeworld');kindFilter.setAttribute('aria-label','Filter clan type');sortFilter.setAttribute('aria-label','Sort clans');count.setAttribute('role','status');count.className='clan-directory-count';for(const [select,options]of [[worldFilter,[['','All homeworlds'],['kaladam','Kaladam'],['giedermark','Giedermark'],['kaiterhof','Kaiterhof'],['sigmadraken_iv','Sigmadraken IV'],['arrakduin','Arrakduin']]],[kindFilter,[['','All clans'],['clan','Player clans'],['institution','Protected institutions']]],[sortFilter,[['name','Name A–Z'],['members','Largest first']]]])for(const[value,label]of options){const option=el('option',label);option.value=value;select.append(option);}worldFilter.value=kindFilter.value='';sortFilter.value='name';worldFilter.onchange=kindFilter.onchange=sortFilter.onchange=()=>renderDirectory();toolbar.append(search,worldFilter,kindFilter,sortFilter,refresh);
const summary=el('div'),directory=el('div'),details=el('div');directory.className='clan-grid';details.className='clan-details';details.hidden=true;
const scope=el('p','Clans are player factions for combat and PvP roleplay. Companies focus on economic roleplay and trade. Covert operations and in-game clan combat integration are not available yet.');scope.className='clan-scope';section.append(hero,notice,summary,toolbar,directory,details,scope);
const scope=el('p','Clans are player factions for combat and PvP roleplay. Companies focus on economic roleplay and trade. Covert operations and in-game clan combat integration are not available yet.');scope.className='clan-scope';section.append(hero,notice,summary,toolbar,count,directory,details,scope);
let state=null,selected=null,allowed=false,sessionUsername=null,navigation=0;
if(dashboard&&nav){dashboard.append(section);const link=el('a',clanPortalEmbedded?'Clans & Quests':'Quests');link.href=clanPortalEmbedded?'#clans':'#clan-quests';nav.append(link);}
async function api(path='',body){const response=await fetch('/api/clans'+path,{method:body?'POST':'GET',headers:body?{'Content-Type':'application/json'}:{},...(body?{body:JSON.stringify(body)}:{}),cache:'no-store'});const data=await response.json();if(!response.ok){const error=new Error(data.message||'The clan request could not be completed.');error.status=response.status;throw error;}return data;}
@ -34,9 +35,9 @@ async function mutate(button,body,show=true){
}
function field(form,label,key,value='',type='text',maxLength){const box=el('label',label),input=el(type==='textarea'?'textarea':'input');input.name=key;if(type!=='textarea')input.type=type;input.value=value;if(maxLength)input.maxLength=maxLength;box.append(input);form.append(box);return input;}
function clanForm(title,record){const form=el('form');form.className='clan-form';form.append(el('h3',title));const name=field(form,'Clan name','name',record?.name||'','text',40);name.minLength=3;name.required=true;const tag=field(form,'Banner tag · 2–6 letters or numbers','tag',record?.tag||'','text',6);tag.minLength=2;tag.pattern='[A-Za-z0-9]{2,6}';tag.required=true;const description=field(form,'Clan description','description',record?.description||'','textarea',1000);const home=el('select'),label=el('label','Homeworld · determines Realm affiliation');for(const w of [{key:'',name:'No homeworld selected'},...(state?.homeworlds||[])]){const option=el('option',w.name+(w.realm?' · '+w.realm:''));option.value=w.key;home.append(option);}home.value=record?.home_world||'';label.append(home);form.append(label);const save=el('button',record?'Save clan details':'Create clan');save.type='submit';form.append(save);form.onsubmit=event=>{event.preventDefault();mutate(save,{action:record?'edit':'create',...(record?{clanId:record.id,version:Number(record.version)}:{}),name:name.value,tag:tag.value,description:description.value,homeWorld:home.value||null});};return form;}
function renderDirectory(){directory.replaceChildren();if(!state)return;const query=search.value.trim().toLowerCase(),rows=state.clans.filter(clan=>[clan.name,clan.tag,clan.description].some(value=>String(value).toLowerCase().includes(query)));
for(const clan of rows){const card=el('article');card.className='clan-card';const crest=clanEmblem(clan);crest.className='clan-banner-tag clan-emblem';card.append(crest,el('h3',clan.name),el('p',clan.realm||'Realm affiliation awaits a homeworld'),el('p',clan.description||'This clan has not added an introduction yet.'),el('p',Number(clan.member_count)+' members'),button('View clan',()=>showClan(clan.id)));directory.append(card);}
if(!rows.length)directory.append(el('p',state.clans.length?'No clans match your search.':'No clans have been created yet. Raise the first banner.'));
function renderDirectory(){directory.replaceChildren();if(!state)return;const rows=filterClanDirectory(state.clans,{query:search.value,world:worldFilter.value,kind:kindFilter.value,sort:sortFilter.value});count.textContent=rows.length+' '+(rows.length===1?'clan':'clans')+' in the register';
for(const clan of rows){const card=el('article');card.className='clan-card clan-recruit-card';const portrait=el('div');portrait.className='clan-directory-portrait';const crest=clanEmblem(clan);crest.className='clan-directory-crest';portrait.append(crest,el('span',clan.institution_key?'PROTECTED INSTITUTION':'HOUSEHOLD REGISTER'));const body=el('div');body.className='clan-directory-body';const tag=el('small','['+clan.tag+']');tag.className='clan-directory-tag';const bio=el('p',clan.description||'This household has not published an introduction yet.');bio.className='clan-directory-bio';const footer=el('div');footer.className='clan-directory-footer';footer.append(el('span',Number(clan.member_count)+' members'),button('View clan →',()=>showClan(clan.id)));body.append(tag,el('h3',clan.name),el('p',clan.realm||'Independent institution / no homeworld'),bio,footer);card.append(portrait,body);directory.append(card);}
if(!rows.length)directory.append(el('p',state.clans.length?'No clans match these filters. Try another search or homeworld.':'No clans have been registered yet.'));
}
async function load(){const token=gate.begin('directory');if(!allowed||!token)return false;gate.invalidate('detail');refresh.disabled=true;try{const data=await api();if(!gate.current(token)||data.username!==sessionUsername)return false;state=data;summary.replaceChildren();if(!state.linked){const hint=el('aside');hint.className='clan-callout';const link=el('a','Link your Minecraft identity');link.href='#game';hint.append(link,el('p','A verified Minecraft account is required to create, join or manage a clan.'));summary.append(hint);}
if(state.membership){const current=state.clans.find(clan=>clan.id===state.membership.clan_id);const card=el('aside');card.className='clan-callout';card.dataset.ownClanCard='';card.append(el('h3','Your clan · '+(current?.name||'Clan membership')),badge(state.membership.clan_role),button('Open your clan',()=>showClan(state.membership.clan_id)));summary.append(card);}

View file

@ -0,0 +1,3 @@
.claims-banner{background:linear-gradient(90deg,#143a35ed,#142c37ad),url('https://www.dunerealms.com/assets/clan-atelier-v1.webp') center/cover;border:3px double #bba16b;border-radius:8px;padding:28px;color:#f0e0b9}.claims-banner small{letter-spacing:.15em;font:11px Arial,sans-serif}.claims-banner h2{font-size:28px}.claims-notice{border-left:3px solid #bd9f60;padding:12px 18px;background:#102c2c;color:#e9dec4;line-height:1.65}.claims-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px;margin-top:20px}.claims-grid article{border:1px solid #b49a6166;background:linear-gradient(140deg,#234537,#142f32);color:#e8dec6;padding:24px;border-radius:8px}.claims-grid h3{color:#e5c788}.claims-grid p{line-height:1.7}.claims-grid button{padding:10px 16px;border:1px solid #a48d5a;background:#193831;color:#c6b993;border-radius:5px}.claims-grid button:disabled{opacity:.65;cursor:not-allowed}
@media(max-width:720px){.claims-grid{grid-template-columns:1fr}}

View file

@ -0,0 +1,9 @@
import {element as el} from './cp-v2-page-template.mjs';
export function mountClaims(host,{kind='clan',name='Your organisation'}={}){
const root=el('section',undefined,'claims-workspace'),hero=el('div',undefined,'claims-banner');hero.append(el('small','LAND & ESTATES'),el('h2',name+' · Claims'),el('p',kind==='company'?'Company premises and Charter Beacons.':'Clan estates, Home Standards and outposts.'));
root.append(hero,el('p','Land claims are coming soon. No land is reserved and no payment is taken from this page.','claims-notice'));
const grid=el('div',undefined,'claims-grid');
for(const [title,copy,action]of [['Estates','Your registered land and ownership records will appear here.','Register estate'],['Anchors',kind==='company'?'Manage your company’s Charter Beacons.':'Manage your Home Standard and Outpost Standards.','Manage anchors'],['Boundaries','Preview estate borders and check neighbouring claims before confirming changes.','Preview boundaries'],['Upgrades & upkeep','Review expansion requirements, organisation costs and upkeep before confirming.','Review upgrades']]){
const card=el('article',undefined,'claims-card'),button=el('button',action);button.type='button';button.disabled=true;button.title='Coming soon';card.append(el('h3',title),el('p',copy),el('strong','Coming soon'),button);grid.append(card);
}root.append(grid);host.replaceChildren(root);return()=>root.remove();
}

View file

@ -0,0 +1,4 @@
export const COMPANY_MENU=Object.freeze([
['overview','Company Overview'],['people','People & Roles'],['treasury','Treasury'],['commerce','Commerce & Contracts'],['claims','Claims'],['acquisitions','Sale & Acquisitions'],['subsidiaries','Subsidiaries'],['projects','Projects & Quests'],['settings','Company Settings']
]);
export function companyPage(hash=''){const parts=hash.replace(/^#/,'').split('/');const page=parts.at(-1);return COMPANY_MENU.some(([id])=>id===page)?page:'overview';}

View file

@ -0,0 +1,10 @@
.company-cp-shell{--guild-ink:#122c32;--guild-blue:#224650;--guild-gold:#d4b779;--guild-text:#eee4ca;background:#0b2026;color:var(--guild-text);font-family:Georgia,serif}
.company-cp-shell .layout{grid-template-columns:230px minmax(0,1fr) 230px}.company-cp-shell .content{background:linear-gradient(#112a32ed,#0d2029f7),url('https://www.dunerealms.com/assets/political-imperial-chamber-v1.png') center/cover;color:var(--guild-text);min-width:0}
.company-cp-shell .side{background:linear-gradient(#14343ce8,#0c222aed),url('https://www.dunerealms.com/assets/corrino-charter-v2.png') center/cover;border-color:#a58b52}.company-cp-shell .side-hero{background:#173b45;color:#efd49b}.company-cp-shell .category-block{background:#18333b;border-color:#a58b52}.company-cp-shell .category-heading{background:#244854;color:#f0d9ac}.company-cp-shell .navitem{color:#e9dfc8;border-color:#a58b5255;text-decoration:none;position:relative}.company-cp-shell .navitem:hover,.company-cp-shell .navitem[aria-current=page]{background:linear-gradient(90deg,#79663788,#244854);color:#ffe9b4}
.company-cp-shell .company-switcher{display:flex;align-items:center;gap:18px;background:linear-gradient(90deg,#183943,#122931);border-bottom:3px double #c9ab6a;padding:16px 28px}.company-switcher>img{width:64px;height:64px;object-fit:contain}.company-switcher label{display:grid;gap:8px;color:#e5c78a;font-size:13px;text-transform:uppercase;letter-spacing:.07em}.company-cp-shell select{min-width:min(320px,65vw);max-width:100%;background:#0f2830;color:#f4e8ca;border:1px solid #b1985c;border-radius:6px;padding:11px;font:16px Georgia,serif}
.company-cp-shell .hero.company-hero{background:linear-gradient(90deg,#214550ee,#122a34e6),url('https://www.dunerealms.com/assets/political-imperial-chamber-v1.png') center/cover;border:4px double #bda066;box-shadow:inset 0 0 0 4px #294752;min-height:170px}.company-hero small{font:11px Arial,sans-serif;letter-spacing:.13em;color:#dfc184}.company-cp-shell .company-hero h1{color:#ffe2a6}.company-cp-shell .hero>img{width:105px;height:105px;max-height:110px;object-fit:contain}.company-cp-shell .hero p{color:#e5ddc9}
.company-cp-shell .cards>.card{border:4px double #bda066;background:linear-gradient(140deg,#24434b,#142e37);color:#eee4ce;box-shadow:inset 0 0 0 4px #182e36}.company-cp-shell .card h2,.company-cp-shell .card h3{color:#edcf91}.company-cp-shell .card p{color:#e0d9c5;line-height:1.7}.company-charter{background:linear-gradient(90deg,#122a32dd,#162c35aa),url('https://www.dunerealms.com/assets/corrino-charter-v2.png') center/cover;padding:32px;border:1px solid #b69a60;border-radius:8px}.company-charter small{color:#e2c384;font:11px Arial,sans-serif;letter-spacing:.14em}
.company-facts{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;margin:22px 0}.company-facts article{padding:20px;background:#112a33;border:1px solid #9a865755;border-radius:7px;display:grid;gap:9px;overflow-wrap:anywhere}.company-facts small{color:#c8b27e;font:12px Arial,sans-serif;text-transform:uppercase}.company-record{margin:16px;padding:18px;background:#12303abf;border:1px solid #a68a5355;border-radius:7px}.company-record h3{color:#e4c98e}.company-record p{font-size:14px;line-height:1.65;color:#d6d2bf}.company-primary-link{display:inline-block;border:1px solid #c4a86c;padding:12px 22px;border-radius:6px;color:#f1d99b;background:#173841;text-decoration:none}.company-cp-shell a:focus-visible,.company-cp-shell button:focus-visible,.company-cp-shell select:focus-visible{outline:3px solid #e7c883;outline-offset:3px}
.claims-banner{background:linear-gradient(90deg,#143a35ed,#142c37ad),url('https://www.dunerealms.com/assets/clan-atelier-v1.webp') center/cover;border:3px double #bba16b;border-radius:8px;padding:28px;color:#f0e0b9}.claims-banner small{letter-spacing:.15em;font:11px Arial,sans-serif}.claims-banner h2{font-size:28px}.claims-notice{border-left:3px solid #bd9f60;padding:12px 18px;background:#102c2c;color:#e9dec4;line-height:1.65}.claims-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px;margin-top:20px}.claims-grid article{border:1px solid #b49a6166;background:linear-gradient(140deg,#234537,#142f32);color:#e8dec6;padding:24px;border-radius:8px}.claims-grid h3{color:#e5c788}.claims-grid p{line-height:1.7}.claims-grid button{padding:10px 16px;border:1px solid #a48d5a;background:#193831;color:#c6b993;border-radius:5px}.claims-grid button:disabled{opacity:.65;cursor:not-allowed}
@media(max-width:1100px){.company-cp-shell .layout{grid-template-columns:190px minmax(0,1fr)}.company-cp-shell .side-right{grid-column:1/-1;display:grid;grid-template-columns:1fr 1fr}.company-cp-shell .side-right>.side-hero{grid-column:1/-1}}
@media(max-width:720px){.company-cp-shell .layout{display:block}.company-cp-shell .side-right{display:none}.company-cp-shell .side-right.open{display:block}.company-facts,.claims-grid{grid-template-columns:1fr}.company-cp-shell .company-switcher{padding:12px 16px}.company-cp-shell .company-hero{padding:22px}.company-cp-shell .hero>img{width:72px}.company-cp-shell .hero h1{font-size:29px}}

View file

@ -0,0 +1,39 @@
import {startCPAuthentication} from './cp-v2-auth.mjs';
import {element as el} from './cp-v2-page-template.mjs';
import {COMPANY_MENU,companyPage} from './cp-v2-company-navigation.mjs';
import {mountClaims} from './cp-v2-claims.mjs';
import {watchMenuHighlights} from './cp-v2-menu-highlights.mjs';
const outer='https://corp.dunerealms.com',assets='https://www.dunerealms.com/assets/',content=document.querySelector('#content'),left=document.querySelector('#sidebar'),right=document.querySelector('#sidebar-right'),portals=document.querySelector('#portals');
let companies=[],selected=null,ready=false,dispose=()=>{};
const picture=(src,cls='')=>{const image=el('img',undefined,cls);image.src=assets+src;image.alt='';return image;};
function measure(){if(parent!==window){const height=Math.ceil(document.body.scrollHeight)+2;if(height>=100&&height<=200000)parent.postMessage({type:'dune-embed-size',height},outer);}}
const observer=new ResizeObserver(()=>requestAnimationFrame(measure));observer.observe(document.body);
window.addEventListener('message',event=>{if(event.source===parent&&event.origin===outer&&event.data?.type==='dune-embed-measure')measure();});
function render(){
if(!ready)return;dispose();dispose=()=>{};const page=companyPage(location.hash),company=companies.find(c=>c.id===selected),label=COMPANY_MENU.find(([id])=>id===page)[1];
left.replaceChildren(el('div','COMPANY AFFAIRS','side-hero'));right.replaceChildren(el('div','THE CORPORATE LEDGER','side-hero'));portals.replaceChildren();portals.classList.add('company-switcher');
const selector=el('select'),selectionLabel=el('label','Your companies');selector.setAttribute('aria-label','Choose your company');for(const item of companies){const option=el('option',item.name);option.value=item.id;selector.append(option);}selector.value=selected||'';selector.disabled=!companies.length;selector.onchange=()=>{selected=selector.value;const url=new URL(location.href);url.searchParams.set('company',selected);history.replaceState(null,'',url);render();};selectionLabel.append(selector);portals.append(picture('guild.webp'),selectionLabel);
const group=el('section',undefined,'category-block');group.append(el('div','Company workspace','category-heading'));for(const[id,title]of COMPANY_MENU){const link=el('a',title,'navitem');link.href='#company/'+id;link.dataset.menuHref=outer+'/#company/'+id;if(id===page)link.setAttribute('aria-current','page');group.append(link);}left.append(group);
const back=el('a','← Account Centre','navitem');back.href='https://cp.dunerealms.com/';back.target='_top';left.append(back);
const identity=el('section',undefined,'company-record');identity.append(picture('corrino-charter-v2.png'),el('h2',company?.name||'Company CP'),el('p',company?company.role+' · '+company.status:'Your corporate workspace'),el('p','A charter. A purpose. A place among the stars.'));right.append(identity);
const guide=el('section',undefined,'company-record');guide.append(el('h3','Charters & estates'),el('p','Company land will belong to the organisation. Officers, boundaries and estate upgrades will be managed here.'));right.append(guide);
const hero=el('header',undefined,'hero company-hero'),copy=el('div');copy.append(el('small','VAERKRING · COMMERCE & ENTERPRISE'),el('h1',label),el('p',company?.name||'Select an enterprise to open its workspace.'));hero.append(picture('guild.webp'),copy);
const cards=el('div',undefined,'cards'),card=el('article',undefined,'card full citizen-page-full'),host=el('div',undefined,'citizen-live-host');card.append(host);cards.append(card);content.replaceChildren(hero,cards);
if(!company){host.append(el('h2','Your enterprise starts here'),el('p','No company is currently registered with you as founder or CEO. Your companies will appear here when the registry grants you access.'));}
else if(page==='claims')dispose=mountClaims(host,{kind:'company',name:company.name});
else if(page==='overview'){
const banner=el('section',undefined,'company-charter');banner.append(el('small','REGISTERED ENTERPRISE'),el('h2',company.name),el('p',company.description||'The company charter has no description yet.'));host.append(banner);
const grid=el('div',undefined,'company-facts');for(const [key,value]of [['Registry',company.slug],['Standing',company.status],['Founder',company.founder_name||'Not listed'],['CEO',company.ceo_name||'Not appointed']]){const tile=el('article');tile.append(el('small',key),el('strong',value));grid.append(tile);}host.append(grid);
const claims=el('a','Explore Claims →','company-primary-link');claims.href='#company/claims';host.append(claims);
}else{
const descriptions={people:'Company officers, members and their responsibilities will be managed here.',treasury:'Company accounts and obligations remain in Imperial Postbank. Your estate budgets and upkeep will appear here.',commerce:'Company procurement, contracts and trading permissions will be gathered here.',acquisitions:'Company sales are coming soon. A player may found one company; selling it does not restore that allowance. Further companies can be acquired by purchase.',subsidiaries:'Bought companies remain separate, keeping their records, claims and loans. Previous owners retain access; special powers and final management authority pass to the mother company.',projects:'Company quests, commissions and shared projects will appear here.',settings:'Company charter settings and role permissions will be managed here.'};
const panel=el('section',undefined,'company-planned');panel.append(picture(page==='treasury'?'imperial-postbank-v2.png':'corrino-founding-marks-v1.png'),el('small','COMING SOON'),el('h2',label),el('p',descriptions[page]));host.append(panel);
if(page==='treasury'){const bank=el('a','Open Imperial Postbank →','company-primary-link');bank.href='https://cp.dunerealms.com/#bank/personal-bank';bank.target='_top';host.append(bank);}
}
const route='company/'+page;history.replaceState(null,'','#'+route);if(parent!==window)parent.postMessage({type:'dune-company-route',page,company:selected},outer);left.classList.remove('open');right.classList.remove('open');document.querySelector('#mobile-menu').setAttribute('aria-expanded','false');measure();
}
document.querySelector('#mobile-menu').onclick=()=>{const open=left.classList.toggle('open');right.classList.toggle('open',open);document.querySelector('#mobile-menu').setAttribute('aria-expanded',String(open));};
window.addEventListener('hashchange',render);const stopBadges=watchMenuHighlights(document.body);window.addEventListener('pagehide',()=>{dispose();observer.disconnect();stopBadges();},{once:true});
startCPAuthentication(async()=>{
content.replaceChildren(el('p','Opening your company register…'));try{const query=new URL(location.href).searchParams.get('company'),r=await fetch('/api/companies/workspace'+(query?'?company='+encodeURIComponent(query):''),{cache:'no-store',credentials:'same-origin'}),data=await r.json();if(!r.ok)throw Error(data.message||'Company register unavailable.');companies=data.companies;selected=data.selected;ready=true;render();}catch(error){content.replaceChildren(el('p',error.message));}
});

View file

@ -1,6 +1,6 @@
import {createCPV2ContentPage,element as el} from './cp-v2-page-template.mjs';
const assets='https://www.dunerealms.com/assets/';
const scopes={header:{title:'Main header',copy:'Public navigation · News & Media publishers',art:'nav-home-v2.webp'},cp:{title:'Control Panel',copy:'Personal workspace tiles · Big Four + official Owner alias',art:'nav-account-v2.webp'},clan:{title:'Clan Control Panel',copy:'Household workspace tiles · Big Four + official Owner alias',art:'nav-clan-v2.webp'}};
const scopes={corp:{title:'Company Control Panel',copy:'Company workspace menus · existing 4.1 access',art:'guild.webp'},pol:{title:'Political Control Panel',copy:'Chambers, offices and decisions · existing 4.1 access',art:'seals/office-landsraad.png'},header:{title:'Main header',copy:'Public navigation · News & Media publishers',art:'nav-home-v2.webp'},cp:{title:'Control Panel',copy:'Personal workspace tiles · Big Four + official Owner alias',art:'nav-account-v2.webp'},clan:{title:'Clan Control Panel',copy:'Household workspace tiles · Big Four + official Owner alias',art:'nav-clan-v2.webp'}};
export function mountMenuBadges(host,{fetcher=fetch}={}){
const frame=createCPV2ContentPage({host,title:'Menu badges',description:'Choose the highlights. Preview the menu. Publish when ready.',artwork:'nav-manual-v2.webp',reload:()=>load()});frame.root.classList.add('mb-page');
let disposed=false,revision=0;
@ -24,6 +24,6 @@ export function mountMenuBadges(host,{fetcher=fetch}={}){
form.onsubmit=async event=>{event.preventDefault();save.disabled=true;notice.textContent='Publishing…';try{const response=await fetcher('/api/staff/menu-badges',{method:'PUT',headers:{'Content-Type':'application/json'},body:JSON.stringify({scope:key,revision,items:choices})}),data=await response.json();if(!response.ok)throw Error(data.message||'Could not publish.');revision=data.revision;notice.textContent='Published. Refresh the destination page to see your badges.';}catch(error){notice.textContent=error.message;}finally{save.disabled=false;}};
return box;
}
async function load(){frame.status.hidden=false;frame.status.textContent='Opening menu settings…';try{const response=await fetcher('/api/staff/menu-badges',{cache:'no-store'}),data=await response.json();if(!response.ok)throw Error(data.message||'Menu settings unavailable.');if(disposed)return;revision=data.revision;const grid=el('div',undefined,'mb-workspaces');for(const key of ['header','cp','clan'])grid.append(section(key,data.scopes[key],data.editableScopes.includes(key)));frame.content.replaceChildren(grid);frame.status.hidden=true;}catch(error){if(!disposed){frame.status.hidden=false;frame.status.textContent=error.message;}}}
async function load(){frame.status.hidden=false;frame.status.textContent='Opening menu settings…';try{const response=await fetcher('/api/staff/menu-badges',{cache:'no-store'}),data=await response.json();if(!response.ok)throw Error(data.message||'Menu settings unavailable.');if(disposed)return;revision=data.revision;const grid=el('div',undefined,'mb-workspaces');for(const key of ['header','cp','clan','corp','pol'])grid.append(section(key,data.scopes[key],data.editableScopes.includes(key)));frame.content.replaceChildren(grid);frame.status.hidden=true;}catch(error){if(!disposed){frame.status.hidden=false;frame.status.textContent=error.message;}}}
load();return()=>{disposed=true;frame.root.remove();};
}

View file

@ -0,0 +1,11 @@
// Workspace badges use the existing public badge catalogue and publisher rules.
export function watchMenuHighlights(root,{fetcher=fetch}={}){
let active=true,items=[];const refresh=()=>{
for(const link of root.querySelectorAll('[data-menu-href]')){
const value=items.find(x=>x.href===link.dataset.menuHref)?.badge;let tag=link.querySelector('.dune-new-overlay');
if(['NEW','UPDATE'].includes(value)){if(!tag){tag=document.createElement('span');tag.className='dune-new-overlay';link.append(tag);}if(tag.textContent!==value)tag.textContent=value;tag.classList.toggle('dune-update-overlay',value==='UPDATE');}else tag?.remove();
}
};const observer=new MutationObserver(refresh);observer.observe(root,{childList:true,subtree:true});
fetcher('/api/menu-badges',{cache:'no-store'}).then(r=>r.ok?r.json():null).then(data=>{if(active&&Array.isArray(data?.items)){items=data.items;refresh();}}).catch(()=>{});
return()=>{active=false;observer.disconnect();};
}

View file

@ -0,0 +1,5 @@
import {element as el} from './cp-v2-page-template.mjs';
export function mountPatronage(host){
const root=el('section',undefined,'claims-workspace'),hero=el('div',undefined,'claims-banner');hero.append(el('small','HOUSEHOLD PATRONAGE'),el('h2','Seek a Patron · Offer Patronage'),el('p','Join a larger clan as a distinct subhouse, or offer smaller households your patronage.'));root.append(hero,el('p','The Patronage Directory is coming soon. No allegiance or authority changes can be made here yet.','claims-notice'));
const grid=el('div',undefined,'claims-grid');for(const [title,copy]of [['Seeking Patronage','Smaller clans will be able to publish a voluntary petition to join a larger household.'],['Offering Patronage','Larger clans will be able to publish their terms and consider incoming petitions.'],['Terms of Allegiance','A subhouse keeps its identity, land and member access. Political powers and its organisation vote pass to the ruling clan; personal voting rights remain absolute.'],['Freedom & Independence','Independence may be bought or won through a defined rebellion. Release removes the automatic parent bank mandates and restores independent organisation powers.']]){const card=el('article');card.append(el('h3',title),el('p',copy));grid.append(card);}root.append(grid);host.replaceChildren(root);return()=>root.remove();
}

View file

@ -1,9 +1,11 @@
import {mountPatronage} from './cp-v2-patronage.mjs';
import {mountClaims} from './cp-v2-claims.mjs';
import {mountClanBank} from './cp-v2-clan-bank.mjs';
import {element as el} from './cp-v2-page-template.mjs';
import {mountNativeService} from './cp-v2-native-services.mjs';
import {mountUserPage} from './cp-v2-user-pages.mjs';
export function mountPlayWorkspace(host,workspace,id,options={}){
if(workspace==='clan'){if(id==='clan-bank')return mountClanBank(host,options);
if(workspace==='clan'){if(id==='clan-patronage')return mountPatronage(host);if(id==='clan-claims')return mountClaims(host,{kind:'clan'});if(id==='clan-subhouses'){const panel=el('section',undefined,'claims-workspace');panel.append(el('h2','Subhouses'),el('p','Clan allegiance, independence and rebellion are coming soon. Subhouses retain their identity, land and local access; political powers and final authority belong to the ruling clan.'),el('strong','Coming soon'));for(const title of ['Buy Independence','Rebel']){const button=el('button',title);button.type='button';button.disabled=true;panel.append(button);}host.replaceChildren(panel);return()=>panel.remove();}if(id==='clan-bank')return mountClanBank(host,options);
const registry={'clan-overview':'overview','clan-roster':'roster','clan-requests':'requests','clan-settings':'settings','clan-directory':'directory'};
if(registry[id])return mountNativeService(host,'clans',{...options,singleHeading:true,initialTab:registry[id]});
if(id==='clan-mail')return mountNativeService(host,'shared-inbox',{...options,singleHeading:true,initialTab:'clan-inbox'});

View file

@ -0,0 +1,459 @@
// Proposed office powers. Catalogue entries do not confer authority.
export const POLICY_OFFICES=Object.freeze([
{
"id": "emperor",
"label": "Emperor",
"art": "seals/emperor-v1.png",
"actions": [
{
"id": "emperor-1",
"category": "economic",
"kind": "Decision",
"title": "Imperial Tariff",
"effect": "Add capped Exchange charges by item/category; credit Imperial Treasury."
},
{
"id": "emperor-2",
"category": "economic",
"kind": "Decision",
"title": "Declare Contraband",
"effect": "Ban named goods from legal listings/purchases empire-wide, without deleting possession."
},
{
"id": "emperor-3",
"category": "economic",
"kind": "Decision",
"title": "Imperial Asset Freeze",
"effect": "Block outgoing payments/withdrawals for named clan/House/world/company entity accounts."
},
{
"id": "emperor-4",
"category": "economic",
"kind": "Decision",
"title": "Commercial Embargo",
"effect": "Block named entity from legal Exchange buying/selling."
},
{
"id": "emperor-5",
"category": "political",
"kind": "Decision",
"title": "Suspend Arms and Kit Sales",
"effect": "Block new purchases of selected kits/sellers temporarily; paid receipts remain valid."
},
{
"id": "emperor-6",
"category": "political",
"kind": "Decision",
"title": "Imperial Travel Interdict",
"effect": "Restrict specified interworld routes through game/proxy enforcement."
},
{
"id": "emperor-7",
"category": "political",
"kind": "Decision",
"title": "Grant Resource Monopoly",
"effect": "Appoint/replace legal spice/water trading House, extending existing appointments."
},
{
"id": "emperor-8",
"category": "communal",
"kind": "Decision",
"title": "Emergency Exemption",
"effect": "Permit specified relief goods, suppliers or journeys through restrictions."
},
{
"id": "emperor-9",
"category": "political",
"kind": "Decision",
"title": "Sanction a House War",
"effect": "Recognise a House/world conflict with objectives and preparation."
},
{
"id": "emperor-10",
"category": "political",
"kind": "Decision",
"title": "Demand Imperial Ceasefire",
"effect": "Issue ultimatum; refusal enables defined sanctions; compulsory power requires constitution."
},
{
"id": "emperor-11",
"category": "economic",
"kind": "Decision",
"title": "Wartime Sanctions",
"effect": "Apply targeted freezes, embargoes or kit restrictions to belligerents."
},
{
"id": "emperor-12",
"category": "communal",
"kind": "Decision",
"title": "Protected World",
"effect": "Designate agreed neutral ground, enforced through explicit war rules."
}
]
},
{
"id": "house",
"label": "House Leaders / Landsraad",
"art": "seals/office-landsraad.png",
"actions": [
{
"id": "house-1",
"category": "economic",
"kind": "Decision",
"title": "World Import Duty",
"effect": "Tax qualifying purchases from another origin into own jurisdiction."
},
{
"id": "house-2",
"category": "economic",
"kind": "Decision",
"title": "Local Contraband Order",
"effect": "Ban specified legal imports/exports within own jurisdiction."
},
{
"id": "house-3",
"category": "economic",
"kind": "Decision",
"title": "World Export Embargo",
"effect": "Stop selected local-origin exports while allowing domestic trade."
},
{
"id": "house-4",
"category": "economic",
"kind": "Decision",
"title": "Freeze Local Corporate Assets",
"effect": "Target locally registered company accounts under defined authority."
},
{
"id": "house-5",
"category": "economic",
"kind": "Decision",
"title": "Suspend Local Trading Licence",
"effect": "Temporarily exclude a local company from legal Exchange."
},
{
"id": "house-6",
"category": "political",
"kind": "Decision",
"title": "Close World Entry",
"effect": "Block ordinary arrivals; departure/exemptions explicitly defined."
},
{
"id": "house-7",
"category": "political",
"kind": "Decision",
"title": "Restrict Military Kit Sales",
"effect": "Restrict new designated kit sales in jurisdiction."
},
{
"id": "house-8",
"category": "communal",
"kind": "Decision",
"title": "Essential Supplies Exemption",
"effect": "Exempt necessities from own tariffs/bans temporarily."
},
{
"id": "house-9",
"category": "political",
"kind": "Decision",
"title": "Declare House War",
"effect": "Publish target, objective and notice period."
},
{
"id": "house-10",
"category": "political",
"kind": "Decision",
"title": "Encourage Clan Hostilities",
"effect": "Offer funded support; clan independently accepts and declares."
},
{
"id": "house-11",
"category": "political",
"kind": "Decision",
"title": "Military Alliance",
"effect": "Invite another House to join a conflict voluntarily."
},
{
"id": "house-12",
"category": "political",
"kind": "Decision",
"title": "Offer Peace / Ceasefire",
"effect": "Propose explicit temporary truce or final settlement."
}
]
},
{
"id": "bene",
"label": "Veiled Concord",
"art": "seals/office-landsraad.png",
"actions": [
{
"id": "bene-1",
"category": "economic",
"kind": "Decision",
"title": "Financial Investigation",
"effect": "Restricted scoped view of recorded organisational transactions."
},
{
"id": "bene-2",
"category": "economic",
"kind": "Decision",
"title": "Preservation Hold",
"effect": "Request short asset hold requiring independent authorised confirmation."
},
{
"id": "bene-3",
"category": "economic",
"kind": "Decision",
"title": "Investigate Sanctions Evasion",
"effect": "Examine recorded legal trades; do not pretend physical cash is visible."
},
{
"id": "bene-4",
"category": "political",
"kind": "Decision",
"title": "Inspection Warrant",
"effect": "Authorise limited contraband checkpoint operation; inspection system is new work."
},
{
"id": "bene-5",
"category": "political",
"kind": "Decision",
"title": "Expose Covert Operation",
"effect": "Investigate scheme sponsor using genuine evidence records."
},
{
"id": "bene-6",
"category": "political",
"kind": "Decision",
"title": "Protect Institution",
"effect": "Temporary counterintelligence for named organisation/institution."
},
{
"id": "bene-7",
"category": "political",
"kind": "Decision",
"title": "Review Emergency Sanction",
"effect": "Trigger review; repeal belongs to designated deciding authority."
},
{
"id": "bene-8",
"category": "communal",
"kind": "Decision",
"title": "Humanitarian Passage Petition",
"effect": "Seek beneficiary-specific exceptions from responsible authority."
},
{
"id": "bene-9",
"category": "political",
"kind": "Decision",
"title": "Peace Conference",
"effect": "Negotiate ceasefire, reparations, restrictions and guarantees."
},
{
"id": "bene-10",
"category": "political",
"kind": "Scheme",
"title": "Incite Clan Rivalry",
"effect": "Secretly sponsor a conflict proposal; never force a clan to fight."
},
{
"id": "bene-11",
"category": "political",
"kind": "Scheme",
"title": "Expose War Sponsor",
"effect": "Investigate and disclose verified covert funding evidence."
},
{
"id": "bene-12",
"category": "communal",
"kind": "Decision",
"title": "Humanitarian Truce",
"effect": "Seek agreement for relief/evacuation protection."
}
]
},
{
"id": "guild",
"label": "Vaerkring",
"art": "seals/office-guild_staff.png",
"actions": [
{
"id": "guild-1",
"category": "economic",
"kind": "Decision",
"title": "Route Surcharge",
"effect": "Temporarily increase specified Guild fare."
},
{
"id": "guild-2",
"category": "economic",
"kind": "Decision",
"title": "Preferential Passage",
"effect": "Accepted fare concessions for named organisations."
},
{
"id": "guild-3",
"category": "economic",
"kind": "Decision",
"title": "Carrier Embargo",
"effect": "Deny Guild transport to named organisation members."
},
{
"id": "guild-4",
"category": "political",
"kind": "Decision",
"title": "Close Route",
"effect": "Close a specified pair of world connections."
},
{
"id": "guild-5",
"category": "political",
"kind": "Decision",
"title": "Isolate World",
"effect": "Suspend normal arrivals/departures with emergency exceptions."
},
{
"id": "guild-6",
"category": "political",
"kind": "Decision",
"title": "Permit-Only Passage",
"effect": "Require active permit for chosen route/world."
},
{
"id": "guild-7",
"category": "political",
"kind": "Decision",
"title": "Revoke Passage Privileges",
"effect": "Suspend special concessions, not personal identity."
},
{
"id": "guild-8",
"category": "communal",
"kind": "Decision",
"title": "Evacuation Corridor",
"effect": "Allow one-way departures during restrictions."
},
{
"id": "guild-9",
"category": "economic",
"kind": "Decision",
"title": "Wartime Blockade",
"effect": "Close specified routes to belligerents."
},
{
"id": "guild-10",
"category": "political",
"kind": "Decision",
"title": "Military Passage",
"effect": "Permit named forces on routes; destination sovereignty still checked."
},
{
"id": "guild-11",
"category": "communal",
"kind": "Decision",
"title": "Neutral Evacuation Routes",
"effect": "Protected civilian journeys in conflict."
},
{
"id": "guild-12",
"category": "economic",
"kind": "Decision",
"title": "Peace Concessions",
"effect": "Offer fare reductions conditional on accepted ceasefire."
}
]
},
{
"id": "clan-delegate",
"label": "Clan Delegate",
"art": "nav-clan-v2.webp",
"actions": [
{
"id": "clan-delegate-1",
"category": "economic",
"kind": "Decision",
"title": "Clan Trade Pact",
"effect": "Participating-clan concessions; taxing office confirms exemptions."
},
{
"id": "clan-delegate-2",
"category": "economic",
"kind": "Decision",
"title": "Collective Procurement Embargo",
"effect": "Restrict participating official procurement, not involuntary personal trading."
},
{
"id": "clan-delegate-3",
"category": "economic",
"kind": "Decision",
"title": "Clan Treasury Safeguard",
"effect": "Short hold for authenticated leadership dispute with independent approval."
},
{
"id": "clan-delegate-4",
"category": "economic",
"kind": "Decision",
"title": "Suspend Collective Funding",
"effect": "Stop future discretionary programme payments; preserve completed obligations."
},
{
"id": "clan-delegate-5",
"category": "political",
"kind": "Decision",
"title": "Clan Sanctions Motion",
"effect": "Clan ballot requesting council sanction."
},
{
"id": "clan-delegate-6",
"category": "political",
"kind": "Decision",
"title": "Withdraw Shared Kit Sales",
"effect": "Pause programme-owned kit sales only."
},
{
"id": "clan-delegate-7",
"category": "communal",
"kind": "Decision",
"title": "Emergency Supply Compact",
"effect": "Pool committed funds for permitted relief supplies."
},
{
"id": "clan-delegate-8",
"category": "communal",
"kind": "Decision",
"title": "Sponsor Relief Passage",
"effect": "Fund Guild permits/evacuation for eligible members."
},
{
"id": "clan-delegate-9",
"category": "political",
"kind": "Decision",
"title": "Recognise Clan Feud",
"effect": "Register valid clan war and objectives."
},
{
"id": "clan-delegate-10",
"category": "political",
"kind": "Decision",
"title": "Rally Clan Coalition",
"effect": "Invite clan leaders to accept participation."
},
{
"id": "clan-delegate-11",
"category": "political",
"kind": "Decision",
"title": "Broker Clan Ceasefire",
"effect": "Present truce for belligerents to accept."
},
{
"id": "clan-delegate-12",
"category": "communal",
"kind": "Decision",
"title": "Peace Assembly",
"effect": "Negotiate settlement and reconstruction."
}
]
}
]);
export const POLICY_CATEGORIES=Object.freeze([["economic","Economic"],["political","Political"],["communal","Communal"]]);

View file

@ -0,0 +1,29 @@
import {element as el} from './cp-v2-page-template.mjs';
import {POLICY_OFFICES,POLICY_CATEGORIES} from './cp-v2-policy-catalogue.mjs';
export function policyActions(office,category,query=''){
const q=query.trim().toLowerCase();return (POLICY_OFFICES.find(o=>o.id===office)?.actions||[]).filter(a=>a.category===category&&(!q||(a.title+' '+a.effect).toLowerCase().includes(q)));
}
export function mountPolicyDecisions(host,officeId){
const office=POLICY_OFFICES.find(o=>o.id===officeId);if(!office)throw Error('Unknown office');
const root=el('section',undefined,'policy-office'),intro=el('aside',undefined,'policy-intro'),nav=el('div',undefined,'policy-tabs'),tools=el('div',undefined,'policy-tools'),search=el('input'),standing=el('select'),panel=el('section');
intro.append(el('strong','THE POWERS OF '+office.label.toUpperCase()),el('p','Explore the proposed decisions and schemes for this office. These powers are coming soon; no order can be enacted here yet.'));
nav.setAttribute('role','tablist');nav.setAttribute('aria-label','Decision categories');panel.id='policy-category-panel';panel.setAttribute('role','tabpanel');
search.type='search';search.placeholder='Search decisions and schemes';search.setAttribute('aria-label',search.placeholder);standing.setAttribute('aria-label','Order status');
for(const [value,label]of [['catalogue','Planned catalogue'],['active','Active orders'],['history','History']]){const option=el('option',label);option.value=value;standing.append(option);}standing.value='catalogue';
let category='economic';const buttons=[];
function render(){
for(const {button,id}of buttons){button.setAttribute('aria-selected',String(category===id));button.tabIndex=category===id?0:-1;}
panel.setAttribute('aria-labelledby','policy-tab-'+category);panel.replaceChildren();
if(standing.value!=='catalogue'){panel.append(el('p',standing.value==='active'?'Active orders will appear here when these powers become available.':'Decisions and their outcomes will be recorded here when these powers become available.','policy-empty'));return;}
const rows=policyActions(officeId,category,search.value);
for(const action of rows){
const row=el('article',undefined,'policy-row'),art=el('div',undefined,'policy-row-art'),seal=el('img'),body=el('div',undefined,'policy-row-body'),badge=el('span','Coming soon','policy-coming'),button=el('button','Prepare '+action.kind.toLowerCase());
seal.src='https://www.dunerealms.com/assets/'+office.art;seal.alt='';art.append(seal);body.append(el('small',action.kind),el('h3',action.title),el('p',action.effect));
const details=el('dl');for(const [label,text]of [['Requirements','Current office and constitutional authority'],['Target','Eligible organisation, world or route'],['Budget','Disclosed before confirmation'],['Duration','Notice, expiry and cooldown to be confirmed']])details.append(el('dt',label),el('dd',text));
button.type='button';button.disabled=true;button.title='Coming soon — no decision will be enacted';body.append(details,badge,button);row.append(art,body);panel.append(row);
}
if(!rows.length)panel.append(el('p','No planned actions match your search.','policy-empty'));
}
POLICY_CATEGORIES.forEach(([id,label],index)=>{const button=el('button',label);button.type='button';button.id='policy-tab-'+id;button.setAttribute('role','tab');button.setAttribute('aria-controls',panel.id);button.onclick=()=>{category=id;render();};button.onkeydown=e=>{if(!['ArrowLeft','ArrowRight','Home','End'].includes(e.key))return;e.preventDefault();const next=e.key==='Home'?0:e.key==='End'?buttons.length-1:(index+(e.key==='ArrowRight'?1:buttons.length-1))%buttons.length;buttons[next].button.click();buttons[next].button.focus();};buttons.push({button,id});nav.append(button);});
search.oninput=standing.onchange=render;tools.append(search,standing);root.append(intro,nav,tools,panel);host.replaceChildren(root);render();return()=>root.remove();
}

View file

@ -1,8 +1,10 @@
import {POLICY_OFFICES} from './cp-v2-policy-catalogue.mjs';
import {ELECTIONS} from '../political-catalog.mjs';
export const POLITICAL_TABS=Object.freeze([
{id:'elections',label:'Elections',pages:[['house-elections','Faction Elections'],['imperial-elections','Emperor Elections'],...ELECTIONS.filter(e=>e.kind!=='house'&&e.kind!=='imperial').map(e=>['election-'+e.id,e.label]),['applications','My applications'],['electoral-roll','Electoral Roll']]},
{id:'directory',label:'Voting Directory',pages:[['all-applications','All applications'],...ELECTIONS.map(e=>['candidates-'+e.id,e.label])]},
{id:'offices',label:'Offices',pages:[['office-register','Government & Offices'],['imperial-senate','Imperial Senate'],['small-council','Small Council'],['politics-overview','Your Political Record'],['landsraad','Landsraad Assembly'],['formal-council','Faction Council'],['imperial-command','Imperial Council']]},
{id:'decisions',label:'Decisions & Schemes',pages:POLICY_OFFICES.map(o=>['decisions-'+o.id,o.label])},
{id:'tools',label:'Tools',pages:[['council-motd','Proclamations'],['imperial-water','Water Rights'],['imperial-spice','Spice Rights']]}
]);
export function politicalRoute(value=''){

View file

@ -44,3 +44,10 @@ body.politics-cp-shell #portals{display:none!important}
.campaign-confirm{background:#35232b;color:#f4e3c3;border:3px double #c4a164;border-radius:10px;padding:28px;max-width:min(460px,calc(100vw - 48px));box-shadow:0 20px 80px #0008}.campaign-confirm::backdrop{background:#160c13b8;backdrop-filter:blur(4px)}.campaign-confirm label{display:flex;align-items:center;gap:16px}.campaign-confirm input{max-width:100px;padding:9px}.campaign-confirm button{margin:12px 12px 0 0}
@media(max-width:900px){.campaign-filters{grid-template-columns:1fr}.politics-cp-shell .content .hero{min-height:150px}.campaign-portrait{min-height:150px}.campaign-body{padding:18px}}
@media(prefers-reduced-motion:no-preference){.campaign-card{transition:box-shadow .2s,border-color .2s}.campaign-card:hover{border-color:#e1be78;box-shadow:0 10px 25px #10070c77}}
/* Office decisions: the existing chamber frame, with readable illustrated rows. */
.policy-intro{background:#35222a;border-left:3px solid #d0ae6d;padding:18px 22px;line-height:1.65;color:#eddfc6}.policy-intro strong{font-size:12px;letter-spacing:.12em;color:#eed19a}
.policy-tabs{display:flex;gap:10px;flex-wrap:wrap;margin:22px 0 18px;border-bottom:1px solid #a7895266;padding-bottom:14px}.politics-cp-shell .policy-tabs button{border:1px solid #a68a54;border-radius:6px;padding:12px 22px;background:#37242c;color:#ebdec5;font:bold 16px Georgia,serif}.politics-cp-shell .policy-tabs button[aria-selected=true]{background:linear-gradient(#d9bd7c,#b69857);color:#2b1a20;box-shadow:inset 0 0 0 2px #ead39c}
.policy-tools{display:flex;gap:12px;flex-wrap:wrap;margin-bottom:20px}.politics-cp-shell .policy-tools input,.politics-cp-shell .policy-tools select{background:#2d2029;color:#f0e3cb;border:1px solid #a68a54;border-radius:6px;padding:12px;font:15px Georgia,serif}.policy-tools input{flex:1;min-width:180px}.policy-row{display:grid;grid-template-columns:140px minmax(0,1fr);margin-bottom:18px;border:3px double #b89a60;border-radius:8px;background:linear-gradient(130deg,#452c35,#2a202b);overflow:hidden;box-shadow:0 5px 14px #100b1244}.policy-row-art{display:flex;align-items:center;justify-content:center;background:linear-gradient(#35202b55,#241925b3),url('https://www.dunerealms.com/assets/political-imperial-chamber-v1.png') center/cover}.policy-row-art img{width:92px;height:92px;object-fit:contain;filter:drop-shadow(0 5px 8px #10080d99)}.policy-row-body{padding:22px 26px}.politics-cp-shell .policy-row-body h3{margin:0 0 10px;color:#efd196;font-size:23px}.policy-row-body p{line-height:1.7;margin:0 0 15px}.policy-row-body button{margin-left:14px;padding:9px 16px;border-radius:5px}.policy-coming{display:inline-block;color:#dbc795;border:1px solid #a5895655;background:#2b2128;padding:7px 12px;border-radius:20px;font:12px Arial,sans-serif}.policy-watch{padding:16px;line-height:1.6;border-bottom:1px solid #a68a54}.policy-watch h3{color:#efd196;font-size:16px}.policy-watch p{font-size:13px}.policy-empty{padding:28px;border:1px solid #a68a5455;border-radius:7px;background:#30212a}
.navitem .dune-new-overlay{display:inline-block;margin-left:6px;padding:2px 5px;border:1px solid #c38a63;background:#8b282c;color:#fff1cf;font:bold 9px Arial,sans-serif;border-radius:2px}.navitem .dune-update-overlay{background:#254957;border-color:#74a2b0}
@media(max-width:720px){.policy-row{grid-template-columns:85px minmax(0,1fr)}.policy-row-art img{width:62px;height:62px}.policy-row-body{padding:18px}.politics-cp-shell .policy-row-body h3{font-size:20px}.policy-tools{display:grid;grid-template-columns:1fr}.policy-tools input{min-width:0}.policy-tabs button{flex:1}}

View file

@ -1,10 +1,12 @@
import {mountPolicyDecisions} from './cp-v2-politics-decisions.mjs';
import {watchMenuHighlights} from './cp-v2-menu-highlights.mjs';
import {startCPAuthentication} from './cp-v2-auth.mjs';
import {mountPoliticsPage} from './cp-v2-politics-pages.mjs';
import {element as el} from './cp-v2-page-template.mjs';
import {ELECTIONS} from '../political-catalog.mjs';
import {POLITICAL_TABS,politicalRoute} from './cp-v2-politics-navigation.mjs';
const outer='https://www.dunerealms.com',content=document.querySelector('#content'),sidebar=document.querySelector('#sidebar'),sidebarRight=document.querySelector('#sidebar-right'),tabs=document.querySelector('#portals');
const artwork={elections:'seals/office-house_leader.png',offices:'seals/office-landsraad.png',tools:'seals/emperor-v1.png'};
const artwork={elections:'seals/office-house_leader.png',offices:'seals/office-landsraad.png',tools:'seals/emperor-v1.png',decisions:'seals/office-landsraad.png'};
const icon=tab=>{const image=el('img');image.src=outer+'/assets/'+artwork[tab];image.alt='';return image;};
let ready=false,dispose=()=>{},current='',queued=false,lastHeight=0;
document.body.classList.toggle('politics-cp-embedded',parent!==window);
@ -17,17 +19,19 @@ function show(){
const tab=POLITICAL_TABS.find(t=>t.id===route.tab),page=tab.pages.find(([id])=>id===route.page);
content.setAttribute('aria-label',page[1]);
sidebar.replaceChildren(el('div','ELECTION CHAMBERS','side-hero'));sidebarRight.replaceChildren(el('div','OFFICES & INSTRUMENTS','side-hero'));
const menu=(host,title,items)=>{const block=el('section',undefined,'category-block');const summary=el('div',title,'category-heading'),links=el('div',undefined,'category-links');for(const[id,label]of items){const group=POLITICAL_TABS.find(t=>t.pages.some(([p])=>p===id));const link=el('a',undefined,'navitem');link.href='#'+group.id+'/'+id;link.append(icon(group.id==='directory'?'elections':group.id),el('span',label));if(id===page[0])link.setAttribute('aria-current','page');links.append(link);}block.append(summary,links);host.append(block);};
const menu=(host,title,items)=>{const block=el('section',undefined,'category-block');const summary=el('div',title,'category-heading'),links=el('div',undefined,'category-links');for(const[id,label]of items){const group=POLITICAL_TABS.find(t=>t.pages.some(([p])=>p===id));const link=el('a',undefined,'navitem');link.href='#'+group.id+'/'+id;link.dataset.menuHref=outer+'/government.html'+link.getAttribute('href');link.append(icon(group.id==='directory'?'elections':group.id),el('span',label));if(id===page[0])link.setAttribute('aria-current','page');links.append(link);}block.append(summary,links);host.append(block);};
menu(sidebar,'Imperial Senate',[['imperial-elections','Emperor election'],['house-elections','House Leader elections']]);
menu(sidebar,'Small Council',ELECTIONS.filter(e=>e.chamber==='Small Council').map(e=>['election-'+e.id,e.label]));
menu(sidebar,'Voting Directory',POLITICAL_TABS.find(t=>t.id==='directory').pages);
menu(sidebar,'Decisions & Schemes',POLITICAL_TABS.find(t=>t.id==='decisions').pages);
menu(sidebar,'Participation',[['applications','My applications'],['electoral-roll','Electoral Roll']]);
if(route.tab==='decisions'){const status=el('section',undefined,'policy-watch');for(const title of ['Active orders','Preparations','Commitments & alerts'])status.append(el('h3',title),el('p','Records will appear here when these powers become available.'));sidebarRight.append(status);}
menu(sidebarRight,'Offices',[['office-register','All offices'],['imperial-senate','Imperial Senate'],['small-council','Small Council'],['politics-overview','My political record']]);
menu(sidebarRight,'Councils',[['landsraad','Landsraad assembly'],['formal-council','House council'],['imperial-command','Imperial council']]);
menu(sidebarRight,'Tools',POLITICAL_TABS.find(t=>t.id==='tools').pages);
const hero=el('header',undefined,'hero'),seal=el('img'),heading=el('div');seal.src=outer+'/assets/seals/office-landsraad.png';seal.alt='';heading.append(el('h1',page[1]),el('p',tab.id==='directory'?'Meet the candidates, explore their campaigns and cast your eligible votes.':tab.id==='elections'?'Candidatures, verified eligibility and the existing ballots.':tab.id==='offices'?'The offices, councils and elected representatives of the realms.':'Proclamations and the existing government instruments.'));hero.append(seal,heading);
const hero=el('header',undefined,'hero'),seal=el('img'),heading=el('div');seal.src=outer+'/assets/seals/office-landsraad.png';seal.alt='';heading.append(el('h1',page[1]),el('p',tab.id==='decisions'?'Decisions and schemes of this office · Economic, Political and Communal.':tab.id==='directory'?'Meet the candidates, explore their campaigns and cast your eligible votes.':tab.id==='elections'?'Candidatures, verified eligibility and the existing ballots.':tab.id==='offices'?'The offices, councils and elected representatives of the realms.':'Proclamations and the existing government instruments.'));hero.append(seal,heading);
const cards=el('div',undefined,'cards'),card=el('article',undefined,'card full citizen-page-full'),host=el('div',undefined,'citizen-live-host');card.append(host);cards.append(card);content.replaceChildren(hero,cards);
dispose=['office-register','imperial-senate','small-council'].includes(page[0])?mountOfficeRegister(host,page[0]):mountPoliticsPage(host,page[0]);
dispose=route.tab==='decisions'?mountPolicyDecisions(host,page[0].slice('decisions-'.length)):['office-register','imperial-senate','small-council'].includes(page[0])?mountOfficeRegister(host,page[0]):mountPoliticsPage(host,page[0]);
history.replaceState(null,'','#'+key);if(parent!==window)parent.postMessage({type:'dune-politics-route',tab:route.tab,page:route.page},outer);
sidebar.classList.remove('open');sidebarRight.classList.remove('open');document.querySelector('#mobile-menu').setAttribute('aria-expanded','false');schedule();
}
@ -38,6 +42,7 @@ function mountOfficeRegister(host,view='office-register'){
host.replaceChildren(grid);
}).catch(error=>{if(active)status.textContent=error.message;});return()=>{active=false;controller.abort();};
}
watchMenuHighlights(document.body);
tabs.hidden=true;tabs.replaceChildren();
document.querySelector('#mobile-menu').onclick=()=>{const open=sidebar.classList.toggle('open');sidebarRight.classList.toggle('open',open);document.querySelector('#mobile-menu').setAttribute('aria-expanded',String(open));};
window.addEventListener('hashchange',show);window.addEventListener('pagehide',()=>{dispose();observer.disconnect();},{once:true});

Some files were not shown because too many files have changed in this diff Show more