From 84edcf31e71ed3ce77cbc15b9535050ebcbb341f Mon Sep 17 00:00:00 2001 From: unimatrixgit <95320811+unimatrixgit@users.noreply.github.com> Date: Sun, 15 Nov 2026 21:43:04 +0100 Subject: [PATCH] Build central Political CP with campaign cards and imperial artwork --- website/control-panel/politics-cp-shell.mjs | 4 +- .../public/cp-v2/cp-v2-politics-native.css | 17 +++++++ .../cp-v2/cp-v2-politics-navigation.mjs | 6 ++- .../public/cp-v2/cp-v2-politics-pages.mjs | 2 + .../public/cp-v2/cp-v2-politics-shell.css | 36 +++++++++++++++ .../public/cp-v2/cp-v2-politics-shell.mjs | 29 ++++++------ .../public/cp-v2/cp-v2-voting-directory.mjs | 42 ++++++++++++++++++ .../public/election-applications-view.mjs | 8 ++-- website/control-panel/public/politics.mjs | 6 +-- website/docs/political-artwork.md | 8 ++++ website/node/electoral-roll.mjs | 2 +- website/tests/political-cp.test.mjs | 9 ++-- .../assets/political-imperial-chamber-v1.png | Bin 0 -> 2178011 bytes .../web/assets/political-small-council-v1.png | Bin 0 -> 2124819 bytes website/web/government-cp.css | 2 + website/web/government-cp.js | 2 +- website/web/government.html | 2 +- website/web/government.js | 8 ++-- 18 files changed, 148 insertions(+), 35 deletions(-) create mode 100644 website/control-panel/public/cp-v2/cp-v2-voting-directory.mjs create mode 100644 website/docs/political-artwork.md create mode 100644 website/web/assets/political-imperial-chamber-v1.png create mode 100644 website/web/assets/political-small-council-v1.png diff --git a/website/control-panel/politics-cp-shell.mjs b/website/control-panel/politics-cp-shell.mjs index 1bb071cc..d6b67d1a 100644 --- a/website/control-panel/politics-cp-shell.mjs +++ b/website/control-panel/politics-cp-shell.mjs @@ -8,8 +8,8 @@ export function politicsCPDocument(source){ .replace(//,'') .replace('','') .replace('✦ DuneRealms','✦ Political CP') - .replace('CONTROL PANEL V2Your imperial workspace','REALMS · COURT · LANDSRAADElections, Offices & Tools') - .replace('class="portals" aria-label="Workspace portals"','class="portals" role="tablist" aria-label="Political workspace"') + .replace('CONTROL PANEL V2Your imperial workspace','IMPERIAL SENATE · SMALL COUNCILFour-week terms · Elections & Offices') + .replace('class="portals" aria-label="Workspace portals"','class="portals" hidden aria-hidden="true"') .replace('aria-controls="sidebar"','aria-controls="sidebar sidebar-right"') .replace(/') .replace('',''); diff --git a/website/control-panel/public/cp-v2/cp-v2-politics-native.css b/website/control-panel/public/cp-v2/cp-v2-politics-native.css index 03faad58..7b96d4d2 100644 --- a/website/control-panel/public/cp-v2/cp-v2-politics-native.css +++ b/website/control-panel/public/cp-v2/cp-v2-politics-native.css @@ -1,3 +1,20 @@ body[data-service=politics]{color-scheme:light;background:#fffcf6;color:#34271f;font-family:Georgia,serif;min-height:0}body[data-service=politics] a{color:#71342d}body[data-service=politics] h1,body[data-service=politics] h2,body[data-service=politics] h3,body[data-service=politics] h4{color:#632f2c}body[data-service=politics] .politics-card,body[data-service=politics] .politics-charter,body[data-service=politics] .politics-candidate,body[data-service=politics] .politics-calendar-card,body[data-service=politics] .politics-leaders,body[data-service=politics] table{background:#f6eddd;color:#34271f;border-color:#bfa77b;box-shadow:none}body[data-service=politics] input,body[data-service=politics] textarea,body[data-service=politics] select,body[data-service=politics] button{background:#fffcf6;color:#4b3229;border:1px solid #aa8755}body[data-service=politics] button:disabled{opacity:.6}body[data-service=politics] .politics-calendar li,body[data-service=politics] .politics-calendar time,body[data-service=politics] th,body[data-service=politics] td{background:#f3e7d1;color:#4b3229;border-color:#c5ae83}body[data-service=politics] .politics-demo-note{color:#755326;background:#ede0c7}body[data-service=politics] .politics-oath{color:#71342d} body[data-service=politics] .politics-card,body[data-service=politics] .politics-charter,body[data-service=politics] .politics-candidate,body[data-service=politics] .politics-calendar-card,body[data-service=politics] .politics-leaders{border:3px double #c7a05a;border-radius:7px;box-shadow:inset 0 0 0 3px #efe0c0} +/* Scope above the legacy faction skins so every political page stays readable. */ +body[data-service=politics]{background:#33252a;color:#f0e3ca;color-scheme:dark} +body[data-service=politics] #dashboard{background:#33252a;color:#f0e3ca;border-color:#ab8c54;padding:10px} +body[data-service=politics] #dashboard .politics-page{background:transparent;color:#f0e3ca;padding:10px} +body[data-service=politics] #dashboard .politics-page :is(.politics-card,.politics-charter,.politics-candidate,.politics-calendar-card,.politics-leaders,.politics-hero,.politics-oath){background:linear-gradient(110deg,#432931ed,#2e2027f5),url('https://www.dunerealms.com/assets/political-small-council-v1.png') center/cover!important;color:#f0e3ca;border:3px double #b7975b;box-shadow:none} +body[data-service=politics] #dashboard .politics-page :is(h1,h2,h3,h4,h5,summary,strong,a,.politics-candidate-count){color:#f0cf8f} +body[data-service=politics] #dashboard .politics-page :is(p,small,label,li,dt,dd,span,time){color:#e6dac4} +body[data-service=politics] #dashboard .politics-page :is(input,textarea,select){background:#ded0b9;color:#342329;border:1px solid #b7975b;accent-color:#9f6c4c;box-sizing:border-box;max-width:100%} +body[data-service=politics] #dashboard .politics-page button{background:linear-gradient(#d5b46a,#ae8c48);color:#2c1b20;border:1px solid #e0be7b;box-shadow:none} +body[data-service=politics] #dashboard .politics-page :is(th,td,.politics-calendar li,.politics-calendar time){background:#432e36;color:#f0e3ca;border-color:#a98c5555} +body[data-service=politics] #dashboard .politics-page :is(.politics-demo-note,.politics-intro){background:#51363c;color:#eedfc1;border-color:#ab8c54} +body[data-service=politics] #dashboard .politics-page :is(input,textarea,select):focus-visible{outline:2px solid #edcc80;outline-offset:2px} +body[data-service=politics] #dashboard .politics-page a{color:#f0cf8f;text-decoration-thickness:1px;text-underline-offset:3px} +body[data-service=politics] #dashboard .politics-page .politics-hero{min-height:190px;background:linear-gradient(90deg,#35171fe8,#35171f88),url('https://www.dunerealms.com/assets/political-imperial-chamber-v1.png') center/cover!important} +body[data-service=politics] #service-heading{display:none} +body[data-service=politics] #dashboard .politics-page .politics-preview-note{background:#51353d;color:#f0dfc1;border-color:#aa8b54} +body[data-service=politics] #dashboard .politics-page .politics-card a{background:#50313b;color:#f0cf8f;border-color:#ad8c53} diff --git a/website/control-panel/public/cp-v2/cp-v2-politics-navigation.mjs b/website/control-panel/public/cp-v2/cp-v2-politics-navigation.mjs index a43ffed4..e9881b29 100644 --- a/website/control-panel/public/cp-v2/cp-v2-politics-navigation.mjs +++ b/website/control-panel/public/cp-v2/cp-v2-politics-navigation.mjs @@ -1,6 +1,8 @@ +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'],['applications','Applications'],['electoral-roll','Electoral Roll']]}, - {id:'offices',label:'Offices',pages:[['office-register','Government & Offices'],['politics-overview','Your Political Record'],['landsraad','Landsraad Assembly'],['formal-council','Faction Council'],['imperial-command','Imperial Council']]}, + {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:'tools',label:'Tools',pages:[['council-motd','Proclamations'],['imperial-water','Water Rights'],['imperial-spice','Spice Rights']]} ]); export function politicalRoute(value=''){ diff --git a/website/control-panel/public/cp-v2/cp-v2-politics-pages.mjs b/website/control-panel/public/cp-v2/cp-v2-politics-pages.mjs index 843f7414..8f4d8939 100644 --- a/website/control-panel/public/cp-v2/cp-v2-politics-pages.mjs +++ b/website/control-panel/public/cp-v2/cp-v2-politics-pages.mjs @@ -1,8 +1,10 @@ +import {mountVotingDirectory} from './cp-v2-voting-directory.mjs'; import {mountNativeService} from './cp-v2-native-services.mjs'; import {createCPV2Page,element as el} from './cp-v2-page-template.mjs'; import {createUserAPI} from './cp-v2-user-api.mjs'; export const POLITICS_PAGES=Object.freeze({'landsraad':'Landsraad Assembly','council-motd':'Proclamations','house-elections':'House Elections','imperial-elections':'Emperor Elections','applications':'Election Applications','electoral-roll':'Electoral Roll','formal-council':'Faction Council','imperial-command':'Imperial Council','imperial-water':'Water Rights','imperial-spice':'Spice Rights'}); export function mountPoliticsPage(host,id,{fetcher=fetch}={}){ + if(id==='all-applications'||id.startsWith('candidates-')||id.startsWith('election-'))return mountVotingDirectory(host,id==='all-applications'?'':id.replace(/^(candidates-|election-)/,'')); if(Object.hasOwn(POLITICS_PAGES,id))return mountNativeService(host,'politics',{fetcher,singleHeading:true,title:POLITICS_PAGES[id],initialTab:id}); if(id!=='politics-overview')throw Error('Unknown political workspace.'); const controller=new AbortController(),api=createUserAPI(fetcher,controller.signal);let active=true; diff --git a/website/control-panel/public/cp-v2/cp-v2-politics-shell.css b/website/control-panel/public/cp-v2/cp-v2-politics-shell.css index 19b45ef5..41dbbbbe 100644 --- a/website/control-panel/public/cp-v2/cp-v2-politics-shell.css +++ b/website/control-panel/public/cp-v2/cp-v2-politics-shell.css @@ -8,3 +8,39 @@ html:has(body.politics-cp-embedded){overflow:hidden}body.politics-cp-shell{displ .politics-cp-shell button,.politics-cp-shell input,.politics-cp-shell select{background:#f6ecda;color:#4b3229;border-color:#aa8755}.politics-cp-shell .cp-v2-auth{background:#fffcf6;color:#38271f;border-color:#c7a05a}.politics-cp-shell .alpha-stat{background:#f4ebdb;color:#4b3229;border-color:#c7a05a}.politics-cp-shell .cp-v2-native-frame iframe{width:100%;border:0}.politics-office-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px}.politics-office-card{border:3px double #c7a05a;border-radius:7px;box-shadow:inset 0 0 0 3px #efe0c0;background:linear-gradient(145deg,#fff7e5,#f0e2c7);padding:22px;display:flex;flex-direction:column;align-items:flex-start;gap:9px;min-width:0}.politics-office-card h2,.politics-office-card p{margin:0}.politics-cp-shell .politics-office-card h2{font-size:23px}.politics-office-card img{object-fit:contain}.politics-office-card small{letter-spacing:.08em;text-transform:uppercase;font:11px Arial,sans-serif} .politics-cp-shell .content .cards>.card.citizen-page-full{background:linear-gradient(140deg,#fffcf6,#f4ead7)!important;border:4px double #c7a05a!important;box-shadow:inset 0 0 0 4px #efe0c0,0 7px 16px #3c1b211a!important} @media(max-width:1100px){.politics-office-grid{grid-template-columns:1fr}}@media(max-width:720px){.politics-cp-shell .portals{grid-template-columns:repeat(3,minmax(0,1fr))}.politics-cp-shell .mobile-tools{background:#eee4d2}.politics-cp-shell .side.open{max-height:none;overflow:visible}} +/* Political chambers share the CP geometry, with a quieter parchment and burgundy palette. */ +body.politics-cp-shell{--political-art:url('https://www.dunerealms.com/assets/political-imperial-chamber-v1.png');background:#c9bba5;color:#f0e3ca} +body.politics-cp-shell #portals{display:none!important} +.politics-cp-shell .content{background:linear-gradient(#28171be8,#28171bf5),var(--political-art) center top/cover;color:#f0e3ca;border-color:#b7975b} +.politics-cp-shell .side{background:linear-gradient(#342126ed,#23171bf5),url('https://www.dunerealms.com/assets/political-small-council-v1.png') center/cover;color:#f0e3ca} +.politics-cp-shell .category-block{background:#38262be8;border-color:#9e814d} +.politics-cp-shell .category-heading{background:linear-gradient(90deg,#58333b,#3d272d);color:#eed4a0;border-color:#9e814d} +.politics-cp-shell .navitem{color:#ecdfc6;border-color:#9e814d55} +.politics-cp-shell .navitem:hover,.politics-cp-shell .navitem[aria-current=page]{background:#714550;color:#fff2cf} +.politics-cp-shell .content .hero{min-height:190px;background:linear-gradient(90deg,#35171fe8,#35171f80),var(--political-art) center 48%/cover;color:#f8e8c9;box-shadow:0 6px 20px #160c1055} +.politics-cp-shell .command-banner{background:linear-gradient(90deg,#35171fe8,#35171f9c),var(--political-art) center 22%/cover} +.politics-cp-shell .content .cards>.card.citizen-page-full{background:#33252a!important;border:3px double #b7975b!important;box-shadow:0 8px 22px #10090c33!important;color:#f0e3ca} +.politics-cp-shell .card p,.politics-cp-shell .card small,.politics-cp-shell .cp-v2-native-workspace{color:#e5d7bd} +.politics-cp-shell h2,.politics-cp-shell h3,.politics-cp-shell .alpha-stat strong{color:#efd295} +.politics-cp-shell a{color:#f0cf8f} +.politics-cp-shell .alpha-stat{background:#442d34;color:#f0e3ca;border-color:#a68a54} +.politics-office-card{background:linear-gradient(#3c2530e8,#312126fa),url('https://www.dunerealms.com/assets/political-small-council-v1.png') center/cover;box-shadow:none;border-color:#ad8b4d;color:#ecdfc6} +.politics-cp-shell .card .politics-office-card h2{color:#f0cf8f} +.campaign-filters{display:grid;grid-template-columns:minmax(170px,2fr) minmax(130px,1fr) minmax(120px,1fr);gap:12px;margin-bottom:18px} +.politics-cp-shell .campaign-filters input,.politics-cp-shell .campaign-filters select{width:100%;min-width:0;box-sizing:border-box;border-radius:6px;padding:12px;background:#dfd2bc;color:#38252a} +.campaign-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,300px),1fr));gap:22px;align-items:start} +.campaign-card{overflow:hidden;border:3px double #c4a164;border-radius:10px;background:#39242c;box-shadow:0 8px 20px #120a0e55;min-width:0} +.campaign-portrait{position:relative;min-height:180px;display:flex;align-items:center;padding:26px;background:linear-gradient(90deg,#2b152153,#2b1521b8),url('https://www.dunerealms.com/assets/political-imperial-chamber-v1.png') center/cover;border-bottom:1px solid #c4a164} +.campaign-card:nth-child(even) .campaign-portrait{background-image:linear-gradient(90deg,#2b152153,#2b1521b8),url('https://www.dunerealms.com/assets/political-small-council-v1.png')} +.campaign-portrait>img:first-child{width:112px;height:112px;image-rendering:pixelated;border:3px double #ddbb73;box-shadow:0 6px 18px #0007;border-radius:9px;background:#3b252b} +.campaign-seal{position:absolute;right:20px;top:22px;object-fit:contain;filter:drop-shadow(0 3px 5px #0008)} +.campaign-kicker{position:absolute;bottom:14px;right:18px;font:11px/1.4 Arial,sans-serif;letter-spacing:.12em;text-transform:uppercase;color:#ffe5aa} +.campaign-body{padding:22px}.politics-cp-shell .campaign-body h2{margin:10px 0;font-size:29px;line-height:1.1;overflow-wrap:anywhere}.campaign-body h2 a{text-decoration:none} +.campaign-office{display:block;color:#e6c176}.campaign-bio{font-style:italic;line-height:1.6;border-bottom:1px solid #b7975b55;padding-bottom:16px;white-space:pre-wrap;overflow-wrap:anywhere} +.campaign-message summary{cursor:pointer;color:#f2d494}.campaign-message p{white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.65;max-height:13em;overflow:auto;padding-right:6px} +.campaign-footer{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-top:20px}.campaign-footer>span{font:10px Arial,sans-serif;color:#cdbb9e} +.politics-cp-shell .campaign-footer button,.politics-cp-shell .campaign-confirm button{background:linear-gradient(#d9b96e,#b59450);color:#2c1b20;border:1px solid #edcd83;border-radius:5px;padding:10px 18px;cursor:pointer;font-weight:bold} +.politics-cp-shell button:disabled{opacity:.6;cursor:default}.campaign-pagination{display:flex;align-items:center;gap:12px;margin-top:24px}.campaign-pagination button{padding:9px 14px} +.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}} diff --git a/website/control-panel/public/cp-v2/cp-v2-politics-shell.mjs b/website/control-panel/public/cp-v2/cp-v2-politics-shell.mjs index 4864dd8a..ddaeaeb3 100644 --- a/website/control-panel/public/cp-v2/cp-v2-politics-shell.mjs +++ b/website/control-panel/public/cp-v2/cp-v2-politics-shell.mjs @@ -1,6 +1,7 @@ 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'}; @@ -14,28 +15,30 @@ window.addEventListener('message',event=>{if(event.source===parent&&event.origin function show(){ if(!ready)return;const route=politicalRoute(location.hash),key=route.tab+'/'+route.page;if(key===current)return;current=key;dispose();dispose=()=>{}; const tab=POLITICAL_TABS.find(t=>t.id===route.tab),page=tab.pages.find(([id])=>id===route.page); - content.setAttribute('role','tabpanel');content.setAttribute('aria-labelledby','politics-tab-'+tab.id); - for(const button of tabs.children){const selected=button.dataset.tab===tab.id;button.setAttribute('aria-selected',String(selected));button.tabIndex=selected?0:-1;} - sidebar.replaceChildren(el('div',tab.label.toUpperCase(),'side-hero'));sidebarRight.replaceChildren(el('div',tab.label.toUpperCase()+' · DIRECTORY','side-hero')); - const split=Math.ceil(tab.pages.length/2); - for(const [index,pages]of [tab.pages.slice(0,split),tab.pages.slice(split)].entries()){ - const block=el('details',undefined,'category-block');block.open=matchMedia('(min-width:721px)').matches||pages.some(([id])=>id===page[0]);const heading=el('summary',undefined,'category-heading');heading.append(icon(tab.id),el('span',index?'Directory':'Chambers','category-name'),el('span',String(pages.length),'category-count'));block.append(heading);const links=el('div',undefined,'category-links'); - for(const [id,label]of pages){const link=el('a',undefined,'navitem');link.href='#'+tab.id+'/'+id;link.append(icon(tab.id),el('span',label));if(id===page[0])link.setAttribute('aria-current','page');links.append(link);}block.append(links);(index?sidebarRight:sidebar).append(block); - } - 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==='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); + 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('details',undefined,'category-block');block.open=items.some(([id])=>id===page[0])||title==='Imperial Senate';const summary=el('summary',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);}; + 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,'Participation',[['applications','My applications'],['electoral-roll','Electoral Roll']]); + 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 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=page[0]==='office-register'?mountOfficeRegister(host):mountPoliticsPage(host,page[0]); + dispose=['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(); } -function mountOfficeRegister(host){ +function mountOfficeRegister(host,view='office-register'){ const controller=new AbortController();let active=true;const status=el('p','Checking the public office register…');status.setAttribute('role','status');host.append(status); fetch('/api/public/government',{credentials:'same-origin',cache:'no-store',signal:controller.signal}).then(async response=>{const data=await response.json();if(!response.ok)throw Error(data.message||'Office register unavailable.');if(!active)return;const grid=el('div',undefined,'politics-office-grid'); - for(const office of data.offices){const card=el('article',undefined,'politics-office-card'),image=el('img');image.src=outer+'/assets/seals/'+office.art;image.alt='';image.width=image.height=76;card.append(image,el('small',office.scope),el('h2',office.name),el('p',office.description));if(office.holder){const link=el('a',office.holder.name);link.href=outer+'/people/'+encodeURIComponent(office.holder.username);link.target='_top';card.append(el('strong','In office'),link);}else card.append(el('p',office.state==='vacant'?'Awaiting an elected officeholder.':'Officeholder verification pending.'));grid.append(card);} + for(const office of data.offices.filter(o=>view==='office-register'||o.chamber===(view==='imperial-senate'?'Imperial Senate':'Small Council'))){const card=el('article',undefined,'politics-office-card'),image=el('img');image.src=outer+'/assets/seals/'+office.art;image.alt='';image.width=image.height=76;card.append(image,el('small',office.scope),el('h2',office.name),el('p',office.description));if(office.holder){const link=el('a',office.holder.name);link.href=outer+'/people/'+encodeURIComponent(office.holder.username);link.target='_top';card.append(el('strong','In office'),link);}else card.append(el('p',office.state==='vacant'?'Awaiting an elected officeholder.':'Officeholder verification pending.'));grid.append(card);} host.replaceChildren(grid); }).catch(error=>{if(active)status.textContent=error.message;});return()=>{active=false;controller.abort();}; } -for(const tab of POLITICAL_TABS){const button=el('button',undefined,'portal');button.append(icon(tab.id),el('span',tab.label));button.type='button';button.dataset.tab=tab.id;button.id='politics-tab-'+tab.id;button.setAttribute('role','tab');button.setAttribute('aria-controls','content');button.onclick=()=>{location.hash=tab.id+'/'+tab.pages[0][0];};button.onkeydown=event=>{if(!['ArrowLeft','ArrowRight','Home','End'].includes(event.key))return;event.preventDefault();const index=POLITICAL_TABS.indexOf(tab),next=event.key==='Home'?0:event.key==='End'?POLITICAL_TABS.length-1:(index+(event.key==='ArrowRight'?1:POLITICAL_TABS.length-1))%POLITICAL_TABS.length;tabs.children[next].click();tabs.children[next].focus();};tabs.append(button);} +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}); startCPAuthentication(user=>{if(!user.permissions?.includes('web.menu.game')){tabs.hidden=true;sidebar.hidden=true;sidebarRight.hidden=true;content.replaceChildren(el('p','Your account does not have access to the political chambers.'));return;}ready=true;show();}); diff --git a/website/control-panel/public/cp-v2/cp-v2-voting-directory.mjs b/website/control-panel/public/cp-v2/cp-v2-voting-directory.mjs new file mode 100644 index 00000000..01518cae --- /dev/null +++ b/website/control-panel/public/cp-v2/cp-v2-voting-directory.mjs @@ -0,0 +1,42 @@ +import {element as el} from './cp-v2-page-template.mjs'; +import {ELECTIONS} from '../political-catalog.mjs'; +export function mountVotingDirectory(host,selected=''){ + const controller=new AbortController();let active=true,page=0,serial=0,timer,busy=false; + const filters=el('form',undefined,'campaign-filters'),search=el('input'),election=el('select'),phase=el('select'),status=el('p','Opening the candidate register…'),grid=el('div',undefined,'campaign-grid'),pages=el('nav',undefined,'campaign-pagination'); + search.type='search';search.placeholder='Search players, biographies and campaign messages';search.setAttribute('aria-label','Search candidates'); + for(const [select,label,items]of [[election,'Election',[['','All elections'],...ELECTIONS.map(e=>[e.id,e.label])]],[phase,'Election status',[['','All statuses'],['upcoming','Applications open'],['voting','Voting open'],['closed','Closed']]]]){select.setAttribute('aria-label',label);for(const[value,text]of items){const option=el('option',text);option.value=value;select.append(option);}} + election.value=selected;status.setAttribute('role','status');filters.append(search,election,phase);host.replaceChildren(filters,status,grid,pages); + const dialog=el('dialog',undefined,'campaign-confirm');dialog.setAttribute('aria-label','Confirm your vote');host.append(dialog); + function card(candidate){ + const scope=ELECTIONS.find(e=>e.kind===candidate.kind&&e.faction===candidate.faction);if(!scope)return null; + const card=el('article',undefined,'campaign-card'),portrait=el('div',undefined,'campaign-portrait'),avatar=el('img'),seal=el('img',undefined,'campaign-seal'); + avatar.src='/api/avatars/face/roster/'+encodeURIComponent(candidate.username);avatar.alt=candidate.username+' Minecraft avatar';avatar.loading='lazy';avatar.onerror=()=>{avatar.onerror=null;avatar.src='/api/avatars/fallback';};avatar.width=avatar.height=128; + seal.src='https://www.dunerealms.com/assets/seals/'+scope.seal;seal.alt=scope.label+' seal';seal.width=seal.height=64;portrait.append(avatar,seal,el('span','Meet your candidate','campaign-kicker')); + const body=el('div',undefined,'campaign-body'),profile=el('a',candidate.name||candidate.username);profile.href='https://www.dunerealms.com/people/'+encodeURIComponent(candidate.username);profile.target='_top';const name=el('h2');name.append(profile); + const date=new Date(candidate.start).toLocaleDateString('en-GB',{timeZone:'UTC',dateStyle:'medium'}); + body.append(el('small',scope.chamber+' · '+date),name,el('strong',scope.label,'campaign-office'),el('p',candidate.bio||'This player has not added a public biography.','campaign-bio')); + const message=el('details',undefined,'campaign-message'),summary=el('summary','Campaign message');message.open=true;message.append(summary,el('p',candidate.motivation));body.append(message); + const footer=el('div',undefined,'campaign-footer'),label=candidate.phase==='voting'&&candidate.round?.eligible?'Vote':candidate.phase==='upcoming'?'Voting opens at election time':'Voting closed',vote=el('button',label);vote.type='button';vote.disabled=label!=='Vote';vote.onclick=()=>confirm(candidate,scope);footer.append(el('span',candidate.publicId),vote);body.append(footer);card.append(portrait,body);return card; + } + async function confirm(candidate,scope){ + if(busy)return;busy=true;dialog.replaceChildren(el('h2','Vote for '+candidate.username+'?'),el('p',scope.label+' · Your submitted vote is final.')); + const feedback=el('p','Checking your eligibility and remaining votes…'),cancel=el('button','Cancel'),submit=el('button','Confirm vote'),amount=el('input'),label=el('label','Votes');amount.type='number';amount.min='1';amount.step='1';amount.value='1';amount.setAttribute('aria-label','Number of votes');label.append(amount);submit.disabled=true;cancel.type=submit.type='button';feedback.setAttribute('role','status');dialog.append(label,feedback,cancel,submit);dialog.showModal(); + cancel.onclick=()=>dialog.close();dialog.onclose=()=>{busy=false;};let ballot; + try{const response=await fetch('/api/politics/ballot/'+candidate.kind,{credentials:'same-origin',cache:'no-store',signal:controller.signal});ballot=await response.json();if(!active)return;if(!response.ok)throw Error(ballot.message||'Could not verify your ballot.'); + if(ballot.faction!==candidate.faction||ballot.start!==candidate.start||ballot.round?.id!==candidate.round?.id||ballot.round?.status!=='open'||Date.now()=ballot.round.closesAt||!ballot.candidates.some(c=>c.id===candidate.id))throw Error('This candidate is outside your current eligible ballot.'); + if(ballot.remaining<1)throw Error('You have no votes remaining for this election.');amount.max=String(ballot.remaining);feedback.textContent=ballot.remaining+' vote(s) available.';submit.disabled=false; + }catch(error){feedback.textContent=error.message;} + const requestId=crypto.randomUUID();let sending=false,payload=null; + submit.onclick=async()=>{if(submit.disabled||sending)return;const votes=Number(amount.value);if(!Number.isInteger(votes)||votes<1||votes>ballot.remaining){feedback.textContent='Choose a whole number within your remaining allowance.';return;} + sending=true;submit.disabled=true;cancel.disabled=true;amount.disabled=true;dialog.oncancel=event=>event.preventDefault(); + payload||={kind:candidate.kind,start:ballot.start,roundId:ballot.round.id,requestId,confirmed:true,allocations:[{applicationId:candidate.id,votes}]}; + try{const response=await fetch('/api/politics/ballot/'+candidate.kind,{method:'POST',credentials:'same-origin',headers:{'Content-Type':'application/json'},body:JSON.stringify(payload),signal:controller.signal}),result=await response.json();if(!active)return;if(!response.ok)throw Error(result.message||'Vote not accepted.');feedback.textContent='Your vote is recorded. '+result.ballot.remaining+' vote(s) remain.';submit.remove();cancel.textContent='Close';await load();} + catch(error){feedback.textContent=error.message+' Check your ballot before retrying.';submit.textContent='Retry same submission';submit.disabled=false;} + finally{sending=false;cancel.disabled=false;dialog.oncancel=null;} + }; + } + async function load(){const request=++serial;status.textContent='Loading candidates…';try{const query=new URLSearchParams({q:search.value,election:election.value,status:phase.value,page:String(page)}),response=await fetch('/api/politics/directory?'+query,{cache:'no-store',credentials:'same-origin',signal:controller.signal}),data=await response.json();if(!active||request!==serial)return;if(!response.ok)throw Error(data.message||'Directory unavailable.');grid.replaceChildren();for(const candidate of data.applications){const item=card(candidate);if(item)grid.append(item);}status.textContent=data.total?data.total+' application(s) · grouped by election, newest first.':'No applications match these filters.';pages.replaceChildren();for(const[label,delta]of [['Previous',-1],['Next',1]]){const button=el('button',label);button.type='button';button.disabled=delta<0?page===0:(page+1)*data.pageSize>=data.total;button.onclick=()=>{page+=delta;void load();};pages.append(button);}pages.append(el('span','Page '+(page+1)));} + catch(error){if(active&&request===serial)status.textContent=error.message;}} + filters.onsubmit=event=>{event.preventDefault();page=0;void load();};search.oninput=()=>{clearTimeout(timer);timer=setTimeout(()=>{page=0;void load();},250);};election.onchange=phase.onchange=()=>{page=0;void load();};void load(); + return()=>{active=false;clearTimeout(timer);controller.abort();if(dialog.open)dialog.close();}; +} diff --git a/website/control-panel/public/election-applications-view.mjs b/website/control-panel/public/election-applications-view.mjs index 45c0b871..85be8af8 100644 --- a/website/control-panel/public/election-applications-view.mjs +++ b/website/control-panel/public/election-applications-view.mjs @@ -1,7 +1,7 @@ import {electionDates,electionWindow} from './election-rules.mjs'; const node=(tag,text,cls)=>{const e=document.createElement(tag);if(text!==undefined)e.textContent=text;if(cls)e.className=cls;return e;}; const date=value=>new Date(Number(value)).toLocaleString('en-GB',{timeZone:'UTC',dateStyle:'medium',timeStyle:'short'})+' GMT'; -export function applicationElectionId(row){const code=row.kind==='imperial'?'IMP':row.faction==='veiled_concord'?'CON':'HSE';return 'ELC-'+code+'-'+new Date(Number(row.election_start)).toISOString().slice(0,10).replaceAll('-','');} +export function applicationElectionId(row){const code=row.kind==='guild'?'GLD':row.kind==='clan_delegate'?'CLN':row.kind==='imperial'?'IMP':row.faction==='veiled_concord'?'CON':'HSE';return 'ELC-'+code+'-'+new Date(Number(row.election_start)).toISOString().slice(0,10).replaceAll('-','');} export function renderApplications({user,context}){ const host=node('div',undefined,'applications-dashboard'); const register=node('article',undefined,'politics-card');register.append(node('h3','Your application register'),node('p','Your latest 100 candidatures, round totals and recorded results. Votes shown belong to your latest participating round; runoff votes are counted separately. Cosmetic rank and seal delivery is still being connected.')); @@ -9,8 +9,8 @@ export function renderApplications({user,context}){ const area=node('div',undefined,'applications-table-wrap'),details=node('section',undefined,'politics-card applications-details');details.hidden=true;details.tabIndex=-1;host.append(register,details); const form=node('form',undefined,'politics-card politics-charter');form.append(node('h3','Stand before the banners'),node('p','Apply for the next scheduled election. Submitting does not grant an office or award.')); const label=node('label','Application type'),select=node('select');select.required=true; - if(context?.factionStatus==='verified'&&context.faction){const o=node('option',context.faction==='veiled_concord'?'CON · Reverent Mother':'HSE · House Leader');o.value='house';select.append(o);} - const imp=node('option','IMP · Emperor');imp.value='imperial';select.append(imp);label.append(select); + if(context?.factionStatus==='verified'&&['atreides','harkonnen','corrino','ordos'].includes(context.faction)){const o=node('option',context.faction==='veiled_concord'?'CON · Reverent Mother':'HSE · House Leader');o.value='house';select.append(o);} + for(const [kind,label] of [['imperial','Emperor'],['bene','Reverent Mother · Bene Gesserit'],['guild','Spacing Guild Leader'],['clan_delegate','Clan Delegate']]){const o=node('option',label);o.value=kind;select.append(o);}label.append(select); const schedule=node('p'),motivation=node('label','Motivation and plans'),text=node('textarea');text.rows=5;text.minLength=20;text.maxLength=4000;text.required=true;motivation.append(text); const consent=node('label',undefined,'politics-accept'),check=node('input');check.type='checkbox';check.required=true;consent.append(check,node('span','I accept the responsibilities of this candidature.')); const submit=node('button','Submit application');submit.type='submit';submit.disabled=true;const feedback=node('p');feedback.setAttribute('role','status'); @@ -18,7 +18,7 @@ export function renderApplications({user,context}){ function updateSchedule(){const start=electionDates(select.value)[0],window=electionWindow(select.value,start);schedule.textContent='Applications close '+date(Date.parse(start))+'. Voting ends '+date(Date.parse(window.votingCloses))+'.';submit.disabled=busy||!access||context?.linked!==true;} select.addEventListener('change',updateSchedule);updateSchedule(); function draw(){area.replaceChildren();const table=node('table',undefined,'applications-table');table.append(node('caption','Your numbered election applications'));const head=node('thead'),tr=node('tr');for(const h of ['Application ID','User name','Function','Date','Election ID','Status','Votes received','Result / rank awarded','3× honour','Details']){const th=node('th',h);th.scope='col';tr.append(th);}head.append(tr);table.append(head);const body=node('tbody'); - for(const row of rows.slice(page*9,page*9+9)){const office=row.kind==='imperial'?'Emperor':row.faction==='veiled_concord'?'Reverent Mother':'House Leader',closed=row.progress?.state==='closed';const tr=node('tr');for(const value of [row.public_id,user?.username||'',office,date(row.created_at),applicationElectionId(row),closed?'Closed':'Open (ongoing)',String(row.progress?.votes??0),row.progress?.result||'Pending',row.progress?.honour?'Yes':'No'])tr.append(node('td',value));const art=node('img');art.src='https://www.dunerealms.com/assets/seals/'+(row.kind==='imperial'?'emperor-v1.png':row.faction==='veiled_concord'?'veiled-concord-v1.png':'office-house_leader.png');art.alt='';art.width=art.height=28;tr.children[2].prepend(art);const td=node('td'),button=node('button','Details');button.type='button';button.onclick=()=>{details.replaceChildren(node('h3',row.public_id+' · '+office));const data=node('dl',undefined,'applications-detail-grid');for(const [key,value]of [['Applicant',user?.username||''],['Faction',row.faction],['Election ID',applicationElectionId(row)],['Application received',date(row.created_at)],['Voting starts / applications close',date(row.election_start)],['Voting closes',date(Number(row.election_start)+10800000)],['Record state',row.status],['Result',row.progress?.result||'Pending'],['Voting',row.progress?.phase||'Awaiting round'],['Office ledger',row.progress?.officeRecorded?'Term recorded; cosmetic rank delivery is separate':'No term recorded'],['Three-term honour',row.progress?.honour?.title||'Not earned'],['Round totals',(row.progress?.rounds||[]).map(r=>'Round '+r.number+': '+(r.eligible?r.votes+' votes':'Not in this runoff')).join('; ')||'Voting has not started']])data.append(node('dt',key),node('dd',value));details.append(data,node('h4','Motivation'),node('p',row.motivation));details.hidden=false;details.focus();};td.append(button);tr.append(td);body.append(tr);}table.append(body);area.append(table); + for(const row of rows.slice(page*9,page*9+9)){const office=row.kind==='guild'?'Spacing Guild Leader':row.kind==='clan_delegate'?'Clan Delegate':row.kind==='imperial'?'Emperor':row.faction==='veiled_concord'?'Reverent Mother':'House Leader',closed=row.progress?.state==='closed';const tr=node('tr');for(const value of [row.public_id,user?.username||'',office,date(row.created_at),applicationElectionId(row),closed?'Closed':'Open (ongoing)',String(row.progress?.votes??0),row.progress?.result||'Pending',row.progress?.honour?'Yes':'No'])tr.append(node('td',value));const art=node('img');art.src='https://www.dunerealms.com/assets/seals/'+(row.kind==='imperial'?'emperor-v1.png':row.faction==='veiled_concord'?'veiled-concord-v1.png':'office-house_leader.png');art.alt='';art.width=art.height=28;tr.children[2].prepend(art);const td=node('td'),button=node('button','Details');button.type='button';button.onclick=()=>{details.replaceChildren(node('h3',row.public_id+' · '+office));const data=node('dl',undefined,'applications-detail-grid');for(const [key,value]of [['Applicant',user?.username||''],['Faction',row.faction],['Election ID',applicationElectionId(row)],['Application received',date(row.created_at)],['Voting starts / applications close',date(row.election_start)],['Voting closes',date(Number(row.election_start)+10800000)],['Record state',row.status],['Result',row.progress?.result||'Pending'],['Voting',row.progress?.phase||'Awaiting round'],['Office ledger',row.progress?.officeRecorded?'Term recorded; cosmetic rank delivery is separate':'No term recorded'],['Three-term honour',row.progress?.honour?.title||'Not earned'],['Round totals',(row.progress?.rounds||[]).map(r=>'Round '+r.number+': '+(r.eligible?r.votes+' votes':'Not in this runoff')).join('; ')||'Voting has not started']])data.append(node('dt',key),node('dd',value));details.append(data,node('h4','Motivation'),node('p',row.motivation));details.hidden=false;details.focus();};td.append(button);tr.append(td);body.append(tr);}table.append(body);area.append(table); if(rows.length>9){const nav=node('nav',undefined,'politics-pagination');for(const [label,step]of [['Previous',-1],['Next',1]]){const b=node('button',label);b.type='button';b.disabled=step<0?page===0:(page+1)*9>=rows.length;b.onclick=()=>{page+=step;draw();};nav.append(b);}nav.append(node('span','Page '+(page+1)+' of '+Math.ceil(rows.length/9)));area.append(nav);}status.textContent=rows.length?rows.length+' submitted application(s).':'No applications submitted yet.';if(!area.isConnected)register.append(area); } async function load(){try{const r=await fetch('/api/politics/applications',{cache:'no-store'}),data=await r.json();if(!host.isConnected)return;if(!r.ok)throw Error(data.message||'Could not load your register.');rows=data.applications||[];access=true;page=0;draw();}catch(error){access=false;status.textContent=error.message;}updateSchedule();} diff --git a/website/control-panel/public/politics.mjs b/website/control-panel/public/politics.mjs index 7945127b..58ccd52e 100644 --- a/website/control-panel/public/politics.mjs +++ b/website/control-panel/public/politics.mjs @@ -28,7 +28,7 @@ function disabled(text){const b=el('button',text);b.type='button';b.disabled=tru function demoNote(){return el('p','DEMO DATA · Fictional names, votes and support. Nothing is submitted or saved.','politics-demo-note');} function demoSupport(counter=false){const box=el('div',undefined,'politics-demo-support');box.append(demoNote());for(const [name,state]of [['House Amber','Supports'],['House Jade',counter?'Supports':'Awaiting agreement']]){const row=el('p');row.append(el('strong',name+' · '),el('span',state));box.append(row);}box.append(el('strong',counter?'Demo outcome: 2 / 2 Houses — election denied':'Demo progress: 1 / 2 Houses'));return box;} function electionCalendar(imperial=false){ - const weeks=imperial?4:2,hour=imperial?15:9; + const weeks=4,hour=imperial?15:9; const box=card(imperial?'The Imperial Almanac':'The House Almanac',`Every ${weeks} weeks · Sunday · ${String(hour).padStart(2,'0')}:00 GMT. Term: ${weeks} weeks.`,imperial?'seals/emperor-v1.png':'seals/office-house_leader.png'); box.classList.add('politics-calendar-card'); box.append(el('p','CONFIRMED CALENDAR · First election Sunday: 15 November 2026. Voting availability is confirmed by the election service.','politics-demo-note')); @@ -38,7 +38,7 @@ function electionCalendar(imperial=false){ time.append(el('small',new Intl.DateTimeFormat('en-GB',{month:'short',year:'numeric',timeZone:'UTC'}).format(date)),el('strong',String(date.getUTCDate()).padStart(2,'0')),el('span',`Sunday · ${String(hour).padStart(2,'0')}:00 GMT`)); entry.append(time,el('small','Scheduled'));list.append(entry); } - box.append(list,el('p',imperial?'On an Imperial election Sunday, Faction Elections take place at 09:00 GMT, followed by Emperor Elections at 15:00 GMT.':'Faction Elections run every two weeks. Every second House election Sunday also includes Emperor Elections at 15:00 GMT.'),el('p','Times stay fixed to GMT throughout the year.'));return box; + box.append(list,el('p',imperial?'On an Imperial election Sunday, Faction Elections take place at 09:00 GMT, followed by Emperor Elections at 15:00 GMT.':'House Leader elections run every four weeks. Emperor elections follow at 15:00 GMT.'),el('p','Times stay fixed to GMT throughout the year.'));return box; } function electionPreview(imperial=false){ const host=el('div',undefined,'politics-content');const overview=el('div',undefined,'politics-election-overview');overview.append(electionCalendar(imperial));host.append(overview); @@ -135,7 +135,7 @@ fetch('/api/auth/session',{cache:'no-store'}).then(r=>r.ok?r.json():null).then(d function applicationsDashboard(){ const host=el('div',undefined,'applications-dashboard'); const types=[['HSE','House Leader'],['CON','Reverent Mother'],['IMP','Emperor']]; - const records=types.map(([prefix,role],i)=>({id:`APP-${prefix}-2026-000001`,prefix,user:'Demo '+['DuneWeaver','MoonSurveyor','AmberWarden'][i],role,date:'2026-11-08',election:`ELC-${prefix}-2026-000001`,status:i===2?'Closed':'Open (ongoing)',votes:[24,18,84][i],result:i===2?'Emperor':'Pending',honour:false,motivation:'Fictional example: I would represent our community through open discussion, clear decisions and shared projects.',term:prefix==='IMP'?'4 weeks':'2 weeks',time:prefix==='IMP'?'Sunday 15:00 GMT':'Sunday 09:00 GMT'})); + const records=types.map(([prefix,role],i)=>({id:`APP-${prefix}-2026-000001`,prefix,user:'Demo '+['DuneWeaver','MoonSurveyor','AmberWarden'][i],role,date:'2026-11-08',election:`ELC-${prefix}-2026-000001`,status:i===2?'Closed':'Open (ongoing)',votes:[24,18,84][i],result:i===2?'Emperor':'Pending',honour:false,motivation:'Fictional example: I would represent our community through open discussion, clear decisions and shared projects.',term:'4 weeks',time:prefix==='IMP'?'Sunday 15:00 GMT':'Sunday 09:00 GMT'})); const register=card('Application register','Numbered candidatures and their linked election results.','seals/office-landsraad.png');register.append(demoNote()); const stats=el('div',undefined,'applications-stats');for(const [label,value]of [['Election Applications',records.length],['Open',2],['Closed',1]]){const box=el('div');box.append(el('strong',String(value)),el('span',label));stats.append(box);}register.append(stats); const wrap=el('div',undefined,'applications-table-wrap'),table=el('table',undefined,'applications-table');const caption=el('caption','Illustrative application history — no real submissions');table.append(caption);const head=el('thead'),heading=el('tr');for(const title of ['Application ID','User name','Function','Date','Election ID','Status','Votes received','Result / rank awarded','3× honour','Details']){const th=el('th',title);th.scope='col';heading.append(th);}head.append(heading);table.append(head);const body=el('tbody'); diff --git a/website/docs/political-artwork.md b/website/docs/political-artwork.md new file mode 100644 index 00000000..5d35f725 --- /dev/null +++ b/website/docs/political-artwork.md @@ -0,0 +1,8 @@ +# Political CP artwork + +Generated with the built-in image generation tool, 15 November 2026. + +- web/assets/political-imperial-chamber-v1.png: Wide cinematic imperial governmental parliament, detailed Minecraft voxel sandstone architecture inspired by a Dune desert empire; burgundy banners, antique gold ornaments, warm muted desert light, distant sandstone city, painterly game environment, no people, text, logos or watermark. +- web/assets/political-small-council-v1.png: Atmospheric imperial Minecraft desert-world Small Council library, circular voxel sandstone architecture, gilded celestial globe and map table, burgundy draperies, brass emblems, desert through arches; painterly game environment, no people, readable text, logos or watermark. + +Images serve as decorative backgrounds beneath solid readable content panels. diff --git a/website/node/electoral-roll.mjs b/website/node/electoral-roll.mjs index 363b820a..01c01ff7 100644 --- a/website/node/electoral-roll.mjs +++ b/website/node/electoral-roll.mjs @@ -1,5 +1,5 @@ const houses={atreides:'House Aerdrecht',harkonnen:'House Harkveen',corrino:'House Korenholt',ordos:'House Oordwijk',fremen:'House Vrijduin',veiled_concord:'Veiled Concord'}; -export function rollRow(r){return {username:r.username,election:(r.kind==='imperial'?'Emperor':houses[r.faction]||r.faction)+' · '+new Date(Number(r.election_start)).toISOString().slice(0,10)+' · Round '+(Number(r.round_number)+1),votes:Number(r.votes)};} +export function rollRow(r){return {username:r.username,election:(({imperial:'Emperor',bene:'Bene Gesserit',guild:'Spacing Guild',clan_delegate:'Clan Delegate'})[r.kind]||houses[r.faction]||r.faction)+' · '+new Date(Number(r.election_start)).toISOString().slice(0,10)+' · Round '+(Number(r.round_number)+1),votes:Number(r.votes)};} export async function votingHonour(db,userId,now=Date.now()){ const row=await db.prepare(`SELECT MAX(r.closes_at) AS expires_at FROM political_election_rounds r WHERE r.status='open' AND r.opens_at<=? AND r.closes_at>? diff --git a/website/tests/political-cp.test.mjs b/website/tests/political-cp.test.mjs index f52e3950..ee6482f1 100644 --- a/website/tests/political-cp.test.mjs +++ b/website/tests/political-cp.test.mjs @@ -9,8 +9,8 @@ import {governmentRoute,politicalFrameMessage} from '../web/government-cp.js'; import {workspacesForSurface} from '../control-panel/public/cp-v2/cp-v2-surface.mjs'; import {politicsCPDocument} from '../control-panel/politics-cp-shell.mjs'; -test('Political CP exposes exactly Elections, Offices and Tools with every existing chamber',()=>{ - assert.deepEqual(POLITICAL_TABS.map(t=>t.label),['Elections','Offices','Tools']); +test('Political CP exposes central Elections, Voting Directory, Offices and Tools menus with every existing chamber',()=>{ + assert.deepEqual(POLITICAL_TABS.map(t=>t.label),['Elections','Voting Directory','Offices','Tools']); const pages=POLITICAL_TABS.flatMap(t=>t.pages.map(([id])=>id));assert.equal(new Set(pages).size,pages.length); for(const tab of POLITICAL_TABS)for(const [page]of tab.pages){const route=tab.id+'/'+page;assert.deepEqual(politicalRoute('#'+route),{tab:tab.id,page});assert.equal(governmentRoute(route),route);assert.equal(governmentRoute('politics/'+page),route);assert.equal(politicsDestination('politics',page),'https://www.dunerealms.com/government.html#'+route);assert.equal(politicsDestination(page),'https://www.dunerealms.com/government.html#'+route);} assert.equal(politicalRoute('elections').page,'house-elections');assert.equal(politicalRoute('offices').page,'office-register');assert.equal(politicalRoute('tools').page,'council-motd'); @@ -27,16 +27,17 @@ test('the real server serves an independent Political CP and styles without the const response=await app(new Request('https://cp.dunerealms.com/politics-cp'));assert.equal(response.status,200);assert.match(response.headers.get('content-type'),/text\/html/);const html=await response.text();assert.match(html,/data-cp-mode="politics"/);assert.match(html,/cp-v2-politics-shell.mjs/);assert.match(html,/class="command-banner"/);assert.match(html,/id="sidebar-right"/);assert.doesNotMatch(html,/src="\/v2\/v2.js|class="dune-site-header"/); assert.equal((await app(new Request('https://cp.dunerealms.com/politics-cp',{method:'HEAD'}))).status,200);assert.equal((await app(new Request('https://cp.dunerealms.com/politics-cp',{method:'POST'}))).status,405); for(const file of ['cp-v2-politics-shell.mjs','cp-v2-politics-shell.css','cp-v2-politics-navigation.mjs','cp-v2-politics-native.css'])assert.equal((await app(new Request('https://cp.dunerealms.com/v2/'+file))).status,200,file); + assert.equal((await app(new Request('https://cp.dunerealms.com/political-catalog.mjs'))).status,200); assert.equal((await app(new Request('https://cp.dunerealms.com/api/public/government?user=other'))).status,400);assert.equal((await app(new Request('https://cp.dunerealms.com/api/public/government',{method:'POST'}))).status,405); }finally{db.close();} }); test('Political CP reuses the authored CP layout and normal CP remains a valid classic script',async()=>{ const template=await readFile(new URL('../control-panel/public/cp-v2/index.html',import.meta.url),'utf8'),html=politicsCPDocument(template); - const layout=template.slice(template.indexOf('