145 lines
29 KiB
JavaScript
145 lines
29 KiB
JavaScript
import {renderCharters} from './imperial-charters-view.mjs';
|
||
import {renderProclamations,proclamationBox} from './proclamations-view.mjs';
|
||
import {renderElectoralRoll} from './electoral-roll-view.mjs';
|
||
import {renderVoting} from './election-voting-view.mjs';
|
||
import {renderApplications} from './election-applications-view.mjs';
|
||
import {electionDates,imperialVoteAllowance} from './election-rules.mjs';
|
||
import {councilPreview,inboxPreview,resetInboxViews,motdPreview,motdEditor} from './council-preview.mjs';
|
||
const el=(tag,text,cls)=>{const n=document.createElement(tag);if(text!==undefined)n.textContent=text;if(cls)n.className=cls;return n;};
|
||
const asset=name=>['imperial-post-seal.svg','imperial-post-seal-v2.png'].includes(name)?'/assets/'+name:'https://www.dunerealms.com/assets/'+name;
|
||
const specs={
|
||
'electoral-roll':['THE VOICES OF THE REALM','Electoral Roll','Every voice recorded. Every choice private.','seals/office-landsraad.png'],
|
||
'council-motd':['WORDS BENEATH THE BANNERS','Proclamations','Proclamations of your faction and the Imperial throne.','seals/office-landsraad.png'],
|
||
'applications':['THE IMPERIAL REGISTER','Election Applications','Your candidatures, decisions and honours in one register.','seals/office-landsraad.png'],
|
||
'formal-council':['THE HOUSE COUNCIL','Faction Council','Stewardship, diplomacy and the voice of your House.','seals/office-house_leader.png'],
|
||
'shared-inbox':['LETTERS OF THE REALMS','Inbox','Personal, House, Clan and System correspondence.','imperial-post-seal-v2.png'],
|
||
landsraad:['THE GREAT ASSEMBLY','Landsraad Assembly','Your voice. Your House. The future of the Imperium.','seals/office-landsraad.png'],
|
||
'house-elections':['YOUR HOUSE, YOUR VOICE','Faction Elections','A chamber reserved for the faction you chose in game.','seals/office-house_leader.png'],
|
||
'imperial-elections':['THE IMPERIAL BALLOT','Emperor Elections','The future seat of the Imperial election.','seals/emperor-v1.png'],
|
||
'imperial-command':['BY IMPERIAL DECREE','Imperial Council','The Emperor’s future workspace for water and spice rights.','seals/emperor-v1.png'],
|
||
'imperial-water':['THE WATER CHARTER','Water Rights','Stewardship of the Imperium’s most precious resource.','seals/water-rights-v1.png'],
|
||
'imperial-spice':['THE SPICE CHARTER','Spice Rights','The Emperor’s future register of spice rights.','seals/spice-rights-v1.png']
|
||
};
|
||
const dashboard=document.getElementById('dashboard'),nav=dashboard?.querySelector('nav'),views={};let user=null,serial=0,context=null;
|
||
const commandLinks=[['Imperial Council','imperial-command','seals/emperor-v1.png'],['Water Rights','imperial-water','seals/water-rights-v1.png'],['Spice Rights','imperial-spice','seals/spice-rights-v1.png']];
|
||
function artLink(label,page,art){const a=el('a');a.href='#'+page;const img=el('img');img.src=asset(art);img.alt='';img.width=img.height=32;a.append(img,el('span',label));return a;}
|
||
function card(title,copy,art){const box=el('article',undefined,'politics-card');if(art){const img=el('img');img.src=asset(art);img.alt='';img.width=80;img.height=80;box.append(img);}box.append(el('h3',title),el('p',copy));return box;}
|
||
function disabled(text){const b=el('button',text);b.type='button';b.disabled=true;return b;}
|
||
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=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'));
|
||
const list=el('ol',undefined,'politics-calendar');list.setAttribute('aria-label','Confirmed election dates');
|
||
for(let i=0;i<4;i++){
|
||
const date=new Date(electionDates(imperial?'imperial':'house')[i]),entry=el('li'),time=el('time');time.dateTime=date.toISOString();
|
||
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.':'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);
|
||
host.append(artLink('Submit or view applications','applications','seals/office-landsraad.png'));
|
||
const ballot=card(imperial?'The Throne’s Ballot':'The House Ballot',imperial?'Faction members have 1 vote. House leaders have 5 votes, freely divided between candidates. This ballot remains a design preview.':'All faction members can vote for a leader of their own faction. Choose one demo candidate.');ballot.append(el('p',imperial?'Before the assembled banners, weigh the voices that would bear the crown.':'Beneath your House banner, choose the voice that will carry its oath to the chamber.','politics-oath'),demoNote(),el('p','Choose a sort order below. Demo allocations do not change the example standings.'));
|
||
const names=['DuneWeaver','AmberWarden','SandCartographer','JadeVoyager','SpiceScribe','CanyonKeeper','SietchGardener','MoonSurveyor','DesertMason','WaterArchivist','GoldenNomad','DawnBuilder'];
|
||
const candidates=names.map((name,i)=>({name:'Demo '+name,votes:84-i*5,id:i,motivation:'I want to represent our community through open discussion, reliable leadership and shared projects. This is a fictional candidate statement for layout review.'}));
|
||
const leaders=card('Current Top 3','The leading voices before the chamber.');leaders.classList.add('politics-leaders');leaders.append(demoNote());const standing=el('ol');for(const c of candidates.slice(0,3)){const row=el('li');const face=el('div',undefined,'politics-demo-head');face.setAttribute('aria-hidden','true');for(let i=0;i<64;i++)face.append(el('span',undefined,[0,1,2,3,4,5,6,7,8,15].includes(i)?'hair':[26,29].includes(i)?'eye':[43,44].includes(i)?'mouth':'skin'));const identity=el('div',undefined,'politics-leader-identity');identity.append(el('strong',c.name),el('span',imperial?'Candidate for Emperor':context?.faction==='veiled_concord'?'Candidate for Reverent Mother':'Candidate for House Leader'),el('small',c.votes+' demo votes'));const badge=el('img');badge.src=asset(imperial?'seals/emperor-v1.png':'seals/office-house_leader.png');badge.alt='Candidate';badge.title='Candidate — not an awarded office';badge.width=badge.height=28;const pledge=el('details'),toggle=el('summary','Motivation');pledge.append(toggle,el('p',c.motivation));row.append(face,identity,badge,pledge);standing.append(row);}leaders.append(standing);overview.append(leaders);
|
||
const filters=el('div',undefined,'politics-ballot-filters'),search=el('input');search.type='search';search.placeholder='Search candidates';search.setAttribute('aria-label','Search candidates');filters.append(search);let order='votes';const sorted=()=>candidates.filter(c=>c.name.toLowerCase().includes(search.value.trim().toLowerCase())).sort((a,b)=>order==='votes'?b.votes-a.votes||a.name.localeCompare(b.name):order==='az'?a.name.localeCompare(b.name):b.name.localeCompare(a.name));const sortButtons=[];for(const [key,label]of [['votes','Most votes'],['az','Name A–Z'],['za','Name Z–A']]){const b=el('button',label);b.type='button';b.setAttribute('aria-pressed',String(order===key));b.addEventListener('click',()=>{order=key;page=0;for(const [k,btn]of sortButtons)btn.setAttribute('aria-pressed',String(k===order));draw();});sortButtons.push([key,b]);filters.append(b);}search.addEventListener('input',()=>{page=0;draw();});
|
||
let page=0,selected=null;const allocations=new Map();const total=()=>[...allocations.values()].reduce((a,b)=>a+b,0);const status=el('p',undefined,'politics-ballot-status');status.setAttribute('role','status');const grid=el('div',undefined,'politics-candidates'),pages=el('nav',undefined,'politics-pagination');pages.setAttribute('aria-label',(imperial?'Imperial':'House')+' demo candidate pages');
|
||
const allowance=imperialVoteAllowance(context||{});
|
||
const updateStatus=()=>{status.textContent=imperial?total()+' of '+allowance+' demo votes allocated':selected===null?'Choose one demo candidate':'Selected: '+candidates[selected].name;};
|
||
function draw(){grid.replaceChildren();pages.replaceChildren();updateStatus();for(const c of sorted().slice(page*9,page*9+9)){
|
||
const tile=el('article',undefined,'politics-candidate');const head=el('div',undefined,'politics-demo-head');head.setAttribute('aria-hidden','true');for(let i=0;i<64;i++)head.append(el('span',undefined,[0,1,2,3,4,5,6,7,8,15].includes(i)?'hair':[26,29].includes(i)?'eye':[43,44].includes(i)?'mouth':'skin'));tile.append(head,el('h4',c.name));const office=el('p',imperial?'Candidate for Emperor':context?.faction==='veiled_concord'?'Candidate for Reverent Mother':'Candidate for House Leader','politics-candidate-office');const icon=el('img');icon.src=asset(imperial?'seals/emperor-v1.png':'seals/office-house_leader.png');icon.alt='Candidate';icon.title='Candidate — not an awarded office';icon.width=icon.height=28;icon.className='politics-candidate-icon';tile.append(office,icon);
|
||
if(imperial){const controls=el('div',undefined,'politics-allocation'),minus=el('button','−'),plus=el('button','+'),count=el('output',String(allocations.get(c.id)||0));minus.type=plus.type='button';minus.setAttribute('aria-label','Remove demo vote from '+c.name);plus.setAttribute('aria-label','Add demo vote to '+c.name);count.setAttribute('aria-label','Allocated votes for '+c.name);minus.disabled=!allocations.get(c.id);plus.disabled=total()>=allowance;
|
||
minus.addEventListener('click',()=>{allocations.set(c.id,Math.max(0,(allocations.get(c.id)||0)-1));draw();});plus.addEventListener('click',()=>{if(total()<allowance)allocations.set(c.id,(allocations.get(c.id)||0)+1);draw();});controls.append(minus,count,plus);tile.append(controls);
|
||
}else{const choice=el('label',undefined,'politics-accept'),radio=el('input');radio.type='radio';radio.name='house-demo-vote';radio.value=String(c.id);radio.checked=selected===c.id;radio.addEventListener('change',()=>{selected=c.id;updateStatus();});choice.append(radio,el('span','Vote for '+c.name));tile.append(choice);}
|
||
const details=el('details'),summary=el('summary','Read the candidate’s pledge');details.append(summary,el('p',c.motivation));tile.append(details);grid.append(tile);}
|
||
const prev=el('button','Previous'),next=el('button','Next');prev.type=next.type='button';prev.disabled=page===0;next.disabled=(page+1)*9>=sorted().length;prev.addEventListener('click',()=>{page--;draw();});next.addEventListener('click',()=>{page++;draw();});pages.append(prev,el('span','Page '+(page+1)+' of '+Math.max(1,Math.ceil(sorted().length/9))),next);
|
||
if(!grid.children.length)grid.append(el('p','No matching candidates. Your current selection is retained.'));}draw();ballot.append(filters,status,grid,pages,disabled('Submit vote — preview only'));host.append(ballot);return host;
|
||
}
|
||
function rallyPreview(){
|
||
const box=card('Force elections','Two different Houses must agree before a new election is held.','seals/office-landsraad.png');
|
||
const start=el('section');start.append(el('h4','Start a rally'),el('p','Call for a new election and explain why the chamber should return to the ballot.'));
|
||
const label=el('label','Reason for the rally'),reason=el('textarea');reason.rows=4;reason.placeholder='Explain why a new election is needed';reason.disabled=true;label.append(reason);start.append(label,disabled('Start a rally'));
|
||
const support=el('section');support.append(el('h4','House agreement'),el('p','Required support: 2 distinct Houses. Multiple endorsements from the same House count only once.'),el('p','No active rally — this is a design preview.'),disabled('Support this rally'));
|
||
reason.value='DEMO: We ask the Houses to support a fresh election and a renewed mandate.';support.append(demoSupport());const grid=el('div',undefined,'politics-grid');start.className='politics-charter';support.className='politics-card';grid.append(start,support);box.append(grid);return box;
|
||
}
|
||
function counterRallyPreview(){
|
||
const box=card('Counter rally','Rally House support against the proposed election. Agreement from two distinct Houses denies the election.','seals/emperor-v1.png');
|
||
const label=el('label','Reason for the counter rally'),reason=el('textarea');reason.rows=4;reason.placeholder='Explain why the proposed election should not proceed';reason.disabled=true;label.append(reason);
|
||
const draft=el('section',undefined,'politics-charter');draft.append(label,disabled('Start a counter rally'));
|
||
reason.value='DEMO: Maintain the current mandate and allow the agreed programme to continue.';box.append(draft,el('p','Required support: 2 distinct Houses. Multiple endorsements from the same House count only once.'),el('p','No active counter rally — design preview only.'),demoSupport(true),disabled('Support this counter rally'));return box;
|
||
}
|
||
function revoltPreview(){
|
||
const box=card('Start revolt','Bring a call for revolt before the Landsraad.','seals/office-landsraad.png');
|
||
box.append(el('p','Design placeholder. Support requirements and consequences have not been defined; this action is not active.'),disabled('Start revolt'));return box;
|
||
}
|
||
function warPreview(){
|
||
const box=card('Declare war on House','A House declaration of war requires the support of the Emperor.','seals/emperor-v1.png');box.append(demoNote());
|
||
const grid=el('div',undefined,'politics-grid'),request=el('section',undefined,'politics-charter');request.append(el('h4','House declaration'));
|
||
for(const [title,value]of [['Declaring House','Demo House Amber'],['Target House','Demo House Jade'],['Reason','DEMO: A disputed border crossing and failed negotiations have brought these Houses before the Landsraad.']]){const label=el('label',title),field=el(title==='Reason'?'textarea':'input');field.value=value;field.disabled=true;label.append(field);request.append(label);}
|
||
request.append(el('p','Imperial support: awaiting the Emperor. This demo declaration cannot proceed.'),disabled('Request Imperial support'));
|
||
const concord=el('section',undefined,'politics-charter');concord.append(el('h4','The Veiled Concord · Suggest a declaration of war'),el('p','The Concord cannot declare war. It may suggest that another House declare war; a suggestion is neither a declaration nor Imperial approval.'));
|
||
for(const [title,value]of [['Suggested declaring House','Demo House Amber'],['Suggested target','Demo House Jade'],['Diplomatic recommendation','DEMO: Ask House Amber to consider a declaration against House Jade after reviewing the disputed crossing.']]){const label=el('label',title),field=el(title==='Diplomatic recommendation'?'textarea':'input');field.value=value;field.disabled=true;label.append(field);concord.append(label);}
|
||
concord.append(disabled('Send suggestion — preview only'));grid.append(request,concord);box.append(grid);return box;
|
||
}
|
||
for(const[id,[eyebrow,title,description,seal]]of Object.entries(specs)){
|
||
const section=el('section',undefined,'politics-page');section.id=id;section.hidden=true;
|
||
const hero=el('header',undefined,'cp-user-page-hero politics-hero');const image=el('img');image.src=asset(seal);image.alt='';image.width=112;image.height=112;const copy=el('div');copy.append(el('small',eyebrow),el('h2',title),el('p',description));hero.append(image,copy);
|
||
const tabs=el('nav',undefined,'cp-context-links');tabs.setAttribute('aria-label',title+' pages');const links=id.startsWith('imperial-')&&id!=='imperial-elections'?commandLinks:[];tabs.hidden=!links.length;for(const[label,page,art]of links){const a=artLink(label,page,art);if(page===id)a.setAttribute('aria-current','page');tabs.append(a);}
|
||
const preview=el('aside',undefined,'politics-preview-note');preview.append(el('strong','WEBSITE DESIGN PREVIEW'),el('span','Voting and rights grants are not active. These pages do not change the game.'));
|
||
const content=el('div',undefined,'politics-content');section.append(hero,tabs,...(id==='shared-inbox'?[]:[preview]),content);if(id==='shared-inbox')content.append(el('p','Loading your private inbox…'));dashboard?.append(section);nav?.append(artLink(title,id,seal));views[id]={section,content};
|
||
}
|
||
const factionSeals={atreides:['House Aerdrecht','house-aerdrecht-v1.png'],harkonnen:['House Harkveen','house-harkveen-v1.png'],corrino:['House Korenholt','house-korenholt-v1.png'],ordos:['House Oordwijk','house-oordwijk-v1.png'],fremen:['Vrijduin','house-vrijduin-v1.png'],veiled_concord:['The Veiled Concord','veiled-concord-v1.png']};
|
||
function renderFactionSeals(){
|
||
const faction=context?.linked?factionSeals[String(context.faction||'').toLowerCase()]:null;
|
||
for(const id of ['formal-council','house-elections']){
|
||
views[id].section.dataset.faction=faction?String(context.faction).toLowerCase():'';
|
||
const hero=views[id].section.querySelector('.politics-hero'),image=hero.querySelector('img');
|
||
image.src=asset(faction?'seals/'+faction[1]:specs[id][3]);image.alt=faction?faction[0]+' seal':'';
|
||
hero.querySelector('small').textContent=faction?faction[0].toUpperCase():specs[id][0];
|
||
}
|
||
}
|
||
function render(){
|
||
renderFactionSeals();
|
||
resetInboxViews();
|
||
for(const[id,v]of Object.entries(views)){v.section.hidden=!user?.permissions?.includes(id==='shared-inbox'?'web.mail.internal.view':'web.menu.game');if(!(id==='shared-inbox'&&v.section.dataset.internalMail==='true'))v.content.replaceChildren();}
|
||
views['council-motd'].content.append(renderProclamations());
|
||
const proclamationNote=views['council-motd'].section.querySelector('.politics-preview-note');if(proclamationNote)proclamationNote.textContent='PROCLAMATION ARCHIVE · Published messages from your House, the Emperor and the Spacing Guild.';
|
||
views['electoral-roll'].content.append(renderElectoralRoll());
|
||
const rollNote=views['electoral-roll'].section.querySelector('.politics-preview-note');if(rollNote)rollNote.textContent='PUBLIC PARTICIPATION · Username, election and number of votes. Choices are never disclosed.';
|
||
views.applications.content.append(renderApplications({user,context}));
|
||
const applicationNote=views.applications.section.querySelector(".politics-preview-note");if(applicationNote)applicationNote.textContent="APPLICATION REGISTER · Submissions are saved. Voting opens at the scheduled time; automatic office awards are still being connected.";
|
||
const landing=views.landsraad.content,grid=el('div',undefined,'politics-grid');
|
||
for(const[title,page,art,copy]of [['Faction Elections','house-elections','seals/office-house_leader.png','Enter your own House chamber. Only your verified in-game faction will appear.'],['Emperor Elections','imperial-elections','seals/emperor-v1.png','Follow the future Imperial ballot, candidates and results.']]){const box=card(title,copy,art);box.append(artLink('Open chamber',page,art));grid.append(box);}landing.append(grid,card('From nomination to result','The planned flow is nomination, voting, then a recorded result. Eligibility, terms and ballot rules will be defined before voting opens.'));
|
||
const house=views['house-elections'].content;
|
||
if(context?.faction){const name=context.faction[0].toUpperCase()+context.faction.slice(1);house.append(card(name+' · House chamber','Your faction was confirmed from your linked Minecraft account. The register below contains real candidatures for this chamber.','seals/office-house_leader.png'),renderVoting('house'));}
|
||
else{const title=context?.linked===false?'Link your Minecraft account':context?'House not confirmed':'Checking your linked House';const box=card(title,context?.linked===false?'Link your Minecraft identity to enter the chamber belonging to the faction you chose in game.':'Your House has not been confirmed. Other House elections remain hidden.','seals/office-house_leader.png');box.append(artLink('Minecraft account','game','nav-clan-v2.webp'));house.append(box);}
|
||
const council=views['formal-council'].content;{const treasury=card('House Treasury','Manage your authorised House and office accounts in Imperial Postbank.','imperial-postbank-v2.png');const link=el('a','Open Imperial Postbank');link.href='https://cp.dunerealms.com/#bank/bank-overview';link.target='_top';treasury.append(link);council.append(treasury);}council.append(councilPreview(),rallyPreview(),revoltPreview(),warPreview(),inboxPreview());if(views['shared-inbox'].section.dataset.internalMail!=='true')views['shared-inbox'].content.append(el('p','Loading your private inbox…'));
|
||
const councilLink=card('Faction Council','Appointments, rallies, war requests, your shared inbox and Imperial Postbank access.','seals/office-house_leader.png');councilLink.append(artLink('Enter the council','formal-council','seals/office-house_leader.png'));landing.append(councilLink);
|
||
const lore=card('The Veiled Concord · Caitain','In the quiet courts of Caitain, the Concord keeps the promises that crowns forget. Its scholars train in memory, diplomacy and patient observation. Three woven paths surround a guiding star upon their seal: knowledge, restraint and accord. Their elected Reverent Mother speaks with the standing of a House leader, while an appointed Concord Sister tends the treasury. They may counsel another House toward war, but never declare it themselves.','seals/veiled-concord-v1.png');lore.classList.add('politics-concord');landing.append(lore);
|
||
for(const key of ['house-elections','imperial-elections']){const note=views[key].section.querySelector('.politics-preview-note');if(note)note.textContent='ELECTION CHAMBER · Real candidates and definitive votes. Voting opens at the scheduled time.';}
|
||
const imperial=views['imperial-elections'].content;imperial.append(renderVoting('imperial'));
|
||
const command=views['imperial-command'].content;command.append(proclamationBox('imperial',{editor:true}));command.append(card(context?.emperor?'Imperial office confirmed':'Reserved for the Emperor',context?.emperor?'Your linked character currently holds the Imperial office. This remains a read-only design preview.':'Only the current Emperor will be able to grant water and spice rights. Viewing this preview does not grant that authority.','seals/emperor-v1.png'));const rights=el('div',undefined,'politics-grid');for(const[label,page,art,copy]of [['Water Rights','imperial-water','seals/water-rights-v1.png','Design the future register of water-rights grants.'],['Spice Rights','imperial-spice','seals/spice-rights-v1.png','Design the future register of spice-rights grants.']]){const box=card(label,copy,art);box.append(artLink('Open '+label.toLowerCase()+' chamber',page,art));rights.append(box);}command.append(rights);
|
||
for(const[id,resource]of [['imperial-water','water'],['imperial-spice','spice']]){views[id].content.append(renderCharters(resource));const note=views[id].section.querySelector('.politics-preview-note');if(note)note.textContent='IMPERIAL CHARTERS · Clan grants, recorded decrees and term-bound expiry.';}
|
||
command.append(counterRallyPreview());
|
||
}
|
||
async function load(){if(!user?.permissions?.includes('web.menu.game'))return;const n=++serial;try{const r=await fetch('/api/politics/preview',{cache:'no-store'}),d=await r.json();if(n!==serial)return;context=r.ok?d:{linked:true,faction:null,emperor:false};render();}catch{if(n===serial){context={linked:true,faction:null,emperor:false};render();}}}
|
||
function session(next){user=next;serial++;context=null;render();if(views[location.hash.slice(1)])load();}
|
||
window.addEventListener('dune:session',e=>session(e.detail));window.addEventListener('dune:page',e=>{if(views[e.detail?.page])load();});
|
||
fetch('/api/auth/session',{cache:'no-store'}).then(r=>r.ok?r.json():null).then(d=>{if(d)session(d.user);}).catch(()=>{});
|
||
|
||
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:'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');
|
||
const details=el('section',undefined,'politics-card applications-details');details.id='application-details';details.hidden=true;details.tabIndex=-1;
|
||
for(const row of records){const tr=el('tr');for(const value of [row.id,row.user,row.role,row.date,row.election,row.status,String(row.votes),row.result,'No'])tr.append(el('td',value));const seal=el('img');seal.src=asset(row.prefix==='IMP'?'seals/emperor-v1.png':row.prefix==='CON'?'seals/veiled-concord-v1.png':'seals/office-house_leader.png');seal.alt='';seal.width=seal.height=28;tr.children[2].prepend(seal);const cell=el('td'),button=el('button','Details');button.type='button';button.setAttribute('aria-controls',details.id);button.setAttribute('aria-label','View details for '+row.id);button.addEventListener('click',()=>{details.replaceChildren(el('h3',row.id+' · '+row.role),demoNote());const data=el('dl',undefined,'applications-detail-grid');for(const [label,value]of [['Applicant',row.user],['Application date',row.date],['Election ID',row.election],['Election status',row.status],['Votes received',String(row.votes)],['Result / rank awarded',row.result],['Three consecutive terms honour','No — no permanent honour awarded'],['Term length',row.term],['Regular election time',row.time],['Election dates','Not scheduled — preview only'],['Eligibility',row.prefix==='IMP'?'Everyone may apply; House leaders allocate five votes':'Verified members of the relevant faction'],['Electorate / turnout','Not available in this demo'],['Finalisation / audit','No real result has been finalised']])data.append(el('dt',label),el('dd',value));details.append(data,el('h4','Motivation'),el('p',row.motivation));details.hidden=false;details.focus();});cell.append(button);tr.append(cell);body.append(tr);}table.append(body);wrap.append(table);register.append(wrap);host.append(register,details);
|
||
const form=card('New application','Choose an election type and explain your motivation.','seals/office-house_leader.png');const fields=el('div',undefined,'politics-charter'),typeLabel=el('label','Application type'),select=el('select');for(const [prefix,title]of types){const option=el('option',prefix+' · '+title);option.value=prefix;select.append(option);}typeLabel.append(select);const motivationLabel=el('label','Motivation and plans'),text=el('textarea');text.rows=5;text.maxLength=5000;text.placeholder='Tell the electorate why you are standing and what you hope to achieve.';motivationLabel.append(text);const accept=el('label',undefined,'politics-accept'),check=el('input');check.type='checkbox';accept.append(check,el('span','Yes, I accept the responsibilities of this candidature.'));fields.append(typeLabel,motivationLabel,accept,disabled('Submit application — preview only'));form.append(fields,el('p','A permanent application number will be assigned only after a successful submission. No real application log is connected yet.'));host.append(form);return host;
|
||
}
|

Staff