Merge pull request 'Complete JARVIS office auctions, People, Rihla and shared Realm interfaces' (#404) from feature/jarvis-office-auctions-profiles-20261118 into main
This commit is contained in:
commit
e1a4a39121
123 changed files with 1361 additions and 460 deletions
11
docs/design/JARVIS-DEVELOPER-EASTER-EGG.md
Normal file
11
docs/design/JARVIS-DEVELOPER-EASTER-EGG.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Jarvis — developer keepsake and easter egg
|
||||
|
||||
Agreed 18 November 2026. Planned; not yet provisioned or deployed.
|
||||
|
||||
Jarvis is a fictional Ixian archive construct and an explicitly labelled AI development assistant credit. Its profile belongs in the discoverable People register, not Staff & Teams. Do not grant site staff/owner rights. The existing official_account rank grants owner authority and must not be used merely as an official badge. Repository access, if provisioned, is a separate scoped project identity.
|
||||
|
||||
## Developer discovery only
|
||||
|
||||
The profile contains a discreet hidden interaction for a personal J.A.R.V.I.S. reward code worth 10,000 DM. One claim per authenticated player, non-transferable, single redemption, enforced server-side through existing issuance and redemption mechanisms. No real code, minting, or balance change has been made yet.
|
||||
|
||||
Keep the discovery in developer notes only. Do not advertise it on the website, public changelog, news, Staff & Teams, Discord, or public help. No visible website hint explaining the reward or hunt. Let developers discover it naturally. Do not hide credentials or executable secrets in client source; reward issuance remains authorized and checked on the server.
|
||||
48
docs/design/POLITICAL-BACKEND-BATCH.md
Normal file
48
docs/design/POLITICAL-BACKEND-BATCH.md
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# Political backend batch — agreed additions, 18 November 2026
|
||||
|
||||
Not implemented by the election design PR403.
|
||||
|
||||
- A tied election immediately creates a three-hour office auction instead of a runoff. Resign Office, after confirmation, ends the incumbent appointment and triggers the same three-hour vacancy auction.
|
||||
- Central Starport Auctions category lists all auction types. Political Positions also includes political custom jobs and office auctions, referencing the same listing. Dedicated auction cards, frontend bidding and backend settlement belong together in the coding batch. Artwork example exists; preserve the established Starport layout.
|
||||
- Election winner or office auction winner receives the office deed, Polclan ownership and appropriate protected gameplay organisation ownership. Membership auctions grant membership only; the office owner assigns ranks and delegated roles. Gameplay affiliation supports clan/PvP or company/non-PvP; do not overwrite personal clan/company membership.
|
||||
- Separate deed-backed clan.membership, company.membership, office.membership and office.role relationships, each scoped to organisation, role, rights and term. No job.membership permission layer.
|
||||
- Polclan Job Listings: My Listings, Post a Job, Applications, reusing recruitment. Appointment automatically adds scoped Polclan membership; expiry/revocation removes only the corresponding entitlement.
|
||||
- Liaison targets: political House, Clan, Company, Bene Gesserit, Spacing Guild, Landsraad. Imperial Observer is appointment by decree, requiring no receiving-organisation approval. Observers do not gain management, voting or banking rights merely by appointment.
|
||||
- Shared portrait/network design for Clan, Company and Polclan. Clan: Dynasty & Council. Company: Board & Representatives. Politics: Office & Delegations, including liaisons, organisation seals and terms. Political connections denote appointment, not ancestry.
|
||||
- Below portraits, Clan and Company show an owner-positionable network organigram with the personal card and related clans, companies and offices. Placement is presentation only and must persist with authorised edits. Political office structure uses the same design but is automatically laid out from active deeds, not user-editable.
|
||||
- Owned, founded, purchased and conquered entities automatically join the same ownership network/alliance. Distinct accounts, members, debts and identities remain; alliance alone grants no bank or management rights. An office association lasts only for the active term and moves to the successor.
|
||||
- Existing deed/volmacht transfer is reused by successful rebellions; rebellion outcome remains a separate domain rule. No unconditional auction for every rebellion.
|
||||
- Network example: Unimatrix-Artreides, Unicorp and the current Emperor office, with only the office association leaving upon succession.
|
||||
|
||||
Unresolved execution rules must be resolved before enabling charges: auction bidder eligibility (including tied-candidate restrictions), minimum bid and increments, funds destination, no-bid result, equal bids and exact settlement rules. Do not silently invent these.
|
||||
|
||||
## Automatic global news integration
|
||||
|
||||
J.A.R.V.I.S. emits durable domain events after confirmed commits for the future global news system. Important election opening/deadline/results, office auction opening/closing/winner, office resignation/succession, public political/recruitment job offers and appointments are candidates. The news service owns visibility, severity, aggregation, channel policy and in-game server announcements. Do not create a second news subsystem or broadcast uncommitted actions. Reuse existing durable outbox patterns; event IDs and delivery deduplication prevent duplicate announcements on retries. Publish public-safe fields only, excluding private applications, account data, reward codes and credentials. Routine bidding, private denials and internal appointments do not automatically become global broadcasts. This integration is automatic once the future news consumer exists; no Minecraft plugin deployment is authorised by this note.
|
||||
|
||||
## Promotion controls — connect in coding batch
|
||||
|
||||
Replace the disabled Boards/Discord promotion controls with working opt-in delivery using existing forum/Discord publishers and jarvis_promotion_jobs. Basic starts with five shared promotion credits: one Board post costs one credit and one Discord post costs one; any mix is allowed, earned credits may supplement. Keyed/Royal have no Basic token cap; configured promotion fees still apply. Validate authority and balance on the server, reserve/spend atomically with the request, and show queued/delivered/failed delivery states. Retry must neither double-charge nor duplicate posts. Closing/filling a listing must update/close its associated forum entry through the existing lifecycle rules. Do not debit credits while channels are unavailable or leave a checkbox that claims delivery is active when its publisher is not configured.
|
||||
|
||||
## Confirmed auction rules
|
||||
|
||||
After a tied election only the tied highest-vote candidates may bid. Starting bid 100 DM (10,000 minor units); minimum increment 10 DM (1,000 minor units). Duration three hours. Winning payment goes to Tax. No bid uses the persisted eligible-candidate lottery described below. Resignation auctions are open to all eligible players, as separately confirmed.
|
||||
|
||||
## Promotion target
|
||||
|
||||
Discord Starport promotion channel confirmed by user: 1572558298467541084. Forum destination is fid=6, confirmed below. Webhook credentials must remain in private server configuration, never committed or placed in browser assets.
|
||||
|
||||
## Updated succession decision
|
||||
|
||||
No-bid office auction uses a one-time persisted lottery among eligible candidates instead of leaving the office vacant. After resignation the new auction is open to all eligible players, not only prior candidates (confirmed). Resignation remains publicly visible in office history and linked from later candidate cards.
|
||||
Forum Starport promotion destination confirmed: https://forums.dunerealms.com/forumdisplay.php?fid=6 (forum ID 6).
|
||||
|
||||
## Publication identity
|
||||
|
||||
The user renamed the proposed Archive IX project keepsake identity to Jarvis. Starport promotion forum posts must be authored by Jarvis, not by the listing owner's personal forum account. Jarvis remains discoverable in People, excluded from Staff & Teams, and without site staff permissions. Scoped DuneGit repository permissions are a separate explicit grant. The site, forum and DuneGit identities have not yet been provisioned; do not claim they exist. The existing official_account role grants owner authority and must not be assigned merely for recognition.
|
||||
|
||||
## Coding batch scope and remaining connections
|
||||
|
||||
This batch connects three-hour office auctions, immediate bank holds and Tax settlement, durable office-transfer commands, resignation/succession, Starport auction cards and bidding, read-only J.A.R.V.I.S. management registers, scoped political appointment deeds, public organisation portraits/networks, and personal net-worth snapshots. Election application and ballot tabs reuse existing services; campaign booking remains explicitly a preview.
|
||||
|
||||
Still to connect: paid hourly campaign reservations, promotion delivery workers/private channel configuration and Jarvis forum provisioning, political vacancy publication/application acceptance into the appointment service, and complete result/history navigation. The hidden reward and development account provisioning remain proposals; the identity helper is not invoked automatically. No global news broadcasts or game deployment are introduced. Do not label these remaining actions as operational.
|
||||
|
|
@ -4,4 +4,4 @@ export function companyCPDocument(source){return clanCPDocument(source)
|
|||
.replace('data-cp-mode="clan" class="clan-cp-shell"','data-cp-mode="company" class="clan-cp-shell company-cp-shell"')
|
||||
.replace(/<script src="\/v2\/v2\.js(?:\?[^\"]*)?" defer><\/script>/,'<script type="module" src="/v2/cp-v2-company-shell.mjs"></script>')
|
||||
.replace('<script type="module" src="/v2/cp-v2-clan-size.mjs"></script>','')
|
||||
.replace('</head>','<link rel="stylesheet" href="/v2/cp-v2-organisation-shell.css"></head>');}
|
||||
.replace('</head>','<link rel="stylesheet" href="/v2/cp-v2-company-shell.css"><link rel="stylesheet" href="/v2/cp-v2-organisation-shell.css"></head>');}
|
||||
|
|
|
|||
|
|
@ -58,12 +58,12 @@ export function applicationProgress(application, rounds, term, honour, now=Date.
|
|||
const history=rounds.map(r=>({number:Number(r.round_number)+1,status:r.status,
|
||||
opensAt:Number(r.opens_at),closesAt:Number(r.closes_at),eligible:!!Number(r.eligible),votes:Number(r.votes||0)}));
|
||||
const latest=rounds.at(-1),final=latest&&['winner','no_votes'].includes(latest.status);
|
||||
const won=final&&latest.status==='winner'&&latest.winner_id===application.id;
|
||||
return {state:final?'closed':'open',phase:final?'Final result':latest?(now<Number(latest.closes_at)?'Voting open':'Finalising round'):(now<Number(application.election_start)?'Applications open':'Awaiting round'),
|
||||
const auction=latest?.status==='auction_required',appointed=term?.application_id===application.id;const won=final&&latest.status==='winner'&&latest.winner_id===application.id;const decided=final||auction&&!!term;
|
||||
return {state:decided?'closed':'open',phase:auction?(term?'Office auction concluded':'Office auction'):final?'Final result':latest?(now<Number(latest.closes_at)?'Voting open':'Finalising round'):(now<Number(application.election_start)?'Applications open':'Awaiting round'),
|
||||
votes:history.filter(r=>r.eligible).at(-1)?.votes??0,
|
||||
result:final?(latest.status==='no_votes'?'No votes cast':won?'Elected':'Not elected'):'Pending',
|
||||
officeRecorded:!!(won&&term?.application_id===application.id),
|
||||
term:won&&term?.application_id===application.id?{startsAt:Number(term.starts_at),expiresAt:Number(term.expires_at),streak:Number(term.streak)}:null,
|
||||
result:auction?(term?(appointed?(term.outcome==='resigned'?'Appointed · voluntarily resigned':'Appointed after office auction'):'Not appointed'):'Office auction pending'):final?(latest.status==='no_votes'?'No votes cast':won?'Elected':'Not elected'):'Pending',
|
||||
officeRecorded:!!((won||auction)&&appointed),
|
||||
term:(won||auction)&&appointed?{startsAt:Number(term.starts_at),expiresAt:Number(term.expires_at),streak:Number(term.streak)}:null,
|
||||
honour:honour?{title:honour.title,earnedAt:Number(honour.earned_at)}:null,rounds:history};
|
||||
}
|
||||
export async function ownApplications(db,userId){
|
||||
|
|
@ -74,7 +74,7 @@ export async function ownApplications(db,userId){
|
|||
const rounds=(await db.prepare(`SELECT r.*, EXISTS(SELECT 1 FROM political_round_candidates c WHERE c.round_id=r.id AND c.application_id=?) AS eligible,
|
||||
COALESCE((SELECT SUM(a.votes) FROM political_ballot_allocations a JOIN political_ballots b ON b.id=a.ballot_id WHERE b.round_id=r.id AND a.application_id=?),0) AS votes
|
||||
FROM political_election_rounds r WHERE r.kind=? AND r.faction=? AND r.election_start=? ORDER BY r.round_number`).bind(row.id,row.id,row.kind,row.faction,row.election_start).all()).results;
|
||||
const term=await db.prepare('SELECT application_id,starts_at,expires_at,streak FROM political_office_terms WHERE kind=? AND faction=? AND election_start=?').bind(row.kind,row.faction,row.election_start).first();
|
||||
const term=await db.prepare('SELECT application_id,starts_at,expires_at,streak,outcome FROM political_office_terms WHERE kind=? AND faction=? AND election_start=? ORDER BY starts_at DESC,id DESC LIMIT 1').bind(row.kind,row.faction,row.election_start).first();
|
||||
const honour=await db.prepare('SELECT title,earned_at FROM political_election_honours WHERE player_uuid=? AND kind=? AND faction=?').bind(row.player_uuid,row.kind,row.faction).first();
|
||||
const {id,player_uuid,...publicRow}=row;
|
||||
output.push({...publicRow,progress:applicationProgress(row,rounds,term,honour)});
|
||||
|
|
|
|||
|
|
@ -59,17 +59,17 @@ export async function castBallot(db,{actor,context,input,now=Date.now(),clock=Da
|
|||
return{id,created:true,remaining:Number(voter.capacity)-Number(voter.spent)-vote.total};
|
||||
}}]);return result;
|
||||
}
|
||||
// A tie is never broken by UUID/name/order. A runoff must be held instead.
|
||||
// A tied ballot delegates succession to a three-hour office auction.
|
||||
export function electionOutcome(candidates){
|
||||
const rows=candidates.filter(c=>Number.isSafeInteger(c.votes)&&c.votes>0);
|
||||
if(!rows.length)return{status:'no_votes',winner:null,runoff:[]};
|
||||
const high=Math.max(...rows.map(c=>c.votes)),leaders=rows.filter(c=>c.votes===high).map(c=>c.id).sort();
|
||||
return leaders.length===1?{status:'winner',winner:leaders[0],runoff:[]}:{status:'runoff_required',winner:null,runoff:leaders};
|
||||
return leaders.length===1?{status:'winner',winner:leaders[0],runoff:[]}:{status:'auction_required',winner:null,runoff:leaders};
|
||||
}
|
||||
export function planRoundResult({kind,start,round=0,candidates},now=Date.now()){
|
||||
if(!Number.isSafeInteger(round)||round<0||round>1000)throw Error('Invalid election round');
|
||||
const base=electionWindow(kind,start,now),opens=Date.parse(base.votingOpens)+round*10800000,closes=opens+10800000;
|
||||
if(now<closes)throw Error('Voting round has not closed');
|
||||
const result=electionOutcome(candidates);
|
||||
return {...result,round,opensAt:opens,closesAt:closes,nextRound:result.status==='runoff_required'?{round:round+1,opensAt:closes,closesAt:closes+10800000,candidateIds:result.runoff}:null};
|
||||
return {...result,round,opensAt:opens,closesAt:closes,nextRound:null,auction:result.status==='auction_required'?{durationMs:10800000,candidateIds:result.runoff}:null};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import {randomUUID} from 'node:crypto';
|
|||
import {electionWindow} from './public/election-rules.mjs';
|
||||
import {planRoundResult} from './election-ballots.mjs';
|
||||
export const roundSchema=[
|
||||
`CREATE TABLE IF NOT EXISTS political_auction_triggers(round_id CHAR(36) PRIMARY KEY,kind VARCHAR(16) NOT NULL,faction VARCHAR(32) NOT NULL,election_start BIGINT NOT NULL,application_ids TEXT NOT NULL,candidate_ids TEXT NOT NULL,opens_at BIGINT NOT NULL,state VARCHAR(16) NOT NULL,auction_id CHAR(36) NULL,created_at BIGINT NOT NULL) ENGINE=InnoDB`,
|
||||
`CREATE TABLE IF NOT EXISTS political_election_rounds(id CHAR(36) PRIMARY KEY,kind VARCHAR(16) NOT NULL,faction VARCHAR(32) NOT NULL,election_start BIGINT NOT NULL,round_number INTEGER NOT NULL,opens_at BIGINT NOT NULL,closes_at BIGINT NOT NULL,status VARCHAR(32) NOT NULL,winner_id CHAR(36),UNIQUE KEY election_round(kind,faction,election_start,round_number)) ENGINE=InnoDB`,
|
||||
`CREATE TABLE IF NOT EXISTS political_round_candidates(round_id CHAR(36) NOT NULL,application_id CHAR(36) NOT NULL,PRIMARY KEY(round_id,application_id)) ENGINE=InnoDB`,
|
||||
`CREATE TABLE IF NOT EXISTS political_round_events(id CHAR(36) PRIMARY KEY,round_id CHAR(36) NOT NULL,event VARCHAR(32) NOT NULL,payload TEXT NOT NULL,created_at BIGINT NOT NULL,UNIQUE KEY round_event(round_id,event)) ENGINE=InnoDB`
|
||||
|
|
@ -34,6 +35,15 @@ export async function finalizeRound(db,{roundId,now=Date.now(),makeId=randomUUID
|
|||
const totals=await query('SELECT c.application_id AS id,COALESCE(SUM(a.votes),0) AS votes FROM political_round_candidates c LEFT JOIN political_ballots b ON b.round_id=c.round_id LEFT JOIN political_ballot_allocations a ON a.ballot_id=b.id AND a.application_id=c.application_id WHERE c.round_id=? GROUP BY c.application_id',[round.id]);
|
||||
const outcome=planRoundResult({kind:round.kind,start:new Date(Number(round.election_start)).toISOString(),round:Number(round.round_number),candidates:totals.map(row=>({...row,votes:Number(row.votes)}))},now);
|
||||
let nextRoundId=null;
|
||||
if(outcome.auction){
|
||||
const candidates=[];
|
||||
for(const applicationId of outcome.auction.candidateIds){
|
||||
const [candidate]=await query("SELECT user_id FROM political_applications WHERE id=? AND kind=? AND faction=? AND election_start=? AND status='submitted' FOR UPDATE",[applicationId,round.kind,round.faction,round.election_start]);
|
||||
if(!candidate||candidates.includes(candidate.user_id))throw Error('Tied candidate identity requires review');
|
||||
candidates.push(candidate.user_id);
|
||||
}
|
||||
await query("INSERT INTO political_auction_triggers(round_id,kind,faction,election_start,application_ids,candidate_ids,opens_at,state,created_at) VALUES(?,?,?,?,?,?,?,'queued',?)",[round.id,round.kind,round.faction,round.election_start,JSON.stringify(outcome.auction.candidateIds),JSON.stringify(candidates),now,now]);
|
||||
}
|
||||
if(outcome.nextRound){
|
||||
nextRoundId=makeId();const next=outcome.nextRound;
|
||||
await query('INSERT INTO political_election_rounds(id,kind,faction,election_start,round_number,opens_at,closes_at,status) VALUES(?,?,?,?,?,?,?,?)',[nextRoundId,round.kind,round.faction,round.election_start,next.round,next.opensAt,next.closesAt,'open']);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export async function advanceElection(db,kind,faction,now=Date.now()){
|
|||
}
|
||||
export function startElectionClock(db,{clock=Date.now,onError=()=>console.error('Election clock failed')}={}){
|
||||
let busy=false,stopped=false;
|
||||
const tick=async()=>{if(busy||stopped)return;busy=true;try{const now=clock();for(const faction of houses.filter(f=>f!=='fremen'))await advanceElection(db,'house',faction,now);for(const kind of ['imperial','bene','guild','clan_delegate'])await advanceElection(db,kind,electionScope(kind),now);}catch(error){onError(error);}finally{busy=false;}};
|
||||
const tick=async()=>{if(busy||stopped)return;busy=true;try{const now=clock();for(const faction of houses)await advanceElection(db,'house',faction,now);for(const kind of ['imperial','bene','guild','clan_delegate'])await advanceElection(db,kind,electionScope(kind),now);}catch(error){onError(error);}finally{busy=false;}};
|
||||
const timer=setInterval(tick,15000);timer.unref?.();void tick();return()=>{stopped=true;clearInterval(timer);};
|
||||
}
|
||||
export function createElectionVoting(db,settings={},deps={}){
|
||||
|
|
@ -39,7 +39,7 @@ export function createElectionVoting(db,settings={},deps={}){
|
|||
const response=await preview(new Request(origin+'/api/politics/preview',{headers:request.headers}));if(!response.ok)return reply({message:'Faction verification unavailable.'},503);
|
||||
const verified=await response.json(),current=await auth(request);
|
||||
if(!current||current.id!==user.id||!await permitted(current)||(await linked(current))?.toLowerCase()!==player.toLowerCase())return reply({message:'Account access changed. Refresh.'},403);
|
||||
if(!verified.linked||(['house','imperial'].includes(kind)&&(verified.factionStatus!=='verified'||!houses.includes(verified.faction)||kind==='house'&&verified.faction==='fremen')))return reply({message:'Verified faction membership required.'},403);
|
||||
if(!verified.linked||(['house','imperial'].includes(kind)&&(verified.factionStatus!=='verified'||!houses.includes(verified.faction))))return reply({message:'Verified faction membership required.'},403);
|
||||
if(kind==='imperial'&&verified.officeStatus!=='verified')return reply({message:'Current office could not be verified. No votes have been spent.'},503);
|
||||
const clan=kind==='clan_delegate'?await db.prepare("SELECT c.id,m.clan_role,c.owner_id FROM site_clans c JOIN site_clan_members m ON m.clan_id=c.id JOIN site_game_links l ON l.user_id=m.user_id AND l.minecraft_uuid=m.minecraft_uuid WHERE m.user_id=? AND c.active=1").bind(current.id).first():null;
|
||||
const context={clanId:clan?.id,clanLeader:clan?.owner_id===current.id&&clan?.clan_role==='owner',linked:true,playerUuid:player,faction:verified.faction,houseLeader:verified.houseLeader===true},faction=electionScope(kind,context),now=clock(),start=cycleStart(kind,now);
|
||||
|
|
|
|||
2
website/control-panel/jarvis-auction-shell.mjs
Normal file
2
website/control-panel/jarvis-auction-shell.mjs
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import {jarvisApplicationDocument} from './jarvis-application-shell.mjs';
|
||||
export const jarvisAuctionDocument=source=>jarvisApplicationDocument(source).replace('DuneRealms · Recruitment Application','DuneRealms · Starport Auction').replace('/v2/cp-v2-jarvis-application.mjs','/v2/cp-v2-jarvis-auction.mjs');
|
||||
|
|
@ -4,4 +4,4 @@ export function politicsCPDocument(source){return clanCPDocument(source)
|
|||
.replace('data-cp-mode="clan" class="clan-cp-shell"','data-cp-mode="politics" class="clan-cp-shell politics-cp-shell"')
|
||||
.replace(/<script src="\/v2\/v2\.js(?:\?[^\"]*)?" defer><\/script>/,'<script type="module" src="/v2/cp-v2-politics-shell.mjs"></script>')
|
||||
.replace('<script type="module" src="/v2/cp-v2-clan-size.mjs"></script>','')
|
||||
.replace('</head>','<link rel="stylesheet" href="/v2/cp-v2-organisation-shell.css"></head>');}
|
||||
.replace('</head>','<link rel="stylesheet" href="/v2/cp-v2-politics-shell.css"><link rel="stylesheet" href="/v2/cp-v2-organisation-shell.css"></head>');}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import {formatDuneDate} from './dune-date.mjs';
|
||||
const el=(tag,text,cls)=>{const n=document.createElement(tag);if(text!==undefined)n.textContent=text;if(cls)n.className=cls;return n;};
|
||||
export const clanPublicUrl=(clan,kind='clan')=>'https://www.dunerealms.com/'+({clan:'clans',company:'companies',politics:'political-houses'}[kind]||'clans')+'/'+encodeURIComponent(clan.tag);
|
||||
export const isRoyalHouse=clan=>clan.charter_kind==='royal';
|
||||
export const isRoyalHouse=clan=>(clan.charter_kind||clan.charterKind)==='royal';
|
||||
const status=clan=>clan.institution_key?'Protected institution':isRoyalHouse(clan)?'Royal House':clan.charter_kind==='original'?'Keyed clan':'Basic clan';
|
||||
function view(clan,kind='clan'){const a=el('a','View '+(kind==='company'?'company':kind==='politics'?'House':'clan')+' →','clan-register-view');a.href=clanPublicUrl(clan,kind);a.target='_top';a.setAttribute('aria-label','View '+clan.name+' public profile');return a;}
|
||||
function logo(clan,size){const img=el('img');img.src=clan.emblem;img.alt='';img.width=img.height=size;img.loading='lazy';return img;}
|
||||
export function renderClanRegister(host,rows,{kind='clan'}={}){const noun=kind==='company'?'Company':kind==='politics'?'Political House':'Clan';
|
||||
host.replaceChildren();const royal=el('section',undefined,'clan-royal-directory'),grid=el('div',undefined,'clan-grid');royal.append(el('h3',kind==='politics'?'Protected Political Houses':'Royal Houses'));const houses=rows.filter(r=>kind==='politics'||isRoyalHouse(r));
|
||||
host.replaceChildren();const royal=el('section',undefined,'clan-royal-directory'),grid=el('div',undefined,'clan-grid');royal.append(el('h3',kind==='politics'?'Protected Political Houses':kind==='company'?'Royal Companies':'Royal Houses'));const houses=rows.filter(r=>kind==='politics'||isRoyalHouse(r));
|
||||
for(const clan of houses){const card=el('article',undefined,'clan-card clan-recruit-card'),portrait=el('div',undefined,'clan-directory-portrait'),crest=logo(clan,160);crest.className='clan-directory-crest';portrait.append(crest,el('span',kind==='politics'?'PROTECTED HOUSE':'ROYAL HOUSE'));const body=el('div',undefined,'clan-directory-body'),tag=el('small','['+clan.tag+']','clan-directory-tag'),footer=el('div',undefined,'clan-directory-footer');footer.append(el('span',Number(clan.member_count)+' members'),view(clan,kind));body.append(tag,el('h3',clan.name),el('p',clan.realm||'Independent House'),el('p',clan.description||'This House has not published an introduction yet.','clan-directory-bio'),footer);card.append(portrait,body);grid.append(card);}if(!houses.length)grid.append(el('p','No Royal Houses match the current filters.','clan-register-empty'));royal.append(grid);if(kind!=='company')host.append(royal);
|
||||
const register=el('section',undefined,'clan-public-register');register.append(el('h3',noun+' Registry'),el('p','Registered organisations · public identity, leadership and membership.'));const wrap=el('div',undefined,'clan-register-scroll'),table=el('table'),head=el('thead'),tr=el('tr');for(const name of [noun,kind==='company'?'Chief Executive':kind==='politics'?'Officeholder':'Owner','Members','Status',kind==='clan'?'Homeworld':'Affiliation',kind==='politics'?'Term begins':'Established','View '+noun.toLowerCase()]){const th=el('th',name);th.scope='col';tr.append(th);}head.append(tr);const body=el('tbody');
|
||||
for(const clan of rows){const row=el('tr'),identity=el('td'),name=el('div',undefined,'clan-register-identity'),copy=el('div'),link=el('a',clan.name);link.href=clanPublicUrl(clan,kind);link.target='_top';copy.append(link,el('small','['+clan.tag+']'));name.append(logo(clan,36),copy);identity.append(name);const owner=el('td');if(clan.owner_username){const a=el('a',clan.owner_name||clan.owner_username);a.href='https://www.dunerealms.com/people/'+encodeURIComponent(clan.owner_username);a.target='_top';owner.append(a);}else owner.append(el('span','Not listed'));const action=el('td');action.append(view(clan,kind));row.append(identity,owner,el('td',clan.member_count==null?'Not published':String(Number(clan.member_count)||0)),el('td',kind==='clan'?status(clan):(clan.standing||'Protected House')),el('td',clan.homeworldName||clan.realm||'Not selected'),el('td',(clan.created_at||clan.term?.startsAt)?formatDuneDate(Number(clan.created_at||clan.term.startsAt)):'—'),action);body.append(row);}if(!rows.length){const row=el('tr'),cell=el('td','No organisations match the current filters.');cell.colSpan=7;row.append(cell);body.append(row);}table.append(head,body);wrap.append(table);register.append(wrap);host.append(register);
|
||||
|
|
|
|||
|
|
@ -18,3 +18,5 @@
|
|||
.dynasty-example{border-style:dashed;box-shadow:inset 0 0 26px #d7b66110}.dynasty-example>strong{font:600 clamp(15px,1.6vw,20px) 'Cinzel','Palatino Linotype',serif;line-height:1.6;color:#d9c38d;overflow-wrap:break-word}.dynasty-example>small{font-size:10px;line-height:1.6;letter-spacing:.04em;color:#b6c5b8}.dynasty-example .dynasty-portrait img{object-fit:contain;image-rendering:auto}
|
||||
.dynasty-example .dynasty-portrait{overflow:visible}.dynasty-example .dynasty-portrait img{object-fit:cover;width:100%;height:100%;border-radius:inherit;object-position:center 30%}
|
||||
.dynasty-example-voxel{display:block;width:100%;height:100%;border-radius:inherit;background-size:300% 300%;background-repeat:no-repeat;image-rendering:auto}
|
||||
|
||||
.organisation-network-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:34px 24px;position:relative;align-items:start}.organisation-network-grid>.dynasty-player{z-index:1}.organisation-network-lines{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;overflow:visible}.organisation-network-lines path{stroke:#c3a35e;stroke-width:2;fill:none}.network-position-controls{display:flex;gap:6px}.organisation-network button{background:#173b2f;color:#eed598;border:1px solid #a68a4e;border-radius:6px;padding:9px 13px;cursor:pointer}.organisation-network>div:last-of-type{margin-top:22px}@media(max-width:650px){.organisation-network-grid{grid-template-columns:1fr}.organisation-network-grid>.dynasty-player{grid-column:1!important;grid-row:auto!important}.organisation-network-lines{display:none}}
|
||||
|
|
|
|||
|
|
@ -23,3 +23,16 @@ export function createDeedCard({clan,deed,titles,established}){
|
|||
styles();const root=el('section',undefined,'clan-deed-card');root.id='ownership-deed';const art=el('div',undefined,'clan-deed-picture');art.setAttribute('role','img');art.setAttribute('aria-label',deed.kind==='royal'?'Royal House deed':deed.kind==='original'?'Keyed House deed':'Basic clan deed');art.style.backgroundImage='url(https://cp.dunerealms.com/assets/organisation-deeds-clan-tiers-v1.png)';art.style.backgroundSize='300% 100%';art.style.backgroundPosition=deed.kind==='royal'?'right center':deed.kind==='original'?'center':'left center';art.style.backgroundRepeat='no-repeat';const content=el('div');content.append(el('small','IMPERIAL REGISTER · OWNERSHIP DEED'),el('h2',clan.name),el('p',deed.kind==='royal'?'Royal House':deed.kind==='original'?'Keyed House':'Basic Clan'),el('p','Est. '+established));
|
||||
const fields=el('dl',undefined,'clan-deed-officers');for(const [label,value]of [['Ruler',dynasticAddress(deed.ruler,clan,titles,'ruler')],['Consort',dynasticAddress(deed.consort,clan,titles,'consort')],['Heir',dynasticAddress(deed.heir,clan,titles,'heir')]])fields.append(el('dt',label),el('dd',value||'Not appointed'));content.append(fields,el('small','Registered deed · revision '+deed.version));root.append(art,content);return root;
|
||||
}
|
||||
|
||||
export function createOrganisationPortraitTree(organisation,{kind='company'}={}){
|
||||
styles();const politics=kind==='politics',root=el('section',undefined,'clan-dynasty organisation-portrait-tree'),heading=el('header'),shield=el('div',undefined,'dynasty-heraldic-shield'),crest=el('img');crest.src=organisation.emblem;crest.alt=organisation.name+' emblem';shield.append(crest);heading.append(shield,el('small',politics?'OFFICE & DELEGATIONS':'BOARD & REPRESENTATIVES'),el('h2',organisation.name));root.append(heading);
|
||||
const groups=[{title:politics?'Office holder':'Company leadership',rows:[]},{title:politics?'Office council':'Board & representatives',rows:[]},{title:'Liaisons & observers',rows:[]}];
|
||||
for(const member of organisation.members||[]){const owner=member.role==='officeholder'||member.username===organisation.owner_username,observer=member.role==='observer'||String(member.appointmentType||'').includes('liaison');groups[owner?0:observer?2:1].rows.push(member);}
|
||||
for(const [index,group]of groups.entries()){
|
||||
if(index===2&&!politics&&!group.rows.length)continue;
|
||||
const section=el('section',undefined,'dynasty-interior '+(index===0?'dynasty-family':'dynasty-council')),grid=el('div',undefined,'dynasty-council-grid');section.append(el('h3',group.title));
|
||||
if(!group.rows.length)grid.append(el('p',index===0?'Position vacant.':'No current appointments.'));
|
||||
for(const member of group.rows){const card=el('article',undefined,'dynasty-player'),portrait=el('div',undefined,'dynasty-portrait'),face=el('img'),link=el('a',member.name||member.username);face.src='https://cp.dunerealms.com/api/avatars/face/roster/'+encodeURIComponent(member.username);face.alt=member.username+' Minecraft portrait';face.width=face.height=96;face.loading='lazy';portrait.append(face);link.href='https://www.dunerealms.com/people/'+encodeURIComponent(member.username);card.append(el('small',member.title||member.role||'Member'),portrait,link,el('small','@'+member.username));if(member.expiresAt)card.append(el('small','Term ends '+new Date(member.expiresAt).toLocaleDateString('en-GB')));grid.append(card);}section.append(grid);root.append(section);
|
||||
}
|
||||
root.dataset.structure=politics?'office-deeds':'company-board';return root;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,38 +1,39 @@
|
|||
import {showInvalidKey} from './cp-v2-key-validation.mjs';
|
||||
import {parseOrganisationCode} from '../codex-code-format.mjs';
|
||||
import {createDeedArtwork} from './cp-v2-deed-art.mjs';
|
||||
import {element as el} from './cp-v2-page-template.mjs';
|
||||
|
||||
// Presentation only. Recognising a format never verifies ownership or grants a right.
|
||||
export function describeRedemption(value){
|
||||
const entered=String(value||'').trim().toUpperCase();let code=entered,edition=null;try{const parsed=parseOrganisationCode(entered);code=parsed.canonical;edition=parsed.edition;}catch{}
|
||||
import {element as el} from './cp-v2-page-template.mjs';
|
||||
|
||||
// Presentation only. Recognising a format never verifies ownership or grants a right.
|
||||
export function describeRedemption(value){
|
||||
const entered=String(value||'').trim().toUpperCase();let code=entered,edition=null;try{const parsed=parseOrganisationCode(entered);code=parsed.canonical;edition=parsed.edition;}catch{}
|
||||
const types=[
|
||||
[/^POL-CLAN-[A-F0-9]{48}$/,'politics-clan','Political clan membership','Bound to the current office deed, not a political decision or Royal appointment.','Open Politics CP',false,'https://www.dunerealms.com/government.html'],
|
||||
[/^(?:CLAN-SUB|COM-SUB)-[A-F0-9]{48}$/,'subhouse','Subordinate organisation founding','This key is bound to its mother deed. It cannot create an independent or Royal charter.','Subhouse creation adapter pending',false],
|
||||
[/^DRK-[A-Z2-7]{32}$/,'kit','Kit delivery','Requests your kit delivery. The game confirms arrival.','Redeem kit',true],
|
||||
[/^DRQ-[A-F0-9]{40}$/,'discovery','Discovery reward','Claims your earned discovery reward. The service checks eligibility before crediting.','Claim reward',true],
|
||||
[/^(?:DRU|UP)-[A-F0-9]{48}$/,'token','Upgrade Token','Apply this token to a saved kit in Imperial Tailor.','Open Imperial Tailor',false,'#realm/kits-exchange'],
|
||||
[/^CLAN-[A-F0-9]{48}$/,'clan','Clan founding right','Upgrades your existing Basic clan to an Original House that can become a mother house. A Royal House requires a separate political appointment.','Upgrade my Basic clan',true],
|
||||
[/^COM-[A-F0-9]{48}$/,'company','Company founding right','Upgrades your existing Basic company using its separate original founding right.','Open Company settings',false,'https://corp.dunerealms.com/#company/settings'],
|
||||
[/^POL-[A-F0-9]{48}$/,'politics','Political appointment','Applies the specific appointment recorded by a political decision. The decision determines the organisation and title.','Political appointments coming soon',false]
|
||||
];
|
||||
for(const [pattern,kind,title,description,action,available,href] of types)if(pattern.test(code))return {code:entered,edition,kind,title,description,action,available,href};
|
||||
throw Error('Enter a complete private code. Community commands are used in game.');
|
||||
}
|
||||
|
||||
export function createCodeRedemption(){
|
||||
let reviewed=null,locked=false;
|
||||
const root=el('section',undefined,'code-redemption'),hero=el('header',undefined,'reward-code-banner'),art=el('img');art.src='https://www.dunerealms.com/assets/imperial-seal-128.png';art.alt='';const heading=el('div');heading.append(el('small','SPOST · IMPERIAL CODE OFFICE'),el('h4','Present your code. Open your next chapter.'),el('p','Your SPost counter for rewards, founding rights and political appointments.'));hero.append(art,heading);
|
||||
const layout=el('div',undefined,'code-redemption-layout'),form=el('form',undefined,'code-redemption-card'),entry=el('fieldset'),legend=el('legend','1 · Enter your private code'),label=el('label','Code'),input=el('input');input.type='text';input.autocomplete='off';input.spellcheck=false;input.autocapitalize='characters';input.required=true;input.maxLength=128;input.placeholder='Paste your complete code';input.setAttribute('aria-describedby','redemption-code-help');const help=el('p','Keep your code private. Checking its format does not use it.','code-redemption-muted');help.id='redemption-code-help';label.append(input);const inspect=el('button','Review code');inspect.type='button';entry.append(legend,label,help,inspect);
|
||||
const preview=el('fieldset',undefined,'code-redemption-preview');preview.hidden=true;preview.append(el('legend','2 · Review & confirm'));const badge=el('span',undefined,'reward-kind'),title=el('h5'),effect=el('p'),verification=el('p','Format recognised. Ownership and eligibility are checked when you submit.','code-redemption-muted'),check=el('input');check.type='checkbox';const consent=el('label',undefined,'code-redemption-consent');consent.append(check,el('span','I understand this action and want to use my code.'));const submit=el('button','Confirm redemption');submit.type='submit';submit.disabled=true;const destination=el('a');destination.hidden=true;preview.append(badge,title,effect,verification,consent,submit,destination);const result=el('p',undefined,'code-redemption-result');result.setAttribute('role','status');result.setAttribute('aria-live','polite');form.append(entry,preview,result);
|
||||
const guide=el('aside',undefined,'code-redemption-card code-redemption-guide');guide.append(el('small','WHAT CAN YOU PRESENT?'),el('h5','Your code chooses the route.'));
|
||||
for(const [kind,name,copy] of [['kit','Kits & discoveries','Existing DRK and DRQ codes can be redeemed here.'],['clan','House & company charters','Create your Basic clan first. CLAN upgrades your Basic clan to an Original House. Keep your separate COM code for Company CP.'],['politics','Political appointments','POL codes come from an approved decision. Founding alone does not confer a Royal title.'],['token','Upgrade Tokens','DRU tokens are applied to a saved kit in Imperial Tailor.']]){const card=el('div',undefined,'code-redemption-guide-item');card.append(el('span',name,'reward-kind reward-kind-'+kind),el('p',copy));guide.append(card);}const register=el('a','← View your codes');register.href='#';register.onclick=e=>{e.preventDefault();root.dispatchEvent(new CustomEvent('show-code-register',{bubbles:true}));};guide.append(createDeedArtwork('keys'),register);layout.append(form,guide);root.append(hero,layout);
|
||||
function sync(){submit.disabled=locked||!reviewed?.available||!check.checked;inspect.disabled=locked;input.disabled=locked;check.disabled=locked;}
|
||||
function invalidate(){reviewed=null;check.checked=false;preview.hidden=true;result.textContent='';sync();}
|
||||
input.oninput=invalidate;check.onchange=sync;
|
||||
inspect.onclick=()=>{if(locked)return;try{reviewed=describeRedemption(input.value);check.checked=false;badge.className='reward-kind reward-kind-'+reviewed.kind;badge.textContent=reviewed.available?'Ready to submit':'Dedicated route';title.textContent=reviewed.title;effect.textContent=reviewed.description;submit.textContent=reviewed.action;submit.hidden=!reviewed.available;consent.hidden=!reviewed.available;destination.hidden=!reviewed.href;if(reviewed.href){destination.href=reviewed.href;destination.textContent=reviewed.action;}verification.textContent=reviewed.available?'Format recognised. Ownership and eligibility are checked when you submit.':reviewed.href?'Continue in the dedicated workshop to choose your kit.':'This route is being connected. Your code has not been used.';preview.hidden=false;result.textContent='';sync();}catch(error){invalidate();result.textContent=error.message;input.focus();}};
|
||||
return {root,form,input,check,submit,result,setLocked(value){locked=!!value;sync();},reset(){form.reset();invalidate();},reviewedCode(){if(!reviewed?.available||describeRedemption(input.value).code!==reviewed.code||!check.checked)throw Error('Review your code and confirm the action first.');return reviewed.code;}};
|
||||
}
|
||||
|
||||
export function createCodeOfficeBranding(){
|
||||
const footer=el('footer',undefined,'code-office-provider'),brands=el('div',undefined,'code-office-provider-brands'),logo=el('img');logo.src='https://www.dunerealms.com/assets/spost-logo-v1.svg';logo.alt='SPost';logo.width=130;logo.height=43;const group=el('a');group.href='https://www.dunerealms.com/corrino-group.html';const art=el('img');art.src='https://www.dunerealms.com/assets/corrino-group-v4.png';art.alt='Corrino Group';art.width=116;art.height=42;group.append(el('span','part of'),art);brands.append(logo,group);footer.append(el('span','Code services provided by'),brands);return footer;
|
||||
}
|
||||
[/^(?:CLAN-SUB|COM-SUB)-[A-F0-9]{48}$/,'subhouse','Subordinate organisation founding','This key is bound to its mother deed. It cannot create an independent or Royal charter.','Subhouse creation adapter pending',false],
|
||||
[/^DRK-[A-Z2-7]{32}$/,'kit','Kit delivery','Requests your kit delivery. The game confirms arrival.','Redeem kit',true],
|
||||
[/^DRQ-[A-F0-9]{40}$/,'discovery','Discovery reward','Claims your earned discovery reward. The service checks eligibility before crediting.','Claim reward',true],
|
||||
[/^(?:DRU|UP)-[A-F0-9]{48}$/,'token','Upgrade Token','Apply this token to a saved kit in Imperial Tailor.','Open Imperial Tailor',false,'#realm/kits-exchange'],
|
||||
[/^CLAN-[A-F0-9]{48}$/,'clan','Clan founding right','Upgrades your existing Basic clan to an Original House that can become a mother house. A Royal House requires a separate political appointment.','Upgrade my Basic clan',true],
|
||||
[/^COM-[A-F0-9]{48}$/,'company','Company founding right','Upgrades your existing Basic company using its separate original founding right.','Open Company settings',false,'https://corp.dunerealms.com/#company/settings'],
|
||||
[/^POL-[A-F0-9]{48}$/,'politics','Political appointment','Applies the specific appointment recorded by a political decision. The decision determines the organisation and title.','Political appointments coming soon',false]
|
||||
];
|
||||
for(const [pattern,kind,title,description,action,available,href] of types)if(pattern.test(code))return {code:entered,edition,kind,title,description,action,available,href};
|
||||
throw Error('Enter a complete private code. Community commands are used in game.');
|
||||
}
|
||||
|
||||
export function createCodeRedemption(){
|
||||
let reviewed=null,locked=false;
|
||||
const root=el('section',undefined,'code-redemption'),hero=el('header',undefined,'reward-code-banner'),art=el('img');art.src='https://www.dunerealms.com/assets/imperial-seal-128.png';art.alt='';const heading=el('div');heading.append(el('small','SPOST · IMPERIAL CODE OFFICE'),el('h4','Present your code. Open your next chapter.'),el('p','Your SPost counter for rewards, founding rights and political appointments.'));hero.append(art,heading);
|
||||
const layout=el('div',undefined,'code-redemption-layout'),form=el('form',undefined,'code-redemption-card'),entry=el('fieldset'),legend=el('legend','1 · Enter your private code'),label=el('label','Code'),input=el('input');input.type='text';input.autocomplete='off';input.spellcheck=false;input.autocapitalize='characters';input.required=true;input.maxLength=128;input.placeholder='Paste your complete code';input.setAttribute('aria-describedby','redemption-code-help');const help=el('p','Keep your code private. Checking its format does not use it.','code-redemption-muted');help.id='redemption-code-help';label.append(input);const inspect=el('button','Review code');inspect.type='button';entry.append(legend,label,help,inspect);
|
||||
const preview=el('fieldset',undefined,'code-redemption-preview');preview.hidden=true;preview.append(el('legend','2 · Review & confirm'));const badge=el('span',undefined,'reward-kind'),title=el('h5'),effect=el('p'),verification=el('p','Format recognised. Ownership and eligibility are checked when you submit.','code-redemption-muted'),check=el('input');check.type='checkbox';const consent=el('label',undefined,'code-redemption-consent');consent.append(check,el('span','I understand this action and want to use my code.'));const submit=el('button','Confirm redemption');submit.type='submit';submit.disabled=true;const destination=el('a');destination.hidden=true;preview.append(badge,title,effect,verification,consent,submit,destination);const result=el('p',undefined,'code-redemption-result');result.setAttribute('role','status');result.setAttribute('aria-live','polite');form.append(entry,preview,result);
|
||||
const guide=el('aside',undefined,'code-redemption-card code-redemption-guide');guide.append(el('small','WHAT CAN YOU PRESENT?'),el('h5','Your code chooses the route.'));
|
||||
for(const [kind,name,copy] of [['kit','Kits & discoveries','Existing DRK and DRQ codes can be redeemed here.'],['clan','House & company charters','Create your Basic clan first. CLAN upgrades your Basic clan to an Original House. Keep your separate COM code for Company CP.'],['politics','Political appointments','POL codes come from an approved decision. Founding alone does not confer a Royal title.'],['token','Upgrade Tokens','DRU tokens are applied to a saved kit in Imperial Tailor.']]){const card=el('div',undefined,'code-redemption-guide-item');card.append(el('span',name,'reward-kind reward-kind-'+kind),el('p',copy));guide.append(card);}const register=el('a','← View your codes');register.href='#';register.onclick=e=>{e.preventDefault();root.dispatchEvent(new CustomEvent('show-code-register',{bubbles:true}));};guide.append(createDeedArtwork('keys'),register);layout.append(form,guide);root.append(hero,layout);
|
||||
function sync(){submit.disabled=locked||!reviewed?.available||!check.checked;inspect.disabled=locked;input.disabled=locked;check.disabled=locked;}
|
||||
function invalidate(){reviewed=null;check.checked=false;preview.hidden=true;result.textContent='';sync();}
|
||||
input.oninput=invalidate;check.onchange=sync;
|
||||
inspect.onclick=()=>{if(locked)return;try{reviewed=describeRedemption(input.value);check.checked=false;badge.className='reward-kind reward-kind-'+reviewed.kind;badge.textContent=reviewed.available?'Ready to submit':'Dedicated route';title.textContent=reviewed.title;effect.textContent=reviewed.description;submit.textContent=reviewed.action;submit.hidden=!reviewed.available;consent.hidden=!reviewed.available;destination.hidden=!reviewed.href;if(reviewed.href){destination.href=reviewed.href;destination.textContent=reviewed.action;}verification.textContent=reviewed.available?'Format recognised. Ownership and eligibility are checked when you submit.':reviewed.href?'Continue in the dedicated workshop to choose your kit.':'This route is being connected. Your code has not been used.';preview.hidden=false;result.textContent='';sync();}catch(error){invalidate();showInvalidKey(result,error.message);void fetch('/api/jarvis/validate',{method:'POST',credentials:'same-origin',headers:{'Content-Type':'application/json'},body:JSON.stringify({code:input.value})}).catch(()=>{});input.focus();}};
|
||||
return {root,form,input,check,submit,result,setLocked(value){locked=!!value;sync();},reset(){form.reset();invalidate();},reviewedCode(){if(!reviewed?.available||describeRedemption(input.value).code!==reviewed.code||!check.checked)throw Error('Review your code and confirm the action first.');return reviewed.code;}};
|
||||
}
|
||||
|
||||
export function createCodeOfficeBranding(){
|
||||
const footer=el('footer',undefined,'code-office-provider'),brands=el('div',undefined,'code-office-provider-brands'),logo=el('img');logo.src='https://www.dunerealms.com/assets/spost-logo-v1.svg';logo.alt='SPost';logo.width=130;logo.height=43;const group=el('a');group.href='https://www.dunerealms.com/corrino-group.html';const art=el('img');art.src='https://www.dunerealms.com/assets/corrino-group-v4.png';art.alt='Corrino Group';art.width=116;art.height=42;group.append(el('span','part of'),art);brands.append(logo,group);footer.append(el('span','Code services provided by'),brands);return footer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,3 @@
|
|||
.codex-management{color:#e8e4d1;min-width:0}.codex-management-hero{display:flex;align-items:center;gap:22px;padding:22px;border-bottom:1px solid #9d854c;background:linear-gradient(100deg,#153b32eb,#122e29e8),url(https://www.dunerealms.com/assets/guild.webp) center/cover}.codex-management-hero>img{width:84px;height:84px;object-fit:contain}.codex-management h2,.codex-management h3{color:#eed495;font-family:Georgia,serif}.codex-management h2{font-size:clamp(25px,3vw,38px);margin:8px 0}.codex-management small{letter-spacing:.13em;color:#c5ad72}.codex-preview-notice{margin:18px;padding:12px 16px;border-left:3px solid #bd9e57;background:#223b34;line-height:1.6}.codex-management-grid{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(250px,1fr);gap:18px}.codex-management [role=tabpanel]{padding:0 18px 18px}.codex-management-box{min-width:0;border:1px solid #7d794f;border-radius:12px;padding:20px;background:linear-gradient(130deg,#1b3d32f5,#122d27f5)}.codex-management-box h3{margin-top:0;font-size:23px}.codex-management p{line-height:1.65}.codex-table-scroll{overflow:auto;max-width:100%;margin:16px 0}.codex-management table{width:100%;border-collapse:collapse;font-size:14px}.codex-management th{text-align:left;color:#efd598;background:#263f35}.codex-management td,.codex-management th{padding:12px;border-bottom:1px solid #526649;vertical-align:top}.codex-field{display:grid;gap:8px;margin:15px 0;font-size:14px}.codex-field>span{color:#d3c28e}.codex-field input,.codex-field select,.codex-field textarea{box-sizing:border-box;width:100%;min-width:0;padding:12px;border:1px solid #667b61;border-radius:6px;background:#102a24;color:#eee6cf;font:inherit}.codex-management button:disabled{padding:12px 16px;margin:6px 8px 6px 0;border:1px solid #68745a;border-radius:7px;background:#263c32;color:#b5b59f;cursor:not-allowed}.codex-seal-note{padding:12px;border-left:2px solid #aa9259;margin:14px 0;background:#142e27}.codex-seal-note strong{color:#e4c67d}.codex-seal-note p{margin-bottom:0}@media(max-width:900px){.codex-management-grid{grid-template-columns:minmax(0,1fr)}}@media(max-width:500px){.codex-management-hero{padding:14px;gap:12px}.codex-management-hero>img{width:60px;height:60px}.codex-management [role=tabpanel]{padding:0 10px 10px}.codex-management-box{padding:14px}}
|
||||
.codex-management{color:#e8e4d1;min-width:0}.codex-management-hero{display:flex;align-items:center;gap:22px;padding:22px;border-bottom:1px solid #9d854c;background:linear-gradient(100deg,#153b32eb,#122e29e8),url(https://www.dunerealms.com/assets/guild.webp) center/cover}.codex-management-hero>img{width:84px;height:84px;object-fit:contain}.codex-management h2,.codex-management h3{color:#eed495;font-family:Georgia,serif}.codex-management h2{font-size:clamp(25px,3vw,38px);margin:8px 0}.codex-management small{letter-spacing:.13em;color:#c5ad72}.codex-preview-notice{margin:18px;padding:12px 16px;border-left:3px solid #bd9e57;background:#223b34;line-height:1.6}.codex-management-grid{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(250px,1fr);gap:18px}.codex-management [role=tabpanel]{padding:0 18px 18px}.codex-management-box{min-width:0;border:1px solid #7d794f;border-radius:12px;padding:20px;background:linear-gradient(130deg,#1b3d32f5,#122d27f5)}.codex-management-box h3{margin-top:0;font-size:23px}.codex-management p{line-height:1.65}.codex-table-scroll{overflow:auto;max-width:100%;margin:16px 0}.codex-management table{width:100%;border-collapse:collapse;font-size:14px}.codex-management th{text-align:left;color:#efd598;background:#263f35}.codex-management td,.codex-management th{padding:12px;border-bottom:1px solid #526649;vertical-align:top}.codex-field{display:grid;gap:8px;margin:15px 0;font-size:14px}.codex-field>span{color:#d3c28e}.codex-field input,.codex-field select,.codex-field textarea{box-sizing:border-box;width:100%;min-width:0;padding:12px;border:1px solid #667b61;border-radius:6px;background:#102a24;color:#eee6cf;font:inherit}.codex-management button:disabled{padding:12px 16px;margin:6px 8px 6px 0;border:1px solid #68745a;border-radius:7px;background:#263c32;color:#b5b59f;cursor:not-allowed}.codex-seal-note{padding:12px;border-left:2px solid #aa9259;margin:14px 0;background:#142e27}.codex-seal-note strong{color:#e4c67d}.codex-seal-note p{margin-bottom:0}@media(max-width:900px){.codex-management-grid{grid-template-columns:minmax(0,1fr)}}@media(max-width:500px){.codex-management-hero{padding:14px;gap:12px}.codex-management-hero>img{width:60px;height:60px}.codex-management [role=tabpanel]{padding:0 10px 10px}.codex-management-box{padding:14px}}
|
||||
|
||||
.codex-live-register nav{display:flex;align-items:center;flex-wrap:wrap;gap:12px}.codex-live-register nav button{padding:10px 16px;border:1px solid #a48b4d;border-radius:7px;background:#18372d;color:#eed594;cursor:pointer}.codex-live-register td{overflow-wrap:anywhere}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
import {showInvalidKey} from './cp-v2-key-validation.mjs';
|
||||
import {createJarvisRegister} from './cp-v2-jarvis-register.mjs';
|
||||
import {organisationTabs} from '../organisation-tabs.mjs';
|
||||
const assets='https://www.dunerealms.com/assets/';
|
||||
const make=(tag,text,className)=>{const node=document.createElement(tag);if(text!==undefined)node.textContent=text;if(className)node.className=className;return node;};
|
||||
const TYPES=[['Clan upgrade','Silver charter','Upgrade a Basic clan','Original or staff issue'],['Company upgrade','Silver charter','Upgrade a Basic company','Original or staff issue'],['Royal appointment','Gold charter','Political appointment or authorised reward','Original or staff issue'],['Political office','Office deed','Appointment for a defined term','Political decision'],['Kit','Equipment seal','Single redemption of a defined kit','Kit service'],['Custom item','Item instance','Unique physical or redeemable item','J.A.R.V.I.S. publication'],['Promotion credit','Dispatch seal','One Board or Discord publication','Reward or authorised grant']];
|
||||
const TYPES=[['Event instrument','EVT reference','Schedule and manage an event; not a redeemable reward','Organisation deed or staff'],['Rihla transfer','RIA key','In-game collection by the named recipient; created / paid / cancelled','Rihla service'],['Clan upgrade','Silver charter','Upgrade a Basic clan','Original or staff issue'],['Company upgrade','Silver charter','Upgrade a Basic company','Original or staff issue'],['Royal appointment','Gold charter','Political appointment or authorised reward','Original or staff issue'],['Political office','Office deed','Appointment for a defined term','Political decision'],['Kit','Equipment seal','Single redemption of a defined kit','Kit service'],['Custom item','Item instance','Unique physical or redeemable item','J.A.R.V.I.S. publication'],['Promotion credit','Dispatch seal','One Board or Discord publication','Reward or authorised grant']];
|
||||
function image(name){const img=make('img');img.src=assets+name;img.alt='';img.loading='lazy';return img;}
|
||||
function field(label,options){const wrapper=make('label',undefined,'codex-field');wrapper.append(make('span',label));let input;if(Array.isArray(options)){input=make('select');for(const option of options){const node=make('option',option);input.append(node);}}else{input=make(options==='message'?'textarea':'input');input.type='text';input.placeholder=options||'';}wrapper.append(input);return wrapper;}
|
||||
function locked(label){const button=make('button',label);button.type='button';button.disabled=true;button.title='Design preview: service connection pending';return button;}
|
||||
function table(headers,rows){const wrap=make('div',undefined,'codex-table-scroll'),table=make('table'),thead=make('thead'),head=make('tr'),body=make('tbody');for(const text of headers){const cell=make('th',text);cell.scope='col';head.append(cell);}thead.append(head);for(const cells of rows){const row=make('tr');for(const value of cells)row.append(make('td',value));body.append(row);}table.append(thead,body);wrap.append(table);return wrap;}
|
||||
function empty(headers,copy){const wrapper=table(headers,[]),row=make('tr'),cell=make('td',copy);cell.colSpan=headers.length;row.append(cell);wrapper.querySelector('tbody').append(row);return wrapper;}
|
||||
function box(title,copy){const node=make('article',undefined,'codex-management-box');node.append(make('h3',title));if(copy)node.append(make('p',copy));return node;}
|
||||
export function mountCodexManagement(host,{initial='keys'}={}){
|
||||
export function mountCodexManagement(host,{initial='keys',fetcher=fetch}={}){
|
||||
if(!document.querySelector('link[data-codex-management]')){const css=make('link');css.rel='stylesheet';css.href=new URL('./cp-v2-codex-management.css',import.meta.url).href;css.dataset.codexManagement='';document.head.append(css);}
|
||||
const root=make('section',undefined,'codex-management'),hero=make('header',undefined,'codex-management-hero');hero.append(image('exchange-quests-v1.png'));const heading=make('div');heading.append(make('small','IMPERIAL BUREAU · MANAGEMENT'),make('h2','J.A.R.V.I.S.'),make('p','Issue, register and deliver the instruments of the realm.'));hero.append(heading);root.append(hero,make('p','Design preview · No live records are loaded. Issuing, replacing, transferring and delivery actions remain unavailable.','codex-preview-notice'));
|
||||
const root=make('section',undefined,'codex-management'),hero=make('header',undefined,'codex-management-hero');hero.append(image('exchange-quests-v1.png'));const heading=make('div');heading.append(make('small','IMPERIAL BUREAU · MANAGEMENT'),make('h2','J.A.R.V.I.S.'),make('p','Issue, register and deliver the instruments of the realm.'));hero.append(heading);root.append(hero,make('p','Live registers are connected where available. Issuing, replacing, transferring and delivery controls are enabled only when their service supports the action.','codex-preview-notice'));
|
||||
const disposers=[];let mounted=true;const groups=[];
|
||||
function retained(content,label,path,name,args=[]){const node=make('details',undefined,'codex-retained-service'),summary=make('summary',label),host=make('div');let started=false;summary.onclick=()=>{if(started)return;started=true;import(path).then(module=>{if(mounted)disposers.push(module[name](host,...args));}).catch(()=>{if(mounted)host.textContent='Existing service unavailable. Reload to retry.';});};node.append(summary,host);content.append(node);}
|
||||
|
||||
|
|
@ -20,8 +22,9 @@ export function mountCodexManagement(host,{initial='keys'}={}){
|
|||
const kits=box('Kits','Kit definitions, equipment and redeemable kit instances share the J.A.R.V.I.S. catalogue.');kits.append(empty(['Kit','Revision','Contents','Availability'],'Kit catalogue adapter pending.'),locked('Define kit'));retained(kits,'Open existing kit service','./cp-v2-kit-directorate.mjs','mountKitDirectorate',['server-kits']);groups.push({id:'kits',title:'Kits',content:kits});
|
||||
const publication=box('Publication','Review versions and their distribution channels before publication.');publication.append(empty(['Definition','Revision','Approval','Channels','State'],'Publication queue is not connected.'),locked('Publish approved revision'));retained(publication,'Open existing publication service','./cp-v2-kit-directorate.mjs','mountKitDirectorate',['kit-publishing']);groups.push({id:'publication',title:'Publication',content:publication});
|
||||
const delivery=box('Deliveries & claims','Track each delivery attempt against one instance. Retries retain the same delivery identity.');delivery.append(field('Delivery state',['All states','Queued','Processing','Delivered','Failed','Redeemed','Revoked']),empty(['Instance','Recipient','Method','State','Last attempt','Action'],'Delivery service not connected. No delivery totals are inferred.'),locked('Retry selected delivery'));groups.push({id:'delivery',title:'Delivery',content:delivery});
|
||||
const listings=box('Listings & distribution','One exchange for goods and eligible J.A.R.V.I.S. instruments. Listings retain the record owner and instance reference.');listings.append(empty(['Listing','Type','Owner','Audience','State'],'Listing administration adapter pending.'),locked('Review listing'));retained(listings,'Open existing exchange controls','./cp-v2-exchange-authority.mjs','mountExchangeAuthority');groups.push({id:'listings',title:'Listings',content:listings});
|
||||
const listings=box('Listings & distribution','One exchange for goods and eligible J.A.R.V.I.S. instruments. Listings retain the record owner and instance reference.');listings.append(empty(['Listing','Type','Owner','Audience','State'],'Listing administration adapter pending.'),locked('Manage listing · service adapter pending'));retained(listings,'Open existing exchange controls','./cp-v2-exchange-authority.mjs','mountExchangeAuthority');groups.push({id:'listings',title:'Listings',content:listings});
|
||||
const history=box('History','Issuance, replacements, transfers, redemption and delivery attempts are recorded without exposing private key material.');history.append(field('Search history','Instance, issuer, recipient or decision'),empty(['Time','Instrument','Action','Actor','Reason','Result'],'Audit service not connected.'));groups.push({id:'history',title:'History',content:history});
|
||||
const seasons=box('Seasons & signing keys','Each season or isolated test run has its own signing-key version. Existing deeds and historical items retain their origin.');seasons.append(table(['Policy','Behaviour'],[['Origin','Season, Alpha/Beta/Live stage, release version and issue date stay attached to the instance.'],['Historical originals','Staff regeneration creates a new current-version instance; it never relabels the historical original.'],['Quality','Common, Uncommon, Rare, Very Rare and Legendary describe quality independently from edition age and actual scarcity.'],['Carry-over','Deeds persist. Unused older-season keys and rare items remain valid and transferable when their type permits.'],['Key rotation','New issues use the active signing key; historical signatures remain verifiable.'],['Test isolation','Test-run instances belong to their own namespace and cannot be redeemed in production.'],['Duplicate protection','Validate on use, redemption or transfer; atomic processing accepts an instance only once.']]),locked('Rotate active signing key'),locked('Create isolated test run'));groups.push({id:'seasons',title:'Seasons',content:seasons});
|
||||
root.append(organisationTabs(groups,{label:'J.A.R.V.I.S. Management sections',initial}));host.replaceChildren(root);return()=>{mounted=false;for(const dispose of disposers)if(typeof dispose==='function')dispose();root.remove();};
|
||||
const validator=box('Check a key','Read-only inspection. Checking never activates or consumes a key.'),checkForm=make('form'),checkInput=make('input'),checkButton=make('button','Check key'),checkResult=make('div');checkInput.type='password';checkInput.autocomplete='off';checkInput.maxLength=300;checkInput.required=true;checkInput.setAttribute('aria-label','Private key to validate');checkButton.type='submit';checkForm.append(checkInput,checkButton);validator.append(checkForm,checkResult);groups.find(g=>g.id==='keys').content.append(validator);checkForm.onsubmit=async event=>{event.preventDefault();if(checkButton.disabled)return;checkButton.disabled=true;try{const r=await fetcher('/api/jarvis/validate',{method:'POST',credentials:'same-origin',headers:{'Content-Type':'application/json'},body:JSON.stringify({code:checkInput.value,staff:true})}),data=await r.json();if(!r.ok)throw Error(data.message||'Validation unavailable');if(data.state==='invalid')showInvalidKey(checkResult,'Key rejected. Dev support: '+(data.ticketNumber||data.caseId||'pending'));else checkResult.textContent=data.valid?'Recognised · '+data.state+' · no key consumed.':'This key type cannot be checked by the connected service.';}catch(e){checkResult.textContent=e.message;}finally{checkInput.value='';checkButton.disabled=false;}};
|
||||
const registers=new Map();for(const [tab,section] of [['keys','keys'],['keys','deeds'],['listings','listings'],['history','history'],['delivery','delivery'],['seasons','seasons']]){const register=createJarvisRegister(section,{fetcher}),group=groups.find(g=>g.id===tab);if(['listings','history','delivery'].includes(tab))group.content.querySelector('.codex-table-scroll')?.remove();if(tab==='history')group.content.querySelector('.codex-field')?.remove();if(tab==='delivery'){const filter=group.content.querySelector('select');if(filter)filter.disabled=true;}const frame=box(section==='deeds'?'Office deeds':'Live '+section+' register');frame.append(register.root);group.content.append(frame);if(!registers.has(tab))registers.set(tab,[]);registers.get(tab).push(register);disposers.push(register.dispose);}const tabs=organisationTabs(groups,{label:'J.A.R.V.I.S. Management sections',initial});tabs.addEventListener('organisation-tab-change',event=>{for(const item of registers.get(event.detail.id)||[])item.load();});root.append(tabs);for(const item of registers.get(initial)||[])item.load();host.replaceChildren(root);return()=>{mounted=false;for(const dispose of disposers)if(typeof dispose==='function')dispose();root.remove();};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
import {startCPAuthentication} from './cp-v2-auth.mjs';import {createCPV2ContentPage,element as el} from './cp-v2-page-template.mjs';import {createUserAPI} from './cp-v2-user-api.mjs';
|
||||
const controller=new AbortController(),api=createUserAPI(fetch,controller.signal),id=new URL(location.href).searchParams.get('company'),host=document.querySelector('#content');window.addEventListener('pagehide',()=>controller.abort(),{once:true});
|
||||
startCPAuthentication(async()=>{document.querySelector('#portals').hidden=true;document.querySelector('#sidebar').hidden=true;document.querySelector('#sidebar-right').hidden=true;document.querySelector('.layout').style.display='block';const frame=createCPV2ContentPage({host,title:'Company membership application',description:'Apply for a place in this company. The company reviews your request.',reload:()=>location.reload()});try{if(!/^[a-f0-9-]{36}$/i.test(id||''))throw Error('Choose a company.');const data=await api.request('/api/companies/deeds/'+id);frame.content.append(el('h3',data.name),el('p',data.memberCount+' / '+data.memberLimit+' members'));if(data.protected||data.memberCount>=data.memberLimit){frame.status.textContent=data.protected?'This protected company uses its own appointment or Order membership rules.':'This company is full.';return;}frame.status.hidden=true;const form=el('form'),check=el('input'),label=el('label'),send=el('button','Send application'),feedback=el('p');check.type='checkbox';check.required=true;label.append(check,document.createTextNode(' I confirm this company membership application.'));send.type='submit';form.append(label,send,feedback);frame.content.append(form);form.onsubmit=async e=>{e.preventDefault();if(send.disabled||!form.reportValidity())return;send.disabled=true;try{await api.request('/api/companies/recruitment',{action:'request',companyId:id,version:data.version});form.replaceChildren(el('p','Application sent. The company can accept or decline your request.'));}catch(error){feedback.textContent=error.message;if(!error.uncertain)send.disabled=false;}};}catch(error){frame.status.textContent=error.message;}});
|
||||
|
|
@ -1,18 +1,20 @@
|
|||
import {renderApplications} from '../election-applications-view.mjs';
|
||||
import {renderVoting} from '../election-voting-view.mjs';
|
||||
import {createCPV2Page,element as el} from './cp-v2-page-template.mjs';
|
||||
import {mountPromotionAgenda,ELECTION_DESIGN_TYPES,electionDesignStyles} from './cp-v2-promotion-agenda.mjs';
|
||||
import {createCardGallery,createListingCard} from './cp-v2-exchange-cards.mjs';
|
||||
export function mountElectionDesign(host,{context='clan'}={}){
|
||||
electionDesignStyles();let active=true,election=context==='clan'?'clan_delegate':'faction',disposeCalendar=()=>{},disposeBooking=()=>{};
|
||||
const outer=el('div',undefined,'election-design');outer.dataset.mode='design-only';const scope=el('div',undefined,'election-scope-selector');if(context!=='clan'){const label=el('label','Election'),select=el('select');select.setAttribute('aria-label','Choose election');for(const id of ['faction','emperor','bene','guild']){const option=el('option',ELECTION_DESIGN_TYPES[id].name);option.value=id;select.append(option);}select.onchange=()=>{election=select.value;draw();};label.append(select);scope.append(label);}const content=el('div');outer.append(scope,content);host.replaceChildren(outer);
|
||||
electionDesignStyles();let sessionUser=null,playerContext=null;let active=true,election=context==='clan'?'clan_delegate':'faction',disposeCalendar=()=>{},disposeBooking=()=>{};
|
||||
const outer=el('div',undefined,'election-design');outer.dataset.mode='connected-elections';const scope=el('div',undefined,'election-scope-selector');if(context!=='clan'){const label=el('label','Election'),select=el('select');select.setAttribute('aria-label','Choose election');for(const id of ['faction','emperor','bene','guild']){const option=el('option',ELECTION_DESIGN_TYPES[id].name);option.value=id;select.append(option);}select.onchange=()=>{election=select.value;draw();};label.append(select);scope.append(label);}const content=el('div');outer.append(scope,content);host.replaceChildren(outer);
|
||||
function draw(){disposeCalendar();disposeBooking();const type=ELECTION_DESIGN_TYPES[election],applications=el('section',undefined,'election-page-grid'),apply=el('article',undefined,'election-panel'),history=el('article',undefined,'election-panel');apply.append(el('small','YOUR CANDIDATURE','election-eyebrow'),el('h3','Stand before the banners'),el('p','Your verified character, eligibility and candidature dossier will appear here.'));
|
||||
const form=el('form',undefined,'election-form');form.onsubmit=e=>e.preventDefault();for(const [text,tag,placeholder]of [['Campaign title','input','Your campaign headline'],['Motivation & programme','textarea','Your plans and responsibilities']]){const label=el('label',text),field=el(tag);field.placeholder=placeholder;field.disabled=true;label.append(field);form.append(label);}const submit=el('button','Submit candidature · backend in commit 2');submit.type='button';submit.disabled=true;form.append(submit);apply.append(form);history.append(el('small','J.A.R.V.I.S. REGISTER','election-eyebrow'),el('h3','My applications'),emptyTable(['Reference','Election','Status','Details'],'No live application records are loaded in this design preview.'));
|
||||
const campaign=el('article',undefined,'election-panel election-campaign-panel'),booking=el('div'),book=el('button','Preview campaign booking agenda');book.type='button';campaign.append(el('small','STARPORT CAMPAIGN','election-eyebrow'),el('h3','Give your campaign a voice'),el('p',type.price+' DM per hour · campaign advertising only in the seven days before voting. Featured surcharge is separate and still to be confirmed.'),createListingCard({type:'campaign',image:'https://www.dunerealms.com/assets/seals/'+type.art,title:'Your campaign headline',subtitle:type.name+' · Example candidate',message:'Your candidate portrait, House seal and message become an advertisement on Starport.',featured:true,duration:'Example · 1 hour placement'},{preview:true}),book,booking);book.onclick=()=>{disposeBooking();disposeBooking=mountPromotionAgenda(booking,{election,organisationKind:context});book.hidden=true;};applications.append(apply,history,campaign);
|
||||
const voting=el('section',undefined,'election-panel');voting.append(el('small','THE BALLOT CHAMBER','election-eyebrow'),el('h3','Voting'),el('p','The existing three-hour ballot, eligibility and vote allowance will be connected in commit 2.'));const candidates=el('div',undefined,'election-candidate-grid');for(const caption of ['Candidate portrait','Candidate portrait']){const card=el('article',undefined,'election-candidate-preview'),portrait=el('div','✦','election-portrait-placeholder');portrait.setAttribute('aria-label',caption);card.append(portrait,el('h4','Candidate record'),el('p','Character name · House identity'),el('p','Programme and linked campaign details.'));const button=el('button','Cast vote · not connected');button.type='button';button.disabled=true;card.append(button);candidates.append(card);}voting.append(candidates,el('p','No sample vote totals or real candidates are shown.','election-muted'));
|
||||
const results=el('section',undefined,'election-panel');results.append(el('small','THE OFFICE REGISTER','election-eyebrow'),el('h3','Results & office history'),el('p','The result creates the office deed; the register preserves the history of the office. Current office deeds determine Polclan access.'),emptyTable(['Election','Winner','Term','Office deed','History'],'No result is inferred or changed by this preview.'),el('p','A tie retains the existing immediate three-hour runoff.'));
|
||||
const campaign=el('article',undefined,'election-panel election-campaign-panel'),booking=el('div'),book=el('button','Preview campaign booking agenda');book.type='button';campaign.append(el('small','STARPORT CAMPAIGN','election-eyebrow'),el('h3','Give your campaign a voice'),el('p',type.price+' DM per hour · campaign advertising only in the seven days before voting. Featured surcharge is separate and still to be confirmed.'),createListingCard({type:'campaign',image:'https://www.dunerealms.com/assets/seals/'+type.art,title:'Your campaign headline',subtitle:type.name+' · Example candidate',message:'Your candidate portrait, House seal and message become an advertisement on Starport.',featured:true,duration:'Example · 1 hour placement'},{preview:true}),book,booking);book.onclick=()=>{disposeBooking();disposeBooking=mountPromotionAgenda(booking,{election,organisationKind:context});book.hidden=true;};applications.append(campaign);if(playerContext)applications.prepend(renderApplications({user:sessionUser,context:playerContext,kind:type.kind}));else applications.prepend(el('p','Checking your player election record…','election-muted'));
|
||||
const voting=el('section',undefined,'election-panel');voting.append(el('small','THE BALLOT CHAMBER','election-eyebrow'),el('h3','Voting'),el('p','The existing three-hour ballot, eligibility and vote allowance will be connected in commit 2.'));const candidates=el('div',undefined,'election-candidate-grid');for(const caption of ['Candidate portrait','Candidate portrait']){const card=el('article',undefined,'election-candidate-preview'),portrait=el('div','✦','election-portrait-placeholder');portrait.setAttribute('aria-label',caption);card.append(portrait,el('h4','Candidate record'),el('p','Character name · House identity'),el('p','Programme and linked campaign details.'));const button=el('button','Cast vote · not connected');button.type='button';button.disabled=true;card.append(button);candidates.append(card);}voting.replaceChildren(renderVoting(type.kind));
|
||||
const results=el('section',undefined,'election-panel');results.append(el('small','THE OFFICE REGISTER','election-eyebrow'),el('h3','Results & office history'),el('p','The result creates the office deed; the register preserves the history of the office. Current office deeds determine Polclan access.'),emptyTable(['Election','Winner','Term','Office deed','History'],'No result is inferred or changed by this preview.'),el('p','A tied result starts an automatic three-hour office auction on Starport. Auction execution is connected in the backend batch.'));
|
||||
const calendar=el('section');let calendarMounted=false;const page=createCPV2Page({shellHost:host,title:context==='clan'?'Clan Elections · Landsraad Delegate':type.name+' Elections',description:context==='clan'?'Applications, voting, results and calendar for the Clan Delegate to the Landsraad.':'Citizen election workspace · eligibility follows your existing personal and political records.',artwork:'seals/'+type.art,tabs:[{id:'applications',label:'Applications',content:applications},{id:'voting',label:'Voting',content:voting},{id:'results',label:'Results',content:results},{id:'calendar',label:'Calendar',content:calendar}],onActivate:id=>{if(id==='calendar'&&!calendarMounted){calendarMounted=true;queueMicrotask(()=>{if(active)disposeCalendar=mountPromotionAgenda(calendar,{election,remindersOnly:true});});}}});
|
||||
const notice=el('p','DESIGN PREVIEW · no applications, votes, bookings or payments are submitted. Existing election services remain unchanged.','election-preview-notice');content.replaceChildren(notice,page.root);if(context==='company')content.prepend(el('p','Company membership does not create extra votes. This page follows your personal election eligibility.','election-muted'));
|
||||
const notice=el('p','Applications and ballots use the existing election service. Advertising bookings remain a preview until the payment and reservation service is connected.','election-preview-notice');content.replaceChildren(notice,page.root);if(context==='company')content.prepend(el('p','Company membership does not create extra votes. This page follows your personal election eligibility.','election-muted'));
|
||||
}
|
||||
draw();return()=>{active=false;disposeCalendar();disposeBooking();outer.remove();};
|
||||
draw();void Promise.all([fetch('/api/auth/session',{cache:'no-store'}),fetch('/api/politics/preview',{cache:'no-store'})]).then(async responses=>{const [session,context]=await Promise.all(responses.map(async r=>r.ok?r.json():null));if(!active)return;sessionUser=session?.user;playerContext=context||{linked:false};draw();}).catch(()=>{if(active){playerContext={linked:false};draw();}});return()=>{active=false;disposeCalendar();disposeBooking();outer.remove();};
|
||||
}
|
||||
function emptyTable(headings,message){const wrap=el('div',undefined,'election-table-scroll'),table=el('table'),head=el('thead'),row=el('tr');for(const text of headings)row.append(el('th',text));head.append(row);const body=el('tbody'),empty=el('tr'),cell=el('td',message);cell.colSpan=headings.length;empty.append(cell);body.append(empty);table.append(head,body);wrap.append(table);return wrap;}
|
||||
export function mountAdvertisingDesign(host,{context='clan'}={}){
|
||||
|
|
|
|||
10
website/control-panel/public/cp-v2/cp-v2-events.mjs
Normal file
10
website/control-panel/public/cp-v2/cp-v2-events.mjs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import {element as el,createCPV2Page} from './cp-v2-page-template.mjs';import {createUserAPI} from './cp-v2-user-api.mjs';import {calendarLibrary,electionDesignStyles} from './cp-v2-promotion-agenda.mjs';
|
||||
const colors={server:'#927123',clan:'#28714d',company:'#245e82',politics:'#74325e',atreides:'#28714d',harkonnen:'#a43c38',corrino:'#927123',ordos:'#386d8d',fremen:'#a36327',veiled_concord:'#74325e',spacing_guild:'#277b83'};
|
||||
export function mountRealmEvents(host,{kind=null,scopeId=null,fetcher=fetch}={}){
|
||||
electionDesignStyles();let active=true,calendar=null,rows=[],canManage=false,busy=false,editing=null,pending=null;const controller=new AbortController(),api=createUserAPI(fetcher,controller.signal),calendarHost=el('div'),manage=el('section',undefined,'election-panel'),create=el('section',undefined,'election-panel'),status=el('p','Opening J.A.R.V.I.S. events…'),scope=el('select'),legend=el('p'),details=el('section',undefined,'election-panel');status.setAttribute('role','status');for(const [id,label]of [['','All events'],['server','Server'],['clan','Clan'],['company','Company'],['politics','Politics / faction']]){const option=el('option',label);option.value=id;scope.append(option);}scope.setAttribute('aria-label','Filter events');legend.append(el('span','Server · gold | Clan · green | Company · blue | Politics · faction colours'));const calendarPanel=el('section');calendarPanel.append(scope,legend,calendarHost,details);
|
||||
const form=el('form',undefined,'organisation-settings-form'),title=el('input'),description=el('textarea'),start=el('input'),end=el('input'),check=el('input'),save=el('button','Publish event'),feedback=el('p');title.maxLength=100;title.minLength=3;title.required=true;description.maxLength=2000;start.type=end.type='datetime-local';start.required=end.required=true;check.type='checkbox';check.required=true;for(const [name,input]of [['Title',title],['Description',description],['Starts · UTC',start],['Ends · UTC',end],['I confirm this event publication.',check]]){const label=el('label',name);label.append(input);form.append(label);}save.type='submit';form.append(save,feedback);const promotion=el('fieldset');promotion.append(el('legend','Promotion'));for(const name of ['Boards','Discord']){const label=el('label',name),input=el('input');input.type='checkbox';input.disabled=true;label.prepend(input);promotion.append(label);}promotion.append(el('p','Promotion delivery is not configured yet. No fee or credit is charged.'));form.append(promotion);create.append(el('h3','Create event'),form);const {root,activate}=createCPV2Page({shellHost:host,title:'Events',description:'Shared calendar and J.A.R.V.I.S. event instruments.',artwork:'nav-home-v2.webp',tabs:[{id:'calendar',label:'Calendar',content:calendarPanel},{id:'manage',label:'Manage Events',content:manage},{id:'create',label:'Create Event',content:create}],onActivate:id=>{if(id==='calendar')requestAnimationFrame(()=>calendar?.updateSize());}});root.prepend(status);host.replaceChildren(root);
|
||||
const local=n=>new Date(n).toISOString().slice(0,16);function eventData(){return rows.filter(r=>r.state==='scheduled'&&(!scope.value||r.kind===scope.value)).map(r=>({id:r.id,title:r.title,start:new Date(r.startsAt).toISOString(),end:new Date(r.endsAt).toISOString(),backgroundColor:colors[r.scopeId]||colors[r.kind],borderColor:colors[r.scopeId]||colors[r.kind]}));}function draw(){if(calendar){calendar.removeAllEvents();calendar.addEventSource(eventData());}manage.replaceChildren(el('h3','Your event instruments'));if(!canManage){manage.append(el('p','A current organisation deed or staff authority is required to manage these events.'));}else for(const row of rows){const card=el('article',undefined,'election-panel');card.append(el('h4',row.title),el('code',row.reference),el('p',row.state+' · '+new Date(row.startsAt).toLocaleString('en-GB',{timeZone:'UTC'})+' UTC'));if(row.state==='scheduled'){const edit=el('button','Edit'),cancel=el('button','Delete event');edit.type=cancel.type='button';edit.onclick=()=>{editing=row;pending=null;title.value=row.title;description.value=row.description;start.value=local(row.startsAt);end.value=local(row.endsAt);check.checked=false;save.textContent='Save changes';activate('create');};cancel.onclick=async()=>{if(busy||!confirm('Remove this event from the calendar? The audit record will remain.'))return;busy=true;try{await api.request('/api/jarvis/events',{...row,scopeId:row.scopeId,action:'cancel',requestId:crypto.randomUUID(),confirmed:true});await load();}catch(e){status.textContent=e.message;}finally{busy=false;}};card.append(edit,cancel);}manage.append(card);}if(canManage&&!rows.length)manage.append(el('p','No events in this register.'));for(const field of form.elements)if(field!==promotion&&!promotion.contains(field))field.disabled=!canManage;}
|
||||
async function load(){try{if(kind==='clan'&&!scopeId){const clans=await api.request('/api/clans');scopeId=clans.membership?.clan_id||null;}const query=kind&&scopeId?'?'+new URLSearchParams({kind,id:scopeId}):'';const data=await api.request('/api/jarvis/events'+query);if(!active)return;rows=data.events;canManage=!!data.canManage;status.textContent=rows.length?'J.A.R.V.I.S. event register · times shown in UTC.':'No published events in this calendar.';draw();}catch(e){if(active){status.textContent=e.message;canManage=false;draw();}}}
|
||||
scope.onchange=draw;form.onsubmit=async e=>{e.preventDefault();if(busy||!canManage||!form.reportValidity())return;pending||={action:editing?'update':'create',kind,scopeId,requestId:crypto.randomUUID(),...(editing?{id:editing.id,revision:editing.revision}:{}),title:title.value,description:description.value,startsAt:Date.parse(start.value+'Z'),endsAt:Date.parse(end.value+'Z'),confirmed:check.checked};busy=true;save.disabled=true;try{await api.request('/api/jarvis/events',pending);if(!active)return;pending=null;editing=null;form.reset();save.textContent='Publish event';feedback.textContent='Event saved.';await load();activate('manage');}catch(error){feedback.textContent=error.message;if(error.uncertain){for(const field of form.elements)field.disabled=true;feedback.textContent+=' Reload the page to verify the register before retrying.';}else pending=null;}finally{busy=false;if(active&&!pending)save.disabled=!canManage;}};
|
||||
void calendarLibrary().then(({Calendar})=>{if(!active)return;calendar=new Calendar(calendarHost,{initialView:'dayGridMonth',timeZone:'UTC',height:'auto',headerToolbar:{left:'prev,next today',center:'title',right:'dayGridMonth,timeGridWeek,listMonth'},events:eventData(),editable:false,eventClick:({event})=>{const r=rows.find(r=>r.id===event.id);if(r)details.replaceChildren(el('h3',r.title),el('p',r.description),el('code',r.reference));}});calendar.render();}).catch(e=>{if(active)calendarHost.textContent=e.message;});void load();return()=>{active=false;controller.abort();calendar?.destroy();root.remove();};
|
||||
}
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
.exchange-card{min-width:0;display:flex;flex-direction:column;border:1px solid #8f824f;border-radius:12px;background:linear-gradient(135deg,#163d36,#082622);padding:18px;color:#e9e0c7;overflow:hidden;box-shadow:0 5px 15px #0003}.exchange-card header{display:flex;gap:10px;justify-content:space-between;align-items:center;margin-bottom:14px}.exchange-card small{font:500 11px/1.6 Arial,sans-serif;color:#b6c6b5;letter-spacing:.07em}.exchange-card-body{display:flex;gap:18px;align-items:center;flex:1;min-width:0}.exchange-card-body>img{object-fit:contain;flex:none;width:84px;height:84px;filter:drop-shadow(0 4px 5px #0006)}.exchange-card-copy{min-width:0}.exchange-card h3{font:600 22px/1.3 'Cinzel',Georgia,serif;color:#f1d993;margin:7px 0;overflow-wrap:anywhere}.exchange-card p{font:14px/1.65 Arial,sans-serif;color:#c2cfbf;margin:8px 0}.exchange-card .minecraft-texture{image-rendering:pixelated}.exchange-card-item .exchange-card-body,.exchange-card-kit .exchange-card-body{flex-direction:column;text-align:center}.exchange-card-item .exchange-card-body>img,.exchange-card-kit .exchange-card-body>img{width:100px;height:100px}.exchange-card-facts{display:flex;gap:7px;flex-wrap:wrap;margin:15px 0}.exchange-card-facts span{border:1px solid #8f9c6c55;border-radius:20px;padding:4px 9px;font:11px/1.4 Arial,sans-serif;color:#c3d4c8}.exchange-card footer{display:flex;gap:10px;justify-content:space-between;align-items:center;padding-top:15px;margin-top:15px;border-top:1px solid #b4a36444}.exchange-card footer button{min-height:42px;border:1px solid #a68f50;border-radius:7px;background:#24483b;color:#efdda1;padding:9px 13px;cursor:pointer}.exchange-card footer button:disabled{opacity:.5;cursor:default}.exchange-card-featured{border-color:#ddbc65;box-shadow:inset 0 0 0 3px #c5a35a22,0 6px 18px #0004}.exchange-card-badge{font:700 10px Arial,sans-serif;color:#16291e;background:#d7ba72;padding:6px 9px;border-radius:4px;letter-spacing:.08em;text-transform:uppercase}.exchange-card-campaign{background:linear-gradient(100deg,#122e29ef,#182a28dd),url(https://www.dunerealms.com/assets/political-imperial-chamber-v1.png) center/cover;border-top:3px solid #ccb16b}.exchange-card-campaign .exchange-card-body>img{width:110px;height:110px;border:1px solid #c9a85a;border-radius:50%;padding:10px;background:#0b241f}.exchange-card-campaign h3{font-size:27px}.exchange-card-gallery-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px}.exchange-card-gallery-grid>.exchange-card-campaign{grid-column:span 2}.exchange-card-gallery-note{color:#c7b978;font:13px/1.6 Arial,sans-serif}.exchange-card-gallery{margin:20px 0}.exchange-card-gallery-grid>.exchange-card-job{background:linear-gradient(130deg,#183d47,#122a28)}.exchange-card-gallery-grid>.exchange-card-ad{background:linear-gradient(130deg,#3b3547,#162d2a)}@media(max-width:1000px){.exchange-card-gallery-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}@media(max-width:600px){.exchange-card-gallery-grid{grid-template-columns:minmax(0,1fr)}.exchange-card-gallery-grid>.exchange-card-campaign{grid-column:auto}.exchange-card-campaign .exchange-card-body{align-items:flex-start}.exchange-card-campaign .exchange-card-body>img{width:70px;height:70px}.exchange-card-campaign h3{font-size:22px}.exchange-card footer{flex-wrap:wrap}}
|
||||
|
||||
.exchange-card-art-sprite{width:90px;height:110px;flex:none;filter:drop-shadow(0 3px 5px #0007)}.exchange-card-art-deed{background:url(https://www.dunerealms.com/assets/organisation-deeds-company-tiers-v1.png) right center/300% 100% no-repeat}.exchange-card-art-key{background:url(https://www.dunerealms.com/assets/organisation-deed-keys-v1.png) left center/200% 100% no-repeat}
|
||||
|
||||
.exchange-card-auction{border:2px solid #bca15d;background:linear-gradient(120deg,#243b37,#102725);box-shadow:inset 0 0 0 3px #bca15d25}.exchange-card-auction h3{font-family:Cinzel,Georgia,serif;color:#efd596}.exchange-card-auction header{border-bottom:1px solid #ac9457}.exchange-card-auction .exchange-card-facts{padding:14px;background:#0c221f;border:1px solid #8c7d4b;border-radius:8px}.exchange-card-auction .exchange-card-body img{width:120px;height:120px;object-fit:contain}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
const asset='https://www.dunerealms.com/assets/';
|
||||
const el=(tag,text,cls)=>{const n=document.createElement(tag);if(text!==undefined)n.textContent=text;if(cls)n.className=cls;return n;};
|
||||
export const CARD_TYPES=Object.freeze({item:{label:'Minecraft item',art:'minecraft-items/diamond_pickaxe.png',action:'View item'},kit:{label:'Equipment kit',art:'minecraft-items/leather_chestplate.png',action:'View kit'},job:{label:'Recruitment',art:'exchange-clan-recruitment-v1.png',action:'View vacancy'},ad:{label:'Advertisement',art:'nav-exchange-v2.webp',action:'View advertisement'},campaign:{label:'Election campaign',art:'seals/emperor-v1.png',action:'View candidature'},quest:{label:'Quest',art:'exchange-quests-v1.png',action:'View quest'},event:{label:'Event',art:'nav-home-v2.webp',action:'View event'},deed:{label:'Registered deed',art:'organisation-deeds-company-tiers-v1.png',action:'View deed'},key:{label:'Charter key',art:'organisation-deed-keys-v1.png',action:'View entitlement'}});
|
||||
export const CARD_TYPES=Object.freeze({auction:{label:'Auction',art:'seals/emperor-v1.png',action:'View auction'},item:{label:'Minecraft item',art:'minecraft-items/diamond_pickaxe.png',action:'View item'},kit:{label:'Equipment kit',art:'minecraft-items/leather_chestplate.png',action:'View kit'},job:{label:'Recruitment',art:'exchange-clan-recruitment-v1.png',action:'View vacancy'},ad:{label:'Advertisement',art:'nav-exchange-v2.webp',action:'View advertisement'},campaign:{label:'Election campaign',art:'seals/emperor-v1.png',action:'View candidature'},quest:{label:'Quest',art:'exchange-quests-v1.png',action:'View quest'},event:{label:'Event',art:'nav-home-v2.webp',action:'View event'},deed:{label:'Registered deed',art:'organisation-deeds-company-tiers-v1.png',action:'View deed'},key:{label:'Charter key',art:'organisation-deed-keys-v1.png',action:'View entitlement'}});
|
||||
export function createListingCard(record,{onOpen=null,preview=false}={}){
|
||||
if(!document.querySelector('link[data-exchange-cards]')){const css=el('link');css.rel='stylesheet';css.href=new URL('./cp-v2-exchange-cards.css',import.meta.url).href;css.dataset.exchangeCards='';document.head.append(css);}
|
||||
const type=Object.hasOwn(CARD_TYPES,record.type)?record.type:'ad',definition=CARD_TYPES[type],card=el('article',undefined,'exchange-card exchange-card-'+type+(record.featured?' exchange-card-featured':''));card.dataset.cardType=type;
|
||||
|
|
@ -11,6 +11,7 @@ export function createListingCard(record,{onOpen=null,preview=false}={}){
|
|||
}
|
||||
export function createCardGallery(){const root=el('section',undefined,'exchange-card-gallery');root.append(el('p','Design examples only · no listings, candidatures, charges or rewards are created.','exchange-card-gallery-note'));const grid=el('div',undefined,'exchange-card-gallery-grid');for(const sample of [
|
||||
{type:'campaign',title:'A voice for the Landsraad',subtitle:'Example candidate · Clan Delegate',message:'A campaign message belongs here, beside the candidate portrait and organisation seal.',featured:true,duration:'1 hour campaign placement',facts:['Clan Delegate','Campaign closes at voting start']},
|
||||
{type:'auction',title:'Office appointment auction',subtitle:'Example office · tied election',message:'A tied election opens a three-hour auction. No real bids are accepted in this design example.',duration:'3 hour auction',facts:['Highest bid: no live bid','Closes: shown when opened']},
|
||||
{type:'item',title:'Diamond Pickaxe',subtitle:'Example seller',message:'Actual Minecraft item artwork.',price:'25.00 DM',facts:['Rare','MK I','Alpha · example edition']},
|
||||
{type:'kit',title:'House Expedition Kit',subtitle:'Clan kit · example',message:'Armour, tools and equipment contents are shown after selection.',price:'75.00 DM',facts:['Clan kit','MK I','Rare']},
|
||||
{type:'job',title:'Join our caravan',subtitle:'Example household',message:'Role, homeworld and vacancy details.',facts:['Recruitment','Apply through J.A.R.V.I.S.']},
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue

Staff