Complete shared People, Rihla, security, event and Realm navigation batch
This commit is contained in:
parent
b6eb59c5eb
commit
c352cc9f2c
62 changed files with 341 additions and 180 deletions
|
|
@ -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>');}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,8 +1,9 @@
|
|||
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;}
|
||||
|
|
@ -24,5 +25,6 @@ export function mountCodexManagement(host,{initial='keys',fetcher=fetch}={}){
|
|||
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});
|
||||
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;}});
|
||||
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();};
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
import {element as el} from './cp-v2-page-template.mjs';
|
||||
export function showInvalidKey(host,message='This key could not be verified.'){const image=el('img');image.src='https://www.dunerealms.com/assets/jarvis-invalid-key-v1.png';image.alt="J.A.R.V.I.S. validation: It's a fake!";image.style.cssText='display:block;width:100%;max-width:620px;height:auto;border-radius:10px;margin:12px 0';host.replaceChildren(image,el('p',message));}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
export const ORGANISATION_MENU_GROUPS=Object.freeze([
|
||||
['Your organisation',[['overview','Dashboard'],['settings','Settings']]],
|
||||
['Organisation affairs',[['boards','Boards'],['elections','Elections'],['advertising','Advertising'],['commerce','Exchange'],['tailor','Tailor']]],
|
||||
['Organisation affairs',[['boards','Boards'],['events','Events'],['elections','Elections'],['advertising','Advertising'],['commerce','Exchange'],['tailor','Tailor']]],
|
||||
['Estates & relations',[['claims','Claims'],['subsidiaries','Subhouses'],['directory','Directory'],['projects','Expeditions'],['campaigns','Campaigns']]]
|
||||
]);
|
||||
export function organisationPage(hash=''){
|
||||
|
|
|
|||
|
|
@ -4,3 +4,5 @@
|
|||
.company-cp-shell #portals,.politics-cp-shell #portals{display:block}.organisation-switcher label{min-width:0}.organisation-switcher select{min-width:0;width:min(440px,100%)}
|
||||
|
||||
.organisation-settings-form{display:grid;gap:16px;margin-top:20px}.organisation-settings-form label{display:grid;gap:8px}.organisation-settings-form input,.organisation-settings-form textarea{box-sizing:border-box;max-width:100%;width:100%;padding:12px;border:1px solid #7d8b60;border-radius:8px;background:#102b25;color:#eadfbf;font:inherit}.organisation-settings-form textarea{min-height:150px;resize:vertical}.organisation-settings-form button{justify-self:start;padding:12px 20px;border:1px solid #bda05c;border-radius:8px;background:#203f39;color:#f1d99a;cursor:pointer}.organisation-settings-form button:disabled{opacity:.5}
|
||||
/* One organisation layout, with the established Company and Political palettes. */
|
||||
.organisation-sidebar-switcher{display:grid!important;justify-items:center;gap:12px;margin:18px 0;padding:18px 10px!important;border:1px solid #b99a51;border-radius:8px;background:transparent!important;box-sizing:border-box}.organisation-sidebar-switcher>img{width:74px;height:74px;object-fit:contain}.organisation-sidebar-switcher label{display:grid;gap:10px;width:100%;font-size:15px;text-align:center}.organisation-sidebar-switcher select{width:100%!important;min-width:0!important;max-width:100%;box-sizing:border-box;font-size:14px}.company-cp-shell .organisation-workspace-hero{background:linear-gradient(90deg,#153d4bee,#102832aa),url('https://www.dunerealms.com/assets/political-imperial-chamber-v1.png') center/cover}.company-cp-shell .organisation-settings-card{background:#15323c;color:#eee4ca;border-color:#a58b52}.company-cp-shell .organisation-settings-card h3{color:#efd49b}.politics-cp-shell .organisation-portal{background:linear-gradient(145deg,#fff5df,#e4cfaa);color:#632f2c;box-shadow:inset 0 0 0 3px #f6ecd8}.politics-cp-shell .organisation-portal[aria-current=page]{background:linear-gradient(135deg,#783d43,#3c1b21);color:#ffedc5}.politics-cp-shell .organisation-workspace-hero{background:linear-gradient(90deg,#632c35ed,#3c1b2177),url('https://www.dunerealms.com/assets/political-imperial-chamber-v1.png') center/cover}.politics-cp-shell .organisation-settings-card{background:#fff8eb;color:#38271f;border-color:#b89756}.politics-cp-shell .organisation-settings-card h3{color:#632f2c}.politics-cp-shell .organisation-settings-form input,.politics-cp-shell .organisation-settings-form textarea{background:#f6ecda;color:#38271f;border-color:#aa8755}.politics-cp-shell .cp-v2-template-tabs{display:flex}.politics-cp-shell .cp-v2-template-tab{background:#f6ecda;color:#632f2c}.politics-cp-shell .cp-v2-template-tab[aria-selected=true]{background:#6b343b;color:#ffedc5}.politics-cp-shell .organisation-sidebar-switcher{color:#632f2c}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import {mountRealmEvents} from './cp-v2-events.mjs';
|
||||
import {mountOfficeResignation} from './cp-v2-office-resign.mjs';
|
||||
import {mountElectionDesign,mountAdvertisingDesign} from './cp-v2-election-design.mjs';
|
||||
import {mountCompanyMailboxSettings} from './cp-v2-company-mailbox.mjs';
|
||||
|
|
@ -21,21 +22,21 @@ export function startOrganisationCP(kind){
|
|||
const company=kind==='company',noun=company?'Company':'Office',prefix=company?'company':'household',outer=company?'https://corp.dunerealms.com':'https://www.dunerealms.com',fallback=company?'guild.webp':'seals/office-landsraad.png';
|
||||
const content=document.querySelector('#content'),left=document.querySelector('#sidebar'),right=document.querySelector('#sidebar-right'),portals=document.querySelector('#portals');let ready=false,records=[],selected=null,user=null,dispose=()=>{},generation=0,routeTurn=0,stopped=false,lastHeight=0;
|
||||
const image=file=>{const n=el('img');n.src=file.startsWith('https://')?file:assets+file;n.alt='';return n;};
|
||||
const reference=()=>{const a=el('a','Open previous '+noun+' CP · reference ↗','organisation-reference');a.href='/'+(company?'company':'politics')+'-cp-reference';a.target='_blank';a.rel='noopener';return a;};
|
||||
const go=id=>{location.hash=prefix+'/'+id;};
|
||||
function measure(){if(stopped||parent===window)return;const height=Math.ceil(document.body.getBoundingClientRect().height)+2;if(height!==lastHeight&&height>=100&&height<=200000){lastHeight=height;parent.postMessage({type:'dune-embed-size',height},outer);}}
|
||||
const observer=new ResizeObserver(()=>requestAnimationFrame(measure));observer.observe(document.body);const onMeasure=e=>{if(e.source===parent&&e.origin===outer&&e.data?.type==='dune-embed-measure')measure();};window.addEventListener('message',onMeasure);
|
||||
const mapCompanies=data=>data.companies.map(c=>({...c,emblem:c.emblem||assets+'guild.webp',members:c.members||[...new Set([c.founder_name,c.ceo_name].filter(Boolean))].map(username=>({username,role:'leadership'}))}));
|
||||
const route=()=>organisationPage(location.hash);
|
||||
const onRoute=()=>{if(!company||!ready){render();return;}const turn=++routeTurn;dispose();dispose=()=>{};content.replaceChildren(el('p','Opening your company…'));const id=new URL(location.href).searchParams.get('company');fetch('/api/companies/workspace'+(id?'?company='+encodeURIComponent(id):''),{credentials:'same-origin',cache:'no-store'}).then(async response=>{const data=await response.json();if(!response.ok)throw Error(data.message||'Company workspace unavailable.');if(stopped||turn!==routeTurn)return;records=mapCompanies(data);selected=data.selected;render();}).catch(error=>{if(!stopped&&turn===routeTurn)content.replaceChildren(el('p',error.message));});};
|
||||
function pending(host,title,copy){const box=el('section',undefined,'organisation-settings-card');box.append(el('h3',title),el('p',copy),reference());host.append(box);}
|
||||
function pending(host,title,copy){const box=el('section',undefined,'organisation-settings-card');box.append(el('h3',title),el('p',copy));host.append(box);}
|
||||
function render(){
|
||||
if(!ready||stopped)return;dispose();dispose=()=>{};const turn=++generation,record=records.find(r=>r.id===selected),page=route()||'overview';
|
||||
left.replaceChildren(el('div',company?'YOUR COMPANY':'YOUR POLITICAL HOUSE','side-hero'));right.replaceChildren(el('div',company?'COMPANY DIRECTORY':'POLITICAL HOUSES','side-hero'));portals.replaceChildren();portals.hidden=false;portals.classList.remove('organisation-switcher');const tiles=el('div',undefined,'organisation-portals');for(const [id,title,art,href] of [['overview',company?'My Company':'My Political House',record?.emblem||fallback],['quests','Quests','nav-manual-v2.webp','https://www.dunerealms.com/exchange.html?type=quests'],['tailor','Kits',company?'minecraft-items/iron_pickaxe.png':'items/office_water.png','https://www.dunerealms.com/exchange.html?type=kits-'+(company?'clan':'office')],['campaigns','Events',company?'nav-home-v2.webp':'seals/emperor-v1.png']]){const a=el('a',undefined,'organisation-portal');a.href=href||'#'+prefix+'/'+id;if(href)a.target='_top';a.append(image(art),el('strong',title));if(id===page)a.setAttribute('aria-current','page');tiles.append(a);}portals.append(tiles);
|
||||
const label=el('label',company?'Your companies':'Political Houses'),select=el('select');select.setAttribute('aria-label',company?'Choose your company':'Choose a political House');for(const r of records){const option=el('option',r.name);option.value=r.id;select.append(option);}if(!records.length){const option=el('option','No verified organisation available');option.value='';select.append(option);}select.value=selected||'';select.disabled=!records.length;select.onchange=()=>{selected=select.value;const u=new URL(location.href);u.searchParams.set(company?'company':'office',selected);history.replaceState(null,'',u);render();};label.append(select);const selector=el('div',undefined,'organisation-switcher');selector.append(image(record?.emblem||fallback),label);portals.append(selector);
|
||||
for(let i=0;i<groups.length;i++){const [heading,items]=groups[i],host=i<2?left:right,block=el('section',undefined,'category-block'),links=el('div',undefined,'category-links');block.append(el('div',heading,'category-heading'));for(const[id,title]of items){const a=el('a',title==='Subhouses'&&company?'Subsidiaries':title,'navitem');a.href='#'+prefix+'/'+id;a.dataset.menuHref=(company?outer+'/':outer+'/government.html')+a.getAttribute('href');if(id===page)a.setAttribute('aria-current','page');links.append(a);}block.append(links);host.append(block);}left.append(reference());
|
||||
const label=el('label',company?'Your companies':'Political Houses'),select=el('select');select.setAttribute('aria-label',company?'Choose your company':'Choose a political House');for(const r of records){const option=el('option',r.name);option.value=r.id;select.append(option);}if(!records.length){const option=el('option','No verified organisation available');option.value='';select.append(option);}select.value=selected||'';select.disabled=!records.length;select.onchange=()=>{selected=select.value;const u=new URL(location.href);u.searchParams.set(company?'company':'office',selected);history.replaceState(null,'',u);render();};label.append(select);const selector=el('div',undefined,'organisation-switcher');selector.append(image(record?.emblem||fallback),label);selector.classList.add('organisation-sidebar-switcher');
|
||||
for(let i=0;i<groups.length;i++){const [heading,items]=groups[i],host=i<2?left:right,block=el('section',undefined,'category-block'),links=el('div',undefined,'category-links');block.append(el('div',heading,'category-heading'));for(const[id,title]of items){const a=el('a',title==='Subhouses'&&company?'Subsidiaries':title,'navitem');a.href='#'+prefix+'/'+id;a.dataset.menuHref=(company?outer+'/':outer+'/government.html')+a.getAttribute('href');if(id===page)a.setAttribute('aria-current','page');links.append(a);}block.append(links);host.append(block);}left.append(selector);
|
||||
const hero=el('header',undefined,'hero organisation-workspace-hero'),copy=el('div');copy.append(el('small',company?'SPACING GUILD · COMMERCIAL AFFAIRS':'IMPERIAL HOUSES · OFFICE DEEDS'),el('h1',record?.name||noun+' Dashboard'),el('p',company?'Your enterprise, its people and its next chapter.':'Protected Houses · membership follows current office deeds.'));hero.append(image(record?.emblem||fallback),copy);
|
||||
const cards=el('div',undefined,'cards'),card=el('article',undefined,'card full citizen-page-full'),host=el('div',undefined,'citizen-live-host clan-center');card.append(host);cards.append(card);content.replaceChildren(hero,cards);
|
||||
if(page==='events'){dispose=mountRealmEvents(host,{kind,scopeId:record.id});return;}
|
||||
if(page==='elections'){dispose=mountElectionDesign(host,{context:company?'company':'citizen'});return;}
|
||||
if(page==='advertising'){dispose=mountAdvertisingDesign(host,{context:kind});return;}
|
||||
if(page==='directory'){dispose=mountOrganisationRegister(host,kind);return;}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export function mountPersonalRecords(host,{fetcher=fetch}={}){
|
|||
biography.append(el('h4','Your character identity'));social.append(el('h4','Social connections'));privacy.append(el('h4','Birthday preferences'));
|
||||
function field(parent,key,label,type='text',limit=500){const box=el('label',label),input=el(type==='textarea'?'textarea':'input');if(type!=='textarea')input.type=type;input.maxLength=limit;input.name=key;box.append(input);parent.append(box);fields[key]=input;return input;}
|
||||
field(biography,'displayName','Character name','text',40).required=true;biography.append(el('p','Your chosen character name. Titles and house names are added automatically; your Minecraft username stays unchanged.'));field(biography,'bio','Biography','textarea',1000);field(biography,'publicInfo','Other public information','textarea',500);
|
||||
const presentationRadios={};for(const [key,title,help]of [['ownerDefault','Owner default','Your fictional Owner title form and the default Owner example portrait.'],['consortPortrait','Consort default','The default Consort example portrait. An actual Consort appointment always takes priority.'],['heirDefault','Heir default','The default Heir example portrait. An actual Heir appointment always takes priority.']]){const box=el('fieldset',undefined,'cp-v2-consort-preference');box.append(el('legend',title),el('p',help+' These are fictional presentation preferences, not your real gender or sexual orientation.'));presentationRadios[key]=[];for(const [value,labelText]of [['male','Male'],['female','Female'],['neutral','Neutral']]){const label=el('label'),radio=el('input');radio.type='radio';radio.name=key;radio.value=value;radio.checked=value===(key==='consortPortrait'?'female':'male');label.append(radio,el('span',labelText));box.append(label);presentationRadios[key].push(radio);}biography.append(box);}
|
||||
const presentationRadios={},wrap=el('div',undefined,'presentation-table-wrap'),table=el('table',undefined,'presentation-table'),caption=el('caption','Fictional portrait & title defaults'),thead=el('thead'),header=el('tr'),tbody=el('tbody');biography.append(el('p','Fictional presentation only, independent of your real gender or orientation. Actual Heir and Consort appointments take priority.'));for(const title of ['Role','Male','Female','Neutral']){const th=el('th',title);th.scope='col';header.append(th);}thead.append(header);for(const [key,title]of [['ownerDefault','Owner'],['consortPortrait','Consort'],['heirDefault','Heir']]){presentationRadios[key]=[];const row=el('tr'),name=el('th',title);name.scope='row';row.append(name);for(const value of ['male','female','neutral']){const td=el('td'),label=el('label'),radio=el('input');radio.type='radio';radio.name=key;radio.value=value;radio.setAttribute('aria-label',title+' · '+value);radio.checked=value===(key==='consortPortrait'?'female':'male');label.append(radio);td.append(label);row.append(td);presentationRadios[key].push(radio);}tbody.append(row);}table.append(caption,thead,tbody);wrap.append(table);biography.append(wrap);if(!document.querySelector('style[data-presentation-table]')){const style=el('style');style.dataset.presentationTable='';style.textContent='.presentation-table-wrap{overflow:auto}.presentation-table{width:100%;border-collapse:collapse;margin:18px 0}.presentation-table caption{text-align:left;font-weight:bold;margin-bottom:12px}.presentation-table th,.presentation-table td{padding:8px 12px;border-bottom:1px solid #b99a5155}.presentation-table td{text-align:center}.presentation-table label{display:flex!important;align-items:center;justify-content:center;min-height:44px;margin:0!important;cursor:pointer}.presentation-table input[type=radio]{width:20px!important;height:20px!important;margin:0!important;accent-color:#c5a25a}';document.head.append(style);}
|
||||
for(const [key,label]of Object.entries(labels))field(social,key,label,'url');
|
||||
field(privacy,'birthday','Birthday','date');const publicBirthday=field(privacy,'publicBirthday','Display birthday on my public profile','checkbox');
|
||||
const save=el('button','Save personal records');save.type='submit';fieldset.append(biography,social,privacy,save);form.append(fieldset);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import {mountRealmEvents} from './cp-v2-events.mjs';
|
||||
import {mountElectionDesign,mountAdvertisingDesign} from './cp-v2-election-design.mjs';
|
||||
import {mountExchangeDesign} from './cp-v2-exchange-design.mjs';
|
||||
import {mountPatronage} from './cp-v2-patronage.mjs';
|
||||
|
|
@ -7,6 +8,7 @@ import {element as el} from './cp-v2-page-template.mjs';
|
|||
import {mountNativeService} from './cp-v2-native-services.mjs';
|
||||
import {mountUserPage} from './cp-v2-user-pages.mjs';
|
||||
export function mountPlayWorkspace(host,workspace,id,options={}){
|
||||
if(workspace==='events'||workspace==='clan'&&id==='clan-events')return mountRealmEvents(host,{kind:workspace==='clan'?'clan':null,fetcher:options.fetcher||fetch});
|
||||
if(workspace==='clan'&&id==='clan-elections')return mountElectionDesign(host,{context:'clan'});
|
||||
if(workspace==='clan'&&id==='clan-advertising')return mountAdvertisingDesign(host,{context:'clan'});
|
||||
if(workspace==='clan'){if(['clan-shop','clan-listings','clan-post-listing'].includes(id))return mountExchangeDesign(host,{context:'clan',view:id==='clan-listings'?'mine':id==='clan-post-listing'?'post':'browse',fetcher:options.fetcher||fetch});if(id==='clan-boards')return mountNativeService(host,'clan-boards',{...options,singleHeading:true});if(id==='clan-patronage')return mountPatronage(host);if(id==='clan-claims')return mountClaims(host,{kind:'clan',fetcher:options.fetcher||fetch,clanId:new URLSearchParams(location.hash.split('?')[1]||'').get('clientclan')||options.accountId||null});if(id==='clan-subhouses'){const panel=el('section',undefined,'claims-workspace');panel.append(el('h2','Subhouses'),el('p','Clan allegiance, independence and rebellion are coming soon. Subhouses retain their identity, land and local access; political powers and final authority belong to the ruling clan.'),el('strong','Coming soon'));for(const title of ['Buy Independence','Rebel']){const button=el('button',title);button.type='button';button.disabled=true;panel.append(button);}host.replaceChildren(panel);return()=>panel.remove();}if(id==='clan-bank')return mountClanBank(host,options);
|
||||
|
|
|
|||
|
|
@ -64,3 +64,6 @@ export function mountPostbankPayments(host,page,{fetcher=fetch,accountId=null}={
|
|||
}
|
||||
void load();return()=>{active=false;controller.abort();window.removeEventListener('beforeunload',beforeUnload);frame.root.remove();};
|
||||
}
|
||||
|
||||
// Shared statement presentation, with each domain controlling its own private projection.
|
||||
export function createStatementTable(headings,rows){const wrap=el('div',undefined,'pb-ledger-scroll'),table=el('table',undefined,'pb-ledger'),head=el('thead'),header=el('tr'),body=el('tbody');for(const title of headings){const th=el('th',title);th.scope='col';header.append(th);}head.append(header);for(const values of rows){const row=el('tr');for(const value of values)row.append(el('td',String(value??'')));body.append(row);}table.append(head,body);wrap.append(table);return wrap;}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ export const ELECTION_DESIGN_TYPES=Object.freeze({clan_delegate:{name:'Clan Dele
|
|||
let libraryPromise;
|
||||
function script(file){return new Promise((resolve,reject)=>{const node=el('script');node.src=new URL('./vendor/fullcalendar/'+file,import.meta.url).href;node.onload=resolve;node.onerror=()=>reject(Error('Calendar library unavailable.'));document.head.append(node);});}
|
||||
export function electionDesignStyles(){if(document.querySelector('link[data-election-design]'))return;for(const file of ['./cp-v2-election-design.css','./vendor/fullcalendar/skeleton.css','./vendor/fullcalendar/monarch.css','./vendor/fullcalendar/palette.css']){const css=el('link');css.rel='stylesheet';css.href=new URL(file,import.meta.url).href;css.dataset.electionDesign='';document.head.append(css);}}
|
||||
async function calendarLibrary(){electionDesignStyles();if(!libraryPromise)libraryPromise=script('fullcalendar.global.min.js').then(()=>script('monarch.global.min.js')).then(()=>globalThis.FullCalendar);return libraryPromise;}
|
||||
export async function calendarLibrary(){electionDesignStyles();if(!libraryPromise)libraryPromise=script('fullcalendar.global.min.js').then(()=>script('monarch.global.min.js')).then(()=>globalThis.FullCalendar);return libraryPromise;}
|
||||
export function mountPromotionAgenda(host,{election='clan_delegate',organisationKind='clan',remindersOnly=false}={}){
|
||||
electionDesignStyles();const company=organisationKind==='company',generic=election==='clan-promotion',definition=ELECTION_DESIGN_TYPES[election];if(!generic&&!definition)throw Error('Choose a known election agenda.');
|
||||
const kind=definition?.kind||'clan_delegate',start=electionDates(kind,Date.now(),1)[0],votingStart=new Date(start),campaignStart=new Date(votingStart.getTime()-7*86400000),initial=generic?new Date():new Date(campaignStart);initial.setUTCHours(0,0,0,0);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import {showInvalidKey} from './cp-v2-key-validation.mjs';
|
||||
import {organisationCodeIs,parseOrganisationCode} from '../codex-code-format.mjs';
|
||||
import {createCodeTypeIcon} from './cp-v2-code-type-icon.mjs';
|
||||
import {createCPV2Page,element as el} from './cp-v2-page-template.mjs';
|
||||
|
|
@ -37,6 +38,6 @@ export function mountRewards(host,{fetcher=fetch,initialTab}={}){
|
|||
status.textContent=data.every(row=>row.status==='fulfilled')?'Your private reward records are loaded.':'Some reward services are unavailable. Other records remain visible.';
|
||||
}catch(error){if(active){status.textContent=error.message;groups.clear();paintCodes();orders=[];community.replaceChildren();tokens.replaceChildren();uncertain=true;}}finally{busy=false;if(active){refresh.disabled=false;desk.setLocked(uncertain);}}
|
||||
}
|
||||
form.onsubmit=async event=>{event.preventDefault();if(busy||uncertain)return;let payload;try{const code=desk.reviewedCode();if(organisationCodeIs(code,'CLAN')){payload={kind:'clan',code};}else payload=redemptionRequest(code,check.checked);}catch(error){result.textContent=error.message;return;}busy=true;refresh.disabled=true;desk.setLocked(true);result.textContent='Presenting your code…';try{if(payload.kind==='clan'){const membership=(await request('/api/clans')).membership;if(!membership)throw Error('Create your Basic clan first, then return here to use your key.');const detail=await request('/api/clans/'+encodeURIComponent(membership.clan_id));if(detail.role!=='owner'||!detail.canManage)throw Error('Only the current linked owner can upgrade their Basic clan.');if(detail.clan.charterKind!=='basic')throw Error('Your clan already has an Original or Royal charter.');payload.path='/api/organisation-keys';payload.body={code:payload.code,clanId:membership.clan_id,version:detail.clan.version,requestId:crypto.randomUUID(),confirmed:true};}const d=await request(payload.path,payload.body);if(payload.kind==='clan'&&(d.ok!==true||d.charter!=='original'||d.clanId!==payload.body.clanId))throw Object.assign(Error('Clan upgrade was not confirmed. Refresh your codes before retrying.'),{uncertain:true});if(!active)return;if(payload.kind==='discovery'&&(d.ok!==true||typeof d.credited!=='boolean'||d.amount!==1000))throw Object.assign(Error('Discovery credit was not confirmed.'),{uncertain:true});if(payload.kind==='kit'&&!['queued','delivered','pending','claimed','redeemed','pending_delivery'].includes(d.status))throw Object.assign(Error('The delivery result was not confirmed.'),{uncertain:true});desk.reset();busy=false;await load();if(active)result.textContent=payload.kind==='clan'?'Your clan is now an Original House. Its founding key has been used; Royal status still requires a political appointment.':payload.kind==='kit'?(d.status==='delivered'?'Delivery is already confirmed by the game.':'Delivery requested. Join a planetary server with four empty inventory slots; the game confirms arrival.'):(d.credited?'Your earned 1,000 DM reward was credited.':'This reward was already redeemed; no duplicate credit was made.');}catch(error){if(active){uncertain=!!error.uncertain;result.textContent=error.message+(uncertain?' Refresh your codes and check the result before retrying.':'');}}finally{busy=false;if(active){refresh.disabled=false;desk.setLocked(uncertain);}}};
|
||||
form.onsubmit=async event=>{event.preventDefault();if(busy||uncertain)return;let payload;try{const code=desk.reviewedCode();if(organisationCodeIs(code,'CLAN')){payload={kind:'clan',code};}else payload=redemptionRequest(code,check.checked);}catch(error){result.textContent=error.message;return;}busy=true;refresh.disabled=true;desk.setLocked(true);result.textContent='Presenting your code…';try{if(payload.kind==='clan'){const membership=(await request('/api/clans')).membership;if(!membership)throw Error('Create your Basic clan first, then return here to use your key.');const detail=await request('/api/clans/'+encodeURIComponent(membership.clan_id));if(detail.role!=='owner'||!detail.canManage)throw Error('Only the current linked owner can upgrade their Basic clan.');if(detail.clan.charterKind!=='basic')throw Error('Your clan already has an Original or Royal charter.');payload.path='/api/organisation-keys';payload.body={code:payload.code,clanId:membership.clan_id,version:detail.clan.version,requestId:crypto.randomUUID(),confirmed:true};}const d=await request(payload.path,payload.body);if(payload.kind==='clan'&&(d.ok!==true||d.charter!=='original'||d.clanId!==payload.body.clanId))throw Object.assign(Error('Clan upgrade was not confirmed. Refresh your codes before retrying.'),{uncertain:true});if(!active)return;if(payload.kind==='discovery'&&(d.ok!==true||typeof d.credited!=='boolean'||d.amount!==1000))throw Object.assign(Error('Discovery credit was not confirmed.'),{uncertain:true});if(payload.kind==='kit'&&!['queued','delivered','pending','claimed','redeemed','pending_delivery'].includes(d.status))throw Object.assign(Error('The delivery result was not confirmed.'),{uncertain:true});desk.reset();busy=false;await load();if(active)result.textContent=payload.kind==='clan'?'Your clan is now an Original House. Its founding key has been used; Royal status still requires a political appointment.':payload.kind==='kit'?(d.status==='delivered'?'Delivery is already confirmed by the game.':'Delivery requested. Join a planetary server with four empty inventory slots; the game confirms arrival.'):(d.credited?'Your earned 1,000 DM reward was credited.':'This reward was already redeemed; no duplicate credit was made.');}catch(error){if(active){uncertain=!!error.uncertain;result.textContent=error.message+(uncertain?' Refresh your codes and check the result before retrying.':'');if(!uncertain&&payload?.kind==='clan')try{const validation=await request('/api/jarvis/validate',{code:payload.code});if(active&&validation.state==='invalid')showInvalidKey(result,error.message+' · Support case '+validation.caseId);}catch{}}}finally{busy=false;if(active){refresh.disabled=false;desk.setLocked(uncertain);}}};
|
||||
refresh.onclick=()=>void load();void load();return()=>{active=false;controller.abort();input.value='';orders=[];root.remove();};
|
||||
}
|
||||
|
|
|
|||
13
website/control-panel/public/cp-v2/cp-v2-rihla.mjs
Normal file
13
website/control-panel/public/cp-v2/cp-v2-rihla.mjs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import {element as el,createCPV2ContentPage} from './cp-v2-page-template.mjs';
|
||||
import {createUserAPI} from './cp-v2-user-api.mjs';
|
||||
import {createStatementTable} from './cp-v2-postbank-payments.mjs';
|
||||
export function mountRihla(host,{fetcher=fetch}={}){
|
||||
const controller=new AbortController(),api=createUserAPI(fetcher,controller.signal);let active=true,page=1,busy=false;
|
||||
const frame=createCPV2ContentPage({host,title:'Rihla Transfers',description:'Your private Rihla account and transfer statement.',artwork:'corrino-group-v4.png',reload:()=>void load()});
|
||||
const identity=el('header',undefined,'pb-box rihla-brand'),brand=el('img');brand.src='https://www.dunerealms.com/assets/rihla-brand-v1.png';brand.alt='Rihla Money Transfer · part of Corrino Group';identity.append(brand);
|
||||
const privacy=el('aside',undefined,'pb-box');privacy.append(el('h4','Your privacy'),el('p','Only the sender and recipient can view their own Rihla transfers. Staff have no Rihla payment overview. Backend records are retained for balances, payouts and duplicate-redemption checks; server and database administrators can technically access those records.'));
|
||||
const record=el('section',undefined,'pb-box');frame.content.append(identity,record,privacy,el('p','Cash withdrawals and deposits use the in-game ATM. Sending and collecting Rihla transfers use the separate in-game Rihla service. The website is read-only.','pb-muted'));const rates=el('a','Rates & Charges');rates.href='https://www.dunerealms.com/rates-and-charges.html#rihla';rates.target='_top';frame.content.append(rates);frame.diagnostics.textContent='Rihla · private owner-only account · no bank package';
|
||||
if(!document.querySelector('style[data-rihla]')){const style=el('style');style.dataset.rihla='';style.textContent='.rihla-brand{padding:0;overflow:hidden}.rihla-brand>img{display:block;width:100%;height:auto;aspect-ratio:1536/650;object-fit:cover;object-position:top}.rihla-brand>strong{font:800 48px/1 system-ui;color:#f15a24;letter-spacing:-3px}.rihla-brand>a{margin-left:auto;display:flex;align-items:center;gap:10px}';document.head.append(style);}
|
||||
async function load(){if(busy)return;busy=true;frame.reloadButton.disabled=true;frame.status.hidden=false;frame.status.textContent='Opening your Rihla statement…';try{const data=await api.request('/api/rihla?'+new URLSearchParams({page:String(page)}));if(!active)return;record.replaceChildren(el('h4',data.account.number),el('strong',data.account.balance+' DM'),el('p','Available: '+data.account.available+' DM','pb-muted'));record.append(createStatementTable(['Transaction number','Sender','Recipient','Amount · DM','Status'],data.transactions.map(t=>[t.number,t.sender,t.recipient,t.amount,({created:'Created',paid:'Paid',cancelled:'Cancelled'})[t.status]||t.status])));if(!data.transactions.length)record.append(el('p','No Rihla transfers recorded.'));const nav=el('nav',undefined,'pb-ledger-pagination');for(const [label,delta,disabled]of [['Previous',-1,page===1],['Next',1,!data.hasMore]]){const button=el('button',label);button.type='button';button.disabled=disabled;button.onclick=()=>{page+=delta;void load();};nav.append(button);}record.append(nav);frame.status.hidden=true;}catch(error){if(active)frame.status.textContent=error.message;}finally{busy=false;if(active)frame.reloadButton.disabled=false;}}
|
||||
void load();return()=>{active=false;controller.abort();frame.root.remove();};
|
||||
}
|
||||
1
website/control-panel/public/cp-v2/cp-v2-security.css
Normal file
1
website/control-panel/public/cp-v2/cp-v2-security.css
Normal file
|
|
@ -0,0 +1 @@
|
|||
.security-page .cp-v2-personal-box{padding:clamp(16px,3vw,30px);border:0;border-radius:0;background:transparent}.security-page .cp-v2-personal-box>h4{font-size:1.35rem;margin:0 0 12px}.security-page .cp-v2-personal-box>p{max-width:76ch;line-height:1.6}.security-page fieldset{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px;border:0;padding:0;margin:24px 0}.security-page label{display:flex;flex-direction:column;gap:8px;margin:0;font:500 15px/1.5 system-ui}.security-page label>span{color:#e4d4ac}.security-page input:not([type=checkbox]){box-sizing:border-box;width:100%;min-width:0;padding:12px 14px;border:1px solid #64775b;border-radius:8px;background:#0c261e;color:#f0e6ce;font:inherit}.security-page input:-webkit-autofill{-webkit-text-fill-color:#f0e6ce;-webkit-box-shadow:0 0 0 1000px #183d30 inset}.security-page .security-check{grid-column:1/-1;flex-direction:row;align-items:flex-start;gap:12px}.security-page input[type=checkbox]{width:20px;height:20px;flex:none;margin:2px 0 0;accent-color:#c4a257}.security-page fieldset>button{grid-column:1/-1;justify-self:start;margin:4px 0 0}.security-page button{min-height:44px;padding:10px 20px}.security-page [role=status]{color:#d6c38e}.security-page details{margin-top:20px;max-width:76ch}.security-page [hidden]{display:none!important}@media(max-width:650px){.security-page fieldset{grid-template-columns:1fr}.security-page .cp-v2-template-tabs{display:flex;flex-wrap:wrap}.security-page .cp-v2-template-tab{flex:1;min-width:140px}}
|
||||
|
|
@ -18,7 +18,7 @@ export function mountSecurity(host,{fetcher=fetch}={}){
|
|||
const passwordBox=el('section',undefined,'cp-v2-personal-box'),contactBox=el('section',undefined,'cp-v2-personal-box'),body=el('div');body.append(passwordBox,contactBox);
|
||||
const passwordForm=el('form'),passwordFields=el('fieldset');passwordFields.disabled=true;
|
||||
passwordBox.append(el('h4','Website password'),el('p','Changing your password signs out your other website sessions. Your mailbox password remains separate.'));
|
||||
function input(parent,title,type='text'){const label=el('label',title),field=el('input');field.type=type;label.append(field);parent.append(label);return field;}
|
||||
function input(parent,title,type='text'){const label=el('label'),caption=el('span',title),field=el('input');field.type=type;if(type==='checkbox'){label.className='security-check';label.append(field,caption);}else label.append(caption,field);parent.append(label);return field;}
|
||||
const current=input(passwordFields,'Current website password','password'),fresh=input(passwordFields,'New password · at least 12 characters','password');current.autocomplete='current-password';fresh.autocomplete='new-password';current.required=fresh.required=true;current.maxLength=fresh.maxLength=256;fresh.minLength=12;
|
||||
const passwordConsent=input(passwordFields,'I confirm changing my website password.','checkbox');passwordConsent.required=true;
|
||||
const passwordSave=el('button','Change password & sign out other sessions');passwordSave.type='submit';const passwordStatus=el('p');passwordStatus.setAttribute('role','status');passwordFields.append(passwordSave);passwordForm.append(passwordFields);passwordBox.append(passwordForm,passwordStatus);
|
||||
|
|
@ -26,16 +26,16 @@ export function mountSecurity(host,{fetcher=fetch}={}){
|
|||
contactBox.append(el('h4','Support notification email'),el('p','Add a private contact for ticket updates. Ownership must be verified before notifications use it. This does not change your website login.'),mailStatus,mailBody,reload);
|
||||
const bankBox=el('section',undefined,'cp-v2-personal-box');body.append(bankBox);
|
||||
async function loadPaymentSecurity(){
|
||||
bankBox.replaceChildren(el('h4','Instant payment secret'));const status=el('p','Loading payment security…');status.setAttribute('role','status');const reloadBank=el('button','Reload payment security');reloadBank.type='button';reloadBank.onclick=()=>void loadPaymentSecurity();bankBox.append(status,reloadBank);
|
||||
try{const data=await request('/api/bank/transfer-security');if(!active)return;status.textContent=(data.configured?'Separate secret configured. ':'No payment secret configured. ')+(data.enabled?'Required for instant transfers above '+data.threshold+' DM.':'Extra payment-secret protection is disabled.');
|
||||
bankBox.append(el('p','This secret is separate from your website password. Changing the secret, its threshold or disabling protection requires the current secret. If forgotten, use Standard transfers and contact Support.'));
|
||||
const form=el('form'),fields=el('fieldset'),enabled=input(fields,'Protect instant payments above my threshold','checkbox'),threshold=input(fields,'Instant payment threshold · DM','number'),website=input(fields,'Current website password','password'),old=input(fields,'Current payment secret','password'),fresh=input(fields,'New payment secret · leave blank to keep it','password'),consent=input(fields,'I confirm these payment-security settings.','checkbox');
|
||||
enabled.checked=data.enabled;threshold.value=data.threshold;threshold.min='0';threshold.max='1000000';threshold.step='0.01';threshold.required=true;website.autocomplete='current-password';website.required=true;old.autocomplete='off';old.required=data.configured;fresh.autocomplete='new-password';fresh.minLength=12;website.maxLength=old.maxLength=fresh.maxLength=256;consent.required=true;const updateRequired=()=>{fresh.required=enabled.checked&&!data.configured;};enabled.onchange=updateRequired;updateRequired();const save=el('button','Save payment security');save.type='submit';fields.append(save);form.append(fields);bankBox.append(form);
|
||||
bankBox.replaceChildren(el('h4','Payment & ATM protection'));const status=el('p','Loading payment security…');status.setAttribute('role','status');const reloadBank=el('button','Reload payment security');reloadBank.type='button';reloadBank.onclick=()=>void loadPaymentSecurity();bankBox.append(status,reloadBank);
|
||||
try{const data=await request('/api/bank/transfer-security');if(!active)return;status.textContent=(data.configured?'Payment secret set. ':'No payment secret set. ')+(data.enabled?'Required for instant transfers above '+data.threshold+' DM.':'Extra payment-secret protection is disabled.');
|
||||
bankBox.append(el('p','One shared threshold for instant bank payments and future ATM cash withdrawals. Rihla is separate. ATM enforcement will be connected with the in-game ATM. This is a security check, not a spending cap.'));
|
||||
const form=el('form'),fields=el('fieldset'),enabled=input(fields,'Require my payment secret above the threshold','checkbox'),threshold=input(fields,'Shared payment / ATM threshold · DM','number'),website=input(fields,'Current website password','password'),old=input(fields,'Current payment secret','password'),fresh=input(fields,'New payment secret · 12+ characters','password'),consent=input(fields,'I confirm these payment-security settings.','checkbox');
|
||||
enabled.checked=data.enabled;threshold.value=data.threshold;threshold.min='0';threshold.max='1000000';threshold.step='0.01';threshold.required=true;website.autocomplete='current-password';website.required=true;old.autocomplete='off';old.required=data.configured;old.closest('label').hidden=!data.configured;fresh.placeholder=data.configured?'Leave blank to keep your existing secret':'Choose a payment secret';fresh.autocomplete='new-password';fresh.minLength=12;website.maxLength=old.maxLength=fresh.maxLength=256;consent.required=true;const updateRequired=()=>{fresh.required=enabled.checked&&!data.configured;};enabled.onchange=updateRequired;updateRequired();const save=el('button','Save payment security');save.type='submit';fields.append(save);form.append(fields);bankBox.append(form);const help=el('details'),summary=el('summary','Forgotten your payment secret?');help.append(summary,el('p','Use Standard bank transfers and contact Support. Changing an existing secret, its threshold or switching protection off requires the current secret.'));bankBox.append(help);
|
||||
form.onsubmit=async event=>{event.preventDefault();if(!form.reportValidity())return;fields.disabled=true;status.textContent='Saving payment security…';try{await request('/api/bank/transfer-security',{websitePassword:website.value,currentSecret:old.value,newSecret:fresh.value,threshold:threshold.value,enabled:enabled.checked,version:data.version,confirmed:consent.checked});website.value=old.value=fresh.value='';await loadPaymentSecurity();}catch(e){status.textContent=e.message;fields.disabled=false;}};
|
||||
}catch(e){if(active)status.textContent=e.message;}
|
||||
}
|
||||
void loadPaymentSecurity();
|
||||
const {root}=createCPV2Page({shellHost:host,title:'Account Security',description:'Protect your website account and manage verified support notifications.',artwork:'nav-account-v2.webp',tabs:[{id:'security',label:'Password & notifications',content:body}]});host.replaceChildren(root);
|
||||
const {root}=createCPV2Page({shellHost:host,title:'Account Security',description:'Protect your website account and manage verified support notifications.',artwork:'nav-account-v2.webp',tabs:[{id:'password',label:'Website password',content:passwordBox},{id:'notifications',label:'Notifications',content:contactBox},{id:'payment-security',label:'Payments & ATM',content:bankBox}]});host.replaceChildren(root);
|
||||
function controls(){passwordFields.disabled=busy||uncertain;reload.disabled=busy;for(const control of mailBody.querySelectorAll('button,input'))control.disabled=busy||uncertain;}
|
||||
async function load(){if(busy)return;busy=true;passwordFields.disabled=true;reload.disabled=true;mailBody.replaceChildren();
|
||||
try{const session=await request('/api/auth/session');if(!session.authenticated)throw Error('Sign in to manage account security.');const data=await request('/api/account/email');if(!active)return;uncertain=false;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ export function mountUserPage(host,id,{fetcher=fetch,initialTab,listingId}={}){
|
|||
let active=true,dispose=()=>{};const controller=new AbortController(),api=createUserAPI(fetcher,controller.signal);
|
||||
host.replaceChildren(el('p','Opening your user workspace…','cp-v2-news-status'));
|
||||
async function mount(){
|
||||
if(id==='rihla'){const {mountRihla}=await import('./cp-v2-rihla.mjs');if(active)dispose=mountRihla(host,{fetcher});return;}
|
||||
if(['item-exchange','item-listings','item-post'].includes(id)){const {mountExchangeDesign}=await import('./cp-v2-exchange-design.mjs');if(active)dispose=mountExchangeDesign(host,{context:'user',view:id==='item-listings'?'mine':id==='item-post'?'post':'browse',fetcher});return;}
|
||||
|
||||
if(id==='citizen-elections'){const {mountElectionDesign}=await import('./cp-v2-election-design.mjs');if(active)dispose=mountElectionDesign(host,{context:'citizen'});return;}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue

Staff