forked from unimatrix/web
Build central Political CP with campaign cards and imperial artwork
This commit is contained in:
parent
e7c8951511
commit
84edcf31e7
6 changed files with 148 additions and 35 deletions
BIN
website/web/assets/political-imperial-chamber-v1.png
Normal file
BIN
website/web/assets/political-imperial-chamber-v1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 MiB |
BIN
website/web/assets/political-small-council-v1.png
Normal file
BIN
website/web/assets/political-small-council-v1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2 MiB |
|
|
@ -1 +1,3 @@
|
|||
body.dune-public-page{background:#f0e8d9;color:#38271f}.government-portal{max-width:1600px;margin:0 auto;padding:24px 3%}.government-workspace{border:1px solid #b79a63;box-shadow:0 12px 32px #3c1b211a;background:#f6f0e5}.government-workspace iframe{display:block;width:100%;border:0;height:1000px;overflow:hidden}.government-public-register{margin:24px 0;border:1px solid #baa276;background:#fbf7ee}.government-public-register>summary{padding:18px 22px;cursor:pointer;font:20px Georgia,serif;color:#632f2c}.government-public-register .staff-directory{color:#38271f}.government-public-register .staff-intro{margin-top:12px}@media(max-width:720px){.government-portal{padding:12px 0}.government-workspace{border-left:0;border-right:0}.government-public-register{margin:18px 10px}}
|
||||
|
||||
body.dune-public-page{background:#c9bba5}.government-workspace{background:#33252a}.government-public-register{background:#d8cbb5}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const cpOrigin='https://cp.dunerealms.com';
|
||||
export const politicalPages={elections:['house-elections','imperial-elections','applications','electoral-roll'],offices:['office-register','politics-overview','landsraad','formal-council','imperial-command'],tools:['council-motd','imperial-water','imperial-spice']};
|
||||
export const politicalPages={elections:['house-elections','imperial-elections','election-bene','election-guild','election-clan-delegate','applications','electoral-roll'],directory:['all-applications','candidates-emperor','candidates-atreides','candidates-harkonnen','candidates-corrino','candidates-ordos','candidates-bene','candidates-guild','candidates-clan-delegate'],offices:['office-register','imperial-senate','small-council','politics-overview','landsraad','formal-council','imperial-command'],tools:['council-motd','imperial-water','imperial-spice']};
|
||||
export function governmentRoute(value){const parts=value.replace(/^#/,'').split('/'),page=parts[1]||parts[0];for(const [tab,pages]of Object.entries(politicalPages))if(pages.includes(page))return tab+'/'+page;const tab=Object.hasOwn(politicalPages,parts[0])?parts[0]:'elections';return tab+'/'+politicalPages[tab][0];}
|
||||
export function politicalFrameMessage(event,frame){
|
||||
if(event.origin!==cpOrigin||event.source!==frame.contentWindow)return null;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,17 +1,17 @@
|
|||
const el=(tag,text,cls)=>{const n=document.createElement(tag);if(text!==undefined)n.textContent=text;if(cls)n.className=cls;return n;};
|
||||
const definitions=[['emperor','Office of the Emperor','The Imperium','emperor-v1.png','imperial'],['atreides','House Aerdrecht Leadership','House Aerdrecht','house-aerdrecht-v1.png'],['harkonnen','House Harkveen Leadership','House Harkveen','house-harkveen-v1.png'],['corrino','House Korenholt Leadership','House Korenholt','house-korenholt-v1.png'],['ordos','House Oordwijk Leadership','House Oordwijk','house-oordwijk-v1.png'],['fremen','Office of the Naib','Vrijduin','house-vrijduin-v1.png'],['veiled_concord','Office of the Reverent Mother','The Veiled Concord','veiled-concord-v1.png','court'],['spacing_guild','Vaerkring Leadership','Vaerkring · Spacing Guild','office-landsraad.png','court']];
|
||||
const definitions=[['emperor','Office of the Emperor','The Imperium','emperor-v1.png','imperial'],['atreides','House Aerdrecht Leadership','House Aerdrecht','house-aerdrecht-v1.png'],['harkonnen','House Harkveen Leadership','House Harkveen','house-harkveen-v1.png'],['corrino','House Korenholt Leadership','House Korenholt','house-korenholt-v1.png'],['ordos','House Oordwijk Leadership','House Oordwijk','house-oordwijk-v1.png'],['clan_delegate','Clan Delegate','Small Council','office-house_leader.png','clan_delegate'],['veiled_concord','Office of the Reverent Mother','The Veiled Concord','veiled-concord-v1.png','court'],['spacing_guild','Vaerkring Leadership','Vaerkring · Spacing Guild','office-landsraad.png','court']];
|
||||
const date=n=>new Date(n).toLocaleString('en-GB',{timeZone:'Europe/Brussels',dateStyle:'medium',timeStyle:'short'})+' · Brussels';
|
||||
function card(office,loading=false){
|
||||
const c=el('article',undefined,'staff-person'),art=el('img');art.src='/assets/seals/'+office.art;art.alt=office.scope+' insignia';art.width=art.height=100;art.className='government-office-art';
|
||||
c.append(art,el('small',office.scope),el('h3',office.name),el('p',office.description||'Elected leadership and representation.','staff-bio'));
|
||||
if(office.holder){const row=el('div',undefined,'government-holder'),avatar=el('img'),a=el('a',office.holder.name);avatar.src=office.holder.avatar;avatar.alt='';avatar.width=avatar.height=56;a.href=office.holder.profile;row.append(avatar,a);c.append(el('span','IN OFFICE','government-state'),row);if(office.term)c.append(el('p','Term: '+date(office.term.startsAt)+' — '+date(office.term.expiresAt),'government-term'));}
|
||||
else{const placeholder=el('div',undefined,'government-vacant');placeholder.append(el('strong',loading?'AWAITING CONFIRMATION':office.state==='verification_pending'?'AWAITING VERIFICATION':'VACANT'),el('span',loading?'Checking the elected office register…':office.state==='verification_pending'?'The elected identity is being verified.':'Awaiting election'));c.append(placeholder);}
|
||||
const a=el('a','View elections →','staff-profile-link');a.href='https://cp.dunerealms.com/#politics/'+(office.kind==='imperial'?'imperial-elections':'house-elections');c.append(a);return c;
|
||||
const a=el('a','View elections →','staff-profile-link');a.href='https://www.dunerealms.com/government.html#'+(office.kind==='imperial'?'imperial-elections':office.kind==='house'?'house-elections':'all-applications');c.append(a);return c;
|
||||
}
|
||||
function render(offices,loading=false){document.querySelector('#court-offices').replaceChildren(...offices.filter(o=>o.kind==='court').map(o=>card(o,loading)));document.querySelector('#imperial-offices').replaceChildren(...offices.filter(o=>o.kind==='imperial').map(o=>card(o,loading)));document.querySelector('#house-offices').replaceChildren(...offices.filter(o=>o.kind==='house').map(o=>card(o,loading)));}
|
||||
function render(offices,loading=false){document.querySelector('#court-offices').replaceChildren(...offices.filter(o=>['court','bene','guild','clan_delegate'].includes(o.kind)).map(o=>card(o,loading)));document.querySelector('#imperial-offices').replaceChildren(...offices.filter(o=>o.kind==='imperial').map(o=>card(o,loading)));document.querySelector('#house-offices').replaceChildren(...offices.filter(o=>o.kind==='house').map(o=>card(o,loading)));}
|
||||
render(definitions.map(([key,name,scope,art,kind='house'])=>({key,name,scope,art,kind})),true);
|
||||
try{
|
||||
const response=await fetch('/api/public/government',{cache:'no-store'});if(!response.ok)throw Error();const data=await response.json();if(!Array.isArray(data.offices)||data.offices.length!==definitions.length)throw Error();
|
||||
render(data.offices);document.querySelector('#government-status').textContent='Current elected offices · Updated '+date(data.observedAt);
|
||||
const calendar=document.querySelector('#government-elections');for(const e of data.elections){const c=el('article',undefined,'staff-person');c.append(el('small',e.phase==='voting'?'VOTING OPEN':'ELECTION CALENDAR'),el('h3',e.kind==='imperial'?'Imperial election':'House elections'),el('p','Voting opens: '+date(e.votingOpens),'government-term'),el('p','Voting closes: '+date(e.votingCloses),'government-term'),el('p','Term cycle: '+e.termWeeks+' weeks','government-term'));calendar.append(c);}
|
||||
const calendar=document.querySelector('#government-elections');for(const e of data.elections){const c=el('article',undefined,'staff-person');c.append(el('small',e.phase==='voting'?'VOTING OPEN':'ELECTION CALENDAR'),el('h3',({imperial:'Emperor election',house:'House Leader elections',bene:'Bene Gesserit election',guild:'Spacing Guild election',clan_delegate:'Clan Delegate election'})[e.kind]),el('p','Voting opens: '+date(e.votingOpens),'government-term'),el('p','Voting closes: '+date(e.votingCloses),'government-term'),el('p','Term cycle: '+e.termWeeks+' weeks','government-term'));calendar.append(c);}
|
||||
}catch{document.querySelector('#government-status').textContent='The office register is temporarily unavailable. Officeholders cannot currently be confirmed; all offices remain visible.';}
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff