diff --git a/docs/design/PUBLIC-STARPORT-EXCHANGE.md b/docs/design/PUBLIC-STARPORT-EXCHANGE.md new file mode 100644 index 00000000..5bd91ddf --- /dev/null +++ b/docs/design/PUBLIC-STARPORT-EXCHANGE.md @@ -0,0 +1,44 @@ +# Public Starport Exchange design + +The public Exchange follows the approved exchange-gui-concept-v1 reference: +near-black jade panels, antique gold rules, green buttons, four desktop columns +and a cinematic Minecraft starport header. Clan and user CP retain their existing +layout and palette. The new treatment is scoped to the public context. + +Top: Spacing Guild transit reference and existing Guild symbol (Dune lore). +Bottom: Logistics by SPost, part of Corrino Group (DuneRealms lore). +Keep franchise references distinct from original DuneRealms organisations; do not +present the latter as canon or imply official approval. + +All public kit browsing is in the central Exchange. Kits shows all published kits. +Clan Kits filters shopType=clan; Office Kits includes official_sale/faction_sale; +Player Kits includes personal_sale outside clan shops; Legendary Kits labels +server_sale without altering item quality. Clicking a category updates the filter +and shareable URL. Existing catalogue, availability checks and authenticated +checkout remain authoritative. This does not implement kit Codex migration. + +New systems reuse definition -> unique instance -> action-triggered validation +and execution -> history. Server-issued signing proof is required; a client hash +is not authority. Confirm accepted actions immediately, deferring only suitable +durable follow-up work to the ticker. Never send a private signing key to clients. + +## Artwork provenance + +website/web/assets/exchange-starport-header-v2.webp was generated with the built-in +image_gen tool and approved by the user. Original PNG remains in the generated +image library. Delivery asset: 1600px WebP, approximately 116 KiB. + +Final prompt: Wide panoramic production website background only, no UI, text, +logos or frames. Minecraft voxel desert starport at night, domed transit terminal, +cargo platforms, warm gold guidance lights and a vast cylindrical interstellar +carrier at upper right with tiny cargo shuttles. Quiet dark teal negative space at +left. Near-black emerald and blue-green with antique gold and restrained bronze. +Avoid purple, bright orange, neon, medieval castle halls and movie characters. + +leather_chestplate.png and netherite_chestplate.png are unmodified official +Minecraft 1.21.4 textures extracted from the SHA1-verified Mojang client archive +recorded in MINECRAFT-EXCHANGE-TEXTURES.json. Assets belong to Mojang/Microsoft. + +Validation: responsive browser checks at 1400/760/390 pixels; five kit categories +filter the existing catalogue and update URLs; no page errors or new write calls. +CI is required before publication. diff --git a/website/control-panel/public/cp-v2/cp-v2-exchange-design.css b/website/control-panel/public/cp-v2/cp-v2-exchange-design.css index 5f02814b..a09f52c5 100644 --- a/website/control-panel/public/cp-v2/cp-v2-exchange-design.css +++ b/website/control-panel/public/cp-v2/cp-v2-exchange-design.css @@ -1 +1,35 @@ .codex-exchange{color:#eee5cc;min-width:0;font-family:Arial,sans-serif}.codex-exchange-hero{display:flex;align-items:center;gap:20px;padding:25px;background:linear-gradient(110deg,#153b31f0,#102d26e0),url(https://www.dunerealms.com/assets/guild.webp) center/cover;border-bottom:1px solid #ae9657}.codex-exchange-hero>img{width:90px;height:90px;object-fit:contain}.codex-exchange h2,.codex-exchange h3{font-family:Georgia,serif;color:#f0d58d}.codex-exchange h2{font-size:clamp(27px,3vw,40px);margin:10px 0}.codex-exchange small{color:#c4b27a;letter-spacing:.08em}.codex-exchange-notice,.codex-exchange-eligibility{margin:18px;padding:14px;border-left:3px solid #b69a56;background:#213c32;line-height:1.6}.codex-exchange-layout{display:grid;grid-template-columns:190px minmax(0,1fr);gap:20px;padding:18px}.codex-exchange-categories{display:flex;flex-direction:column;gap:7px}.codex-exchange button{font:inherit;min-height:44px;padding:10px 15px;border:1px solid #8f8151;border-radius:7px;background:linear-gradient(120deg,#244b3b,#19382d);color:#eddb9d;cursor:pointer}.codex-exchange button:disabled{opacity:.55;cursor:not-allowed}.codex-exchange button:focus-visible{outline:3px solid #7ec7db}.codex-exchange-categories button{display:flex;align-items:center;gap:10px;text-align:left;padding:10px}.codex-exchange-categories img{width:32px;height:32px;object-fit:contain}.codex-exchange-categories button[aria-pressed=true]{border-color:#f1ca69;background:#40503a}.codex-exchange-main{min-width:0}.codex-exchange-tools{display:flex;flex-wrap:wrap;align-items:end;gap:12px}.codex-exchange-field{display:grid;gap:7px;min-width:0;flex:1 1 145px;color:#d4c18a;font-size:13px}.codex-exchange-field input,.codex-exchange-field select,.codex-exchange-field textarea{box-sizing:border-box;width:100%;min-width:0;padding:12px;background:#102920;color:#eee8d0;border:1px solid #778464;border-radius:6px;font:inherit}.codex-exchange-preview{display:flex;align-items:center;gap:8px;font-size:13px}.codex-exchange-preview input{width:auto}.codex-exchange-status{font-size:13px;line-height:1.6;color:#c3cbb6}.codex-exchange-cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(185px,100%),1fr));gap:15px}.codex-exchange-card{min-width:0;padding:16px;border:1px solid #8a7b4c;border-radius:11px;background:linear-gradient(140deg,#264338e8,#112b24f5);display:flex;flex-direction:column;gap:10px}.codex-exchange-card>img{width:88px;height:88px;object-fit:contain;align-self:center;margin:8px}.codex-exchange-card .minecraft-texture{image-rendering:pixelated;width:64px;height:64px;margin:20px}.codex-exchange-card h3{margin:0;font-size:20px;overflow-wrap:anywhere}.codex-exchange-card p{font-size:13px;color:#bbc7b4;line-height:1.6;margin:0}.codex-exchange-card button{margin-top:auto}.codex-exchange-empty{padding:28px;border:1px dashed #6f7e5d;line-height:1.8;grid-column:1/-1}.codex-exchange-pager{display:flex;align-items:center;justify-content:center;gap:14px;padding:22px}.codex-exchange-legend{margin:18px;padding:16px;border-top:1px solid #727044}.codex-exchange-legend summary{cursor:pointer;color:#e9d398}.codex-exchange-legend>div{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:14px;margin-top:18px}.codex-exchange-legend section{display:grid;grid-template-columns:46px 1fr;gap:5px 10px;font-size:13px}.codex-exchange-legend img{width:42px;height:42px;object-fit:contain;grid-row:span 2}.codex-exchange-legend span{color:#b6c0ab}.codex-exchange-form-grid{display:grid;grid-template-columns:minmax(0,1.4fr) minmax(200px,1fr);gap:20px;padding:18px}.codex-exchange-form{display:grid;gap:17px}.codex-exchange-form fieldset{border:1px solid #7b8058;padding:15px}.codex-exchange-form fieldset label{display:flex;gap:8px;padding:8px}.codex-exchange-form input[type=checkbox]{width:auto}.codex-exchange-listing-preview{align-self:start;text-align:center;padding:25px;border:1px solid #aa8f53;border-radius:12px;background:#193a30;overflow-wrap:anywhere}.codex-exchange-listing-preview img{width:110px;height:110px;object-fit:contain}.codex-exchange-table{overflow:auto;margin:18px 0}.codex-exchange table{width:100%;border-collapse:collapse}.codex-exchange th,.codex-exchange td{text-align:left;padding:14px;border-bottom:1px solid #526346}.codex-exchange th{background:#264336;color:#e8cd8c}.codex-exchange-promotion{padding:18px;line-height:1.8}.codex-exchange-logistics{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:15px;padding:25px;border-top:1px solid #7b754b}.codex-exchange-logistics img{max-width:130px;height:42px;object-fit:contain}.codex-exchange-dialog{box-sizing:border-box;max-width:min(560px,94vw);background:#14382c;border:1px solid #c0a45e;border-radius:12px;color:#eee2ba;padding:28px}.codex-exchange-dialog::backdrop{background:#00190ed9}.codex-exchange-missing-icon{font-size:45px;text-align:center}@media(max-width:700px){.codex-exchange-layout,.codex-exchange-form-grid{grid-template-columns:minmax(0,1fr);padding:10px}.codex-exchange-categories{flex-direction:row;flex-wrap:wrap}.codex-exchange-categories button{flex:1 1 135px}.codex-exchange-hero{padding:16px}.codex-exchange-hero>img{width:65px;height:65px}} +/* Public Starport Exchange: approved visual reference. Clan/user CP keep their own palette. */ +.codex-exchange-public{--starport-gold:#c7aa60;--starport-muted:#9cb7ac;color:#eee8d5;background:radial-gradient(ellipse at 85% 0,#10332e99,transparent 55%),#031c18;border:1px solid #af9556;border-radius:9px;overflow:hidden;box-shadow:0 20px 70px #0005;max-width:1460px;margin:24px auto} +.codex-exchange-public .codex-exchange-hero{min-height:170px;box-sizing:border-box;padding:25px 28px;background:linear-gradient(90deg,#021c19f2 0%,#031e1ace 32%,#031e1a30 67%,#031e1a20),url(https://www.dunerealms.com/assets/exchange-starport-header-v2.webp) center 44%/cover;border-bottom:1px solid #c7aa60;gap:20px} +.codex-exchange-public .codex-exchange-hero>img{width:64px;height:64px;filter:drop-shadow(0 0 12px #baa15d33);border-right:1px solid #aa9254;padding-right:19px;box-sizing:content-box} +.codex-exchange-public .codex-exchange-hero h2{font-size:clamp(27px,3.4vw,43px);margin:8px 0;color:#f5e2aa;text-shadow:0 2px 6px #000} +.codex-exchange-public .codex-exchange-hero p{font-family:Georgia,serif;color:#e5d9b7;font-size:17px;margin-bottom:0}.codex-exchange-public small{color:#cfb978} +.codex-exchange-public .codex-exchange-notice{margin:0;padding:10px 22px;border-left:0;border-bottom:1px solid #5c613d;background:#0a2922;color:#adc3b5;font-size:12px} +.codex-exchange-public>.organisation-tabbed>.organisation-tabs{display:none} +.codex-exchange-public .codex-exchange-layout{grid-template-columns:205px minmax(0,1fr);padding:0;gap:0} +.codex-exchange-public .codex-exchange-categories{padding:23px 12px;background:#041c18;border-right:1px solid #a18b4e;gap:5px} +.codex-exchange-public .codex-exchange-categories:before{content:'Categories';font:700 23px Georgia,serif;color:#ead8a5;padding:0 8px 13px} +.codex-exchange-public .codex-exchange-categories button{border:1px solid transparent;border-radius:5px;background:transparent;padding:10px 9px;color:#e3dfc9;font-size:14px;gap:9px} +.codex-exchange-public .codex-exchange-categories button[aria-pressed=true]{border-color:#ceb96d;background:linear-gradient(110deg,#35543b,#123a2c);box-shadow:inset 0 0 0 1px #8a804733} +.codex-exchange-public .codex-exchange-categories button:hover{background:#143c2d}.codex-exchange-public .codex-exchange-categories img{width:27px;height:27px} +.codex-exchange-public .codex-exchange-main{padding:22px 18px;background:linear-gradient(135deg,#0b2a2160,#02191299)} +.codex-exchange-public .codex-exchange-tools{gap:9px}.codex-exchange-public .codex-exchange-field{color:#c6b989}.codex-exchange-public .codex-exchange-field input,.codex-exchange-public .codex-exchange-field select{background:#041d19;border-color:#a28f5b;color:#f0e9cc;box-shadow:inset 0 1px 4px #0005} +.codex-exchange-public .codex-exchange-status{color:#bfcaae;padding:5px 0} +.codex-exchange-public .codex-exchange-cards{grid-template-columns:repeat(4,minmax(0,1fr));gap:13px} +.codex-exchange-public .codex-exchange-card{background:radial-gradient(ellipse at 50% 20%,#1b473037,transparent 70%),linear-gradient(145deg,#0a2b21,#041d18);border:1px solid #bcaa6b;border-radius:7px;padding:13px;box-shadow:inset 0 0 0 2px #233b2533,0 5px 16px #0003;gap:10px;transition:border-color .15s,transform .15s} +.codex-exchange-public .codex-exchange-card:hover{border-color:#f0d990;transform:translateY(-2px)} +.codex-exchange-public .codex-exchange-card>img{width:108px;height:108px;max-width:100%;margin:9px auto 13px;filter:drop-shadow(0 5px 5px #0006)} +.codex-exchange-public .codex-exchange-card .minecraft-texture{width:78px;height:78px;margin:24px auto 28px} +.codex-exchange-public .codex-exchange-card h3{color:#f0e7c8;font-size:21px;font-weight:700;line-height:1.2}.codex-exchange-public .codex-exchange-card p{color:#c4cfbc;font-size:12px}.codex-exchange-public .codex-exchange-card strong{font-family:Georgia,serif;font-size:17px;color:#e3cd82} +.codex-exchange-public button{background:linear-gradient(#12412c,#062519);border-color:#c6ac5f;color:#ece0a5;border-radius:6px;box-shadow:inset 0 1px #ffffff0d}.codex-exchange-public button:not(:disabled):hover{background:linear-gradient(#235d3a,#0c3524);color:#fff0b9} +.codex-exchange-public .codex-exchange-pager{padding:23px 0 4px}.codex-exchange-public .codex-exchange-empty{border-color:#67704a;color:#b5c4b2} +.codex-exchange-public .codex-exchange-legend{margin:0 16px 18px;padding:18px 20px;border:1px solid #b6a369;border-radius:8px;background:linear-gradient(105deg,#0c2c21,#052119)} +.codex-exchange-public .codex-exchange-legend summary{font:700 20px Georgia,serif;color:#eadcb1}.codex-exchange-public .codex-exchange-legend>div{grid-template-columns:repeat(4,minmax(0,1fr));gap:18px}.codex-exchange-public .codex-exchange-legend img{width:46px;height:46px}.codex-exchange-public .codex-exchange-legend strong{color:#e5d8ad;font-family:Georgia,serif} +.codex-exchange-public .codex-exchange-logistics{background:#031b17;border-top:1px solid #887544;color:#adc1ae;padding:20px;font-size:13px}.codex-exchange-public .codex-exchange-logistics img{opacity:.95} +body.exchange-starport:has(.codex-exchange-public){background:#061e1b} +@media(max-width:1150px){.codex-exchange-public .codex-exchange-cards{grid-template-columns:repeat(3,minmax(0,1fr))}.codex-exchange-public .codex-exchange-layout{grid-template-columns:180px minmax(0,1fr)}} +@media(max-width:900px){.codex-exchange-public .codex-exchange-cards{grid-template-columns:repeat(2,minmax(0,1fr))}.codex-exchange-public .codex-exchange-legend>div{grid-template-columns:repeat(2,minmax(0,1fr))}} +@media(max-width:700px){.codex-exchange-public{margin:12px 8px}.codex-exchange-public .codex-exchange-layout{grid-template-columns:minmax(0,1fr)}.codex-exchange-public .codex-exchange-categories{border-right:0;border-bottom:1px solid #8d7e4d;padding:12px}.codex-exchange-public .codex-exchange-categories:before{flex-basis:100%;font-size:20px;padding-bottom:6px}.codex-exchange-public .codex-exchange-hero{padding:20px 16px;min-height:175px;background-position:60% center}.codex-exchange-public .codex-exchange-hero>img{width:45px;height:45px;padding-right:12px}.codex-exchange-public .codex-exchange-main{padding:15px 10px}.codex-exchange-public .codex-exchange-legend{margin:0 10px 14px;padding:14px}} +@media(max-width:430px){.codex-exchange-public .codex-exchange-cards{grid-template-columns:minmax(0,1fr)}.codex-exchange-public .codex-exchange-legend>div{grid-template-columns:minmax(0,1fr)}.codex-exchange-public .codex-exchange-hero{gap:12px}.codex-exchange-public .codex-exchange-hero h2{font-size:27px}} +.codex-exchange-public .codex-exchange-categories button[data-subcategory=true]{margin-left:18px;width:calc(100% - 18px);border-left:1px solid #88784b;border-radius:0;font-size:13px;min-height:38px;padding:7px 8px}.codex-exchange-public .codex-exchange-categories button[data-subcategory=true] img{width:22px;height:22px} diff --git a/website/control-panel/public/cp-v2/cp-v2-exchange-design.mjs b/website/control-panel/public/cp-v2/cp-v2-exchange-design.mjs index 0750c5f8..617dd57f 100644 --- a/website/control-panel/public/cp-v2/cp-v2-exchange-design.mjs +++ b/website/control-panel/public/cp-v2/cp-v2-exchange-design.mjs @@ -1,7 +1,7 @@ import {organisationTabs} from '../organisation-tabs.mjs'; 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;}; -const TYPES=[['all','All listings','nav-exchange-v2.webp','Everything in one register'],['items','Minecraft items','minecraft-items/diamond.png','Actual game goods'],['recruitment','Clan recruitment','exchange-clan-recruitment-v1.png','Join a household'],['company','Company jobs','exchange-company-jobs-v1.png','Commercial opportunities'],['faction','Faction jobs','exchange-faction-jobs-v1.png','Serve your faction'],['quests','Quests','exchange-quests-v1.png','Accept a task'],['events','Events','nav-home-v2.webp','Gatherings and campaigns'],['politics','Political positions','exchange-political-positions-v1.png','Public appointments'],['deeds','Companies & deeds','exchange-political-positions-v1.png','Transferable rights']]; +const TYPES=[['all','All listings','nav-exchange-v2.webp','Everything in one register'],['items','Minecraft items','minecraft-items/diamond.png','Actual game goods'],['kits','Kits','minecraft-items/leather_chestplate.png','All published kits'],['kits-clan','Clan Kits','minecraft-items/leather_chestplate.png','Household designs'],['kits-office','Office Kits','minecraft-items/leather_chestplate.png','Political and faction designs'],['kits-player','Player Kits','minecraft-items/leather_chestplate.png','Player designs'],['kits-legendary','Legendary Kits','minecraft-items/netherite_chestplate.png','Server kit catalogue'],['recruitment','Clan recruitment','exchange-clan-recruitment-v1.png','Join a household'],['company','Company jobs','exchange-company-jobs-v1.png','Commercial opportunities'],['faction','Faction jobs','exchange-faction-jobs-v1.png','Serve your faction'],['quests','Quests','exchange-quests-v1.png','Accept a task'],['events','Events','nav-home-v2.webp','Gatherings and campaigns'],['politics','Political positions','exchange-political-positions-v1.png','Public appointments'],['deeds','Companies & deeds','exchange-political-positions-v1.png','Transferable rights']]; const SAMPLES=[{id:'preview-recruit',type:'recruitment',title:'A place beneath our banner',owner:'Example household',world:'Kaladam',price:0,description:'Recruitment example. No real vacancy or application is created.'},{id:'preview-quest',type:'quests',title:'Supplies for the next expedition',owner:'Example household',world:'Arrakduin',price:0,description:'Quest example. Objectives and rewards are not connected.'},{id:'preview-office',type:'politics',title:'An imperial appointment',owner:'Example office',world:'Kaiterhof',price:0,description:'Political example. Candidacy and election handling are deferred.'},{id:'preview-event',type:'events',title:'The caravan assembles',owner:'Example event',world:'Giedermark',price:0,description:'Event example. No event is scheduled.'}]; const words=value=>String(value||'').replaceAll('_',' ').replace(/\b\w/g,c=>c.toUpperCase()); function image(name,cls){const n=el('img',undefined,cls);n.src=asset+name;n.alt='';n.loading='lazy';return n;} @@ -10,25 +10,26 @@ function field(label,options){const box=el('label',undefined,'codex-exchange-fie function empty(columns,message){const wrap=el('div',undefined,'codex-exchange-table'),table=el('table'),head=el('tr'),thead=el('thead'),body=el('tbody'),row=el('tr'),cell=el('td',message);for(const label of columns)head.append(el('th',label));thead.append(head);cell.colSpan=columns.length;row.append(cell);body.append(row);table.append(thead,body);wrap.append(table);return wrap;} export function mountExchangeDesign(host,{context='public',view='browse',fetcher=fetch}={}){ if(!document.querySelector('link[data-codex-exchange]')){const css=el('link');css.rel='stylesheet';css.href=new URL('./cp-v2-exchange-design.css',import.meta.url).href;css.dataset.codexExchange='';document.head.append(css);} - let active=true,rows=[],category=context==='user'?'items':'all',page=0,examples=false,clanKind='unknown';const controller=new AbortController(); - const root=el('section',undefined,'codex-exchange'),hero=el('header',undefined,'codex-exchange-hero'),copy=el('div');copy.append(el('small','STARPORT · DUNEREALM ITEM CODEX'),el('h2',context==='clan'?'Household Exchange':context==='user'?'Item Exchange':'The Exchange'),el('p','Find your next trade, calling or adventure.'));hero.append(image('nav-exchange-v2.webp'),copy);root.append(hero); + let active=true,rows=[],kitRows=[],category=context==='user'?'items':context==='public'&&TYPES.some(([id])=>id===new URLSearchParams(location.search).get('type'))?new URLSearchParams(location.search).get('type'):'all',page=0,examples=false,clanKind='unknown';const controller=new AbortController(); + const root=el('section',undefined,'codex-exchange'+(context==='public'?' codex-exchange-public':'')),hero=el('header',undefined,'codex-exchange-hero'),copy=el('div');copy.append(el('small',context==='public'?'SPACING GUILD · STARPORT EXCHANGE':'STARPORT · DUNEREALM ITEM CODEX'),el('h2',context==='clan'?'Household Exchange':context==='user'?'Item Exchange':'Starport Exchange'),el('p','Find your next trade, calling or adventure.'));hero.append(image(context==='public'?'faction-guild.svg':'nav-exchange-v2.webp'),copy);root.append(hero); const banner=el('p',context==='user'?'Minecraft goods use the existing listings service. Trading remains in game.':'Codex design preview · New listings, applications and promotions are not connected.','codex-exchange-notice');root.append(banner); const browse=el('div'),layout=el('div',undefined,'codex-exchange-layout'),aside=el('aside',undefined,'codex-exchange-categories'),main=el('div',undefined,'codex-exchange-main'),tools=el('div',undefined,'codex-exchange-tools'); const search=field('Search','Items, opportunities, sellers or worlds');search.input.type='search';const sort=field('Sort',['Newest first','Price: low to high','Price: high to low','Title']);const quality=field('Quality',['All qualities','Common','Uncommon','Rare','Very Rare','Legendary']);const stage=field('Edition',['All stages','Alpha','Beta','Live']);const season=field('Season',['All seasons','Current season','Earlier seasons']);const preview=el('label',undefined,'codex-exchange-preview'),toggle=el('input');toggle.type='checkbox';preview.append(toggle,el('span','Show design examples'));toggle.onchange=()=>{examples=toggle.checked;page=0;render();};tools.append(search.box,sort.box,quality.box,stage.box,season.box);if(context!=='user')tools.append(preview);const status=el('p','Loading live Minecraft listings…','codex-exchange-status');status.setAttribute('role','status');const cards=el('div',undefined,'codex-exchange-cards'),pager=el('div',undefined,'codex-exchange-pager');main.append(tools,status,cards,pager);layout.append(aside,main);browse.append(layout); - const categories=context==='user'?TYPES.filter(([id])=>id==='items'):TYPES;const buttons=[];for(const [id,title,art]of categories){const node=button(title,()=>{category=id;page=0;render();});node.prepend(image(art));node.setAttribute('aria-pressed',String(id===category));buttons.push([node,id]);aside.append(node);} - const legend=el('details',undefined,'codex-exchange-legend');legend.append(el('summary','Codex symbols · What each listing means'));const icons=el('div');for(const [,title,art,description]of TYPES.slice(1)){const row=el('section');row.append(image(art),el('strong',title),el('span',description));icons.append(row);}legend.append(icons);browse.append(legend); + const categories=context==='user'?TYPES.filter(([id])=>id==='items'):context==='clan'?TYPES.filter(([id])=>!id.startsWith('kits')):TYPES;const buttons=[];for(const [id,title,art]of categories){const node=button(title,()=>{category=id;page=0;if(context==='public'){const url=new URL(location.href);if(id==='all')url.searchParams.delete('type');else url.searchParams.set('type',id);history.replaceState(null,'',url);}render();});node.prepend(image(art));if(id.startsWith('kits-'))node.dataset.subcategory='true';node.setAttribute('aria-pressed',String(id===category));buttons.push([node,id]);aside.append(node);} + const legend=el('details',undefined,'codex-exchange-legend');if(context==='public')legend.open=true;legend.append(el('summary','Codex symbols · What each listing means'));const icons=el('div');for(const [type,title,art,description]of TYPES.slice(1).filter(([id])=>!id.startsWith('kits-')&&(context==='public'||id!=='kits'))){const row=el('section');row.append(image(art),el('strong',title),el('span',description));icons.append(row);}legend.append(icons);browse.append(legend); const mine=el('div');mine.append(el('h3','My listings'),empty(['Artwork','Title','Type','Applications','Promotion','Status','Action'],'Codex listing records are not connected. No records or balances are inferred.'),button('Post a listing',()=>selectPost?.())); const post=el('div',undefined,'codex-exchange-form-grid'),form=el('form',undefined,'codex-exchange-form'),formTitle=el('h3',context==='user'?'List an item':'Post a listing');form.onsubmit=e=>e.preventDefault();form.append(formTitle);const kind=field('Listing type',context==='user'?['Minecraft item']:['Clan recruitment','Quest · Keyed required','Event · Keyed required','Contract · Keyed required']);if(context==='clan')for(const option of [...kind.input.options].slice(1))option.disabled=true;const title=field('Title','A clear title for your listing'),message=field('Message','message'),audience=field('Audience',['Public exchange','Clan only']),promotion=el('fieldset');promotion.append(el('legend','Promotion'));for(const text of ['Publish to Boards','Publish to Discord']){const label=el('label'),input=el('input');input.type='checkbox';label.append(input,el('span',text));promotion.append(label);}const outcome=el('p','Preview only · Nothing has been submitted.','codex-exchange-status');form.append(kind.box,title.box,message.box,audience.box,promotion,button('Preview listing',()=>{previewCard.replaceChildren(el('small','LOCAL PREVIEW · NOT PUBLISHED'),el('h3',title.input.value||'Your listing title'),el('p',message.input.value||'Your message will appear here.'),el('p',kind.input.value));outcome.textContent='Local preview updated. Publishing is unavailable until the Codex service is connected.';}),button(context==='user'?'Create through /exchange in game':'Publish listing',null,true),outcome);const previewCard=el('article',undefined,'codex-exchange-listing-preview');previewCard.append(image(context==='user'?'minecraft-items/diamond.png':'exchange-clan-recruitment-v1.png'),el('h3','Your next chapter'),el('p','Preview your listing before publication.'));post.append(form,previewCard); const applications=el('div');applications.append(el('h3','Applications'),empty(['Applicant','Listing','Received','Status','Review'],'Application service not connected. Existing clan join requests remain available from the dashboard.'),button('Accept application',null,true),button('Decline application',null,true)); const promotions=el('div',undefined,'codex-exchange-promotion');promotions.append(el('h3','Promotions & delivery'),el('p','Basic: five initial shared credits. Each Board post costs one; each Discord post costs one. Choose any mix. Quest rewards may add credits. Keyed and Royal remove the Basic credit limit; configured promotion fees apply.'),empty(['Listing','Channel','Cost','State','Last attempt'],'Delivery history is not connected.'),el('p','Available credits: not connected. No charge is made in this preview.')); const eligibility=el('p','Checking your deed…','codex-exchange-eligibility');if(context==='clan')root.append(eligibility); let selectPost;const groups=[{id:'browse',title:'Browse',content:browse}];if(context!=='public'){groups.push({id:'mine',title:'My listings',content:mine},{id:'post',title:context==='user'?'Post an item':'Post a listing',content:post});if(context==='clan')groups.push({id:'applications',title:'Applications',content:applications},{id:'promotions',title:'Promotions',content:promotions});}const tabbed=organisationTabs(groups,{label:'Exchange sections',initial:view});selectPost=()=>tabbed.querySelector('[role=tab][aria-controls$="-post-panel"]')?.click();root.append(tabbed); - const footer=el('footer',undefined,'codex-exchange-logistics');footer.append(el('span','Exchange logistics supplied by'),image('spost-logo-v1.svg'),el('small','part of'),image('corrino-group-v4.png'));root.append(footer);host.replaceChildren(root); - function render(){for(const [node,id]of buttons)node.setAttribute('aria-pressed',String(id===category));let matches=[...rows,...(examples?SAMPLES.filter(row=>context!=='clan'||['recruitment','quests','events'].includes(row.type)):[])].filter(row=>(category==='all'||row.type===category)&&[row.title,row.owner,row.world].join(' ').toLowerCase().includes(search.input.value.toLowerCase()));if(season.input.selectedIndex>0||quality.input.selectedIndex>0||stage.input.selectedIndex>0)matches=[];matches.sort((a,b)=>sort.input.selectedIndex===1?a.price-b.price:sort.input.selectedIndex===2?b.price-a.price:sort.input.selectedIndex===3?a.title.localeCompare(b.title):Number(b.id)-Number(a.id)||0);page=Math.min(page,Math.max(0,Math.ceil(matches.length/8)-1));cards.replaceChildren();if(!matches.length)cards.append(el('p',season.input.selectedIndex||quality.input.selectedIndex||stage.input.selectedIndex?'Existing goods do not yet carry Codex edition and quality metadata. Matching records will appear after Codex integration.':'No matching listings. Design examples can be enabled separately.','codex-exchange-empty'));for(const row of matches.slice(page*8,page*8+8)){const sample=String(row.id).startsWith('preview-'),type=TYPES.find(([id])=>id===row.type),card=el('article',undefined,'codex-exchange-card');card.append(el('small',sample?'DESIGN EXAMPLE':type?.[1]||'ITEM'));const art=row.type==='items'?'minecraft-items/'+String(row.material).toLowerCase()+'.png':type?.[2],img=image(art,row.type==='items'?'minecraft-texture':undefined);img.onerror=()=>{img.remove();card.prepend(el('span','▧','codex-exchange-missing-icon'));};card.append(img,el('h3',row.title),el('p',row.owner+' · '+row.world),el('strong',row.type==='items'?row.price.toFixed(2)+' DM · '+row.quantity+' available':'View opportunity'),button(row.type==='items'?'View item':row.type==='recruitment'?'View vacancy':'View details',()=>detail(row,sample)));cards.append(card);}pager.replaceChildren(button('← Previous',()=>{page--;render();},page===0),el('span',(page+1)+' / '+Math.max(1,Math.ceil(matches.length/8))),button('Next →',()=>{page++;render();},(page+1)*8>=matches.length));} - function detail(row,sample){const dialog=el('dialog',undefined,'codex-exchange-dialog');dialog.append(el('h3',row.title),el('p',row.description||row.owner+' · '+row.world),el('p',sample?'Design example. Applications and purchases are disabled.':'Trade in Minecraft: /exchange buy '+row.id),button('Close',()=>dialog.close()));dialog.onclose=()=>dialog.remove();root.append(dialog);dialog.showModal();} + const footer=el('footer',undefined,'codex-exchange-logistics');footer.append(el('span',context==='public'?'Logistics by SPost':'Exchange logistics supplied by'),image('spost-logo-v1.svg'),el('small','part of'),image('corrino-group-v4.png'));root.append(footer);host.replaceChildren(root); + function render(){for(const [node,id]of buttons)node.setAttribute('aria-pressed',String(id===category));let matches=[...rows,...kitRows,...(examples?SAMPLES.filter(row=>context!=='clan'||['recruitment','quests','events'].includes(row.type)):[])].filter(row=>(category==='all'||row.type===category||row.kitCategory===category)&&[row.title,row.owner,row.world].join(' ').toLowerCase().includes(search.input.value.toLowerCase()));if(season.input.selectedIndex>0||stage.input.selectedIndex>0)matches=[];if(quality.input.selectedIndex>0)matches=matches.filter(row=>words(row.quality).toLowerCase()===quality.input.value.toLowerCase());matches.sort((a,b)=>sort.input.selectedIndex===1?a.price-b.price:sort.input.selectedIndex===2?b.price-a.price:sort.input.selectedIndex===3?a.title.localeCompare(b.title):Number(b.id)-Number(a.id)||0);page=Math.min(page,Math.max(0,Math.ceil(matches.length/8)-1));cards.replaceChildren();if(!matches.length)cards.append(el('p',season.input.selectedIndex||quality.input.selectedIndex||stage.input.selectedIndex?'Existing goods do not yet carry Codex edition and quality metadata. Matching records will appear after Codex integration.':'No matching listings. Design examples can be enabled separately.','codex-exchange-empty'));for(const row of matches.slice(page*8,page*8+8)){const sample=String(row.id).startsWith('preview-'),type=TYPES.find(([id])=>id===row.type),card=el('article',undefined,'codex-exchange-card');card.append(el('small',sample?'DESIGN EXAMPLE':type?.[1]||'ITEM'));const art=row.type==='items'?'minecraft-items/'+String(row.material).toLowerCase()+'.png':row.type==='kits'?'minecraft-items/'+(row.quality==='legendary'?'netherite_chestplate':'leather_chestplate')+'.png':type?.[2],img=image(art,['items','kits'].includes(row.type)?'minecraft-texture':undefined);img.onerror=()=>{img.remove();card.prepend(el('span','▧','codex-exchange-missing-icon'));};card.append(img,el('h3',row.title),el('p',row.owner+' · '+row.world),el('strong',row.type==='items'?row.price.toFixed(2)+' DM · '+row.quantity+' available':row.type==='kits'?row.price.toFixed(2)+' DM · '+words(row.quality):'View opportunity'),button(row.type==='items'?'View item':row.type==='kits'?'View kit':row.type==='recruitment'?'View vacancy':'View details',()=>detail(row,sample)));cards.append(card);}pager.replaceChildren(button('← Previous',()=>{page--;render();},page===0),el('span',(page+1)+' / '+Math.max(1,Math.ceil(matches.length/8))),button('Next →',()=>{page++;render();},(page+1)*8>=matches.length));} + function detail(row,sample){const dialog=el('dialog',undefined,'codex-exchange-dialog');dialog.append(el('h3',row.title),el('p',row.description||row.owner+' · '+row.world),el('p',sample?'Design example. Applications and purchases are disabled.':row.type==='kits'?(row.purchaseAvailable?'Continue to the existing kit checkout.':'Published design · purchase or delivery is not available yet.'):'Trade in Minecraft: /exchange buy '+row.id),button('Close',()=>dialog.close()));if(row.type==='kits'&&row.purchaseAvailable){const checkout=el('a','Open kit checkout →');checkout.href='https://cp.dunerealms.com/?kit-listing='+encodeURIComponent(row.listingId)+'#realm/kits-exchange';dialog.append(checkout);}dialog.onclose=()=>dialog.remove();root.append(dialog);dialog.showModal();} search.input.oninput=()=>{page=0;render();};sort.input.onchange=quality.input.onchange=stage.input.onchange=season.input.onchange=()=>{page=0;render();}; async function load(){try{const response=await fetcher(context==='public'?'/api/exchange/listings':'/api/exchange/listings?view=all',{credentials:'same-origin',signal:controller.signal});if(!response.ok)throw Error('unavailable');const data=await response.json();const source=Array.isArray(data)?data:Array.isArray(data.listings)?data.listings:Array.isArray(data.items)?data.items:[];rows=source.filter(row=>Number.isFinite(Number(row.price))&&Number.isFinite(Number(row.quantity))&&/^[A-Za-z0-9_]+$/.test(row.material||'')&&/^\d+$/.test(String(row.id))).map(row=>({...row,type:'items',title:row.displayName||words(row.material),owner:row.seller||row.seller_name||'Player listing',world:words(row.origin),price:Number(row.price),quantity:Number(row.quantity)}));if(!active)return;status.textContent=rows.length+' live Minecraft listings · Codex opportunities pending connection.';render();}catch{if(!active)return;rows=[];status.textContent='Live listings are unavailable. Design examples stay separate and cannot be purchased.';render();}} if(context==='clan')Promise.resolve().then(async()=>{const response=await fetcher('/api/clans',{signal:controller.signal});if(!response.ok)throw Error();const data=await response.json(),clan=data.membership?.clan||data.clan||data.clans?.find(c=>c.role);if(!clan)throw Error();clanKind=clan.charterKind||clan.deed?.charterKind||'unknown';if(!active)return;const tier={basic:['Basic',5],original:['Keyed',25],royal:['Royal',50]}[clanKind];eligibility.textContent=tier?tier[0]+' deed · '+tier[1]+' members maximum · '+(clanKind==='basic'?'Free recruitment; other listing types unlock with an upgrade.':'Advanced listing types available after Codex integration.'):'Deed eligibility is not connected. Advanced listing types remain locked.';if(['original','royal'].includes(clanKind))for(const option of kind.input.options)option.disabled=false;}).catch(()=>{if(active)eligibility.textContent='Deed eligibility could not be confirmed. Advanced listing types remain locked.';}); if(context==='user')Promise.resolve().then(async()=>{const response=await fetcher('/api/exchange/listings?view=mine',{signal:controller.signal,credentials:'same-origin'});if(!response.ok)throw Error();const data=await response.json();if(!active)return;const records=Array.isArray(data.listings)?data.listings:[];const table=empty(['Item','World','Quantity','Each · DM'],'No active item listings. List goods through /exchange in game.');if(records.length){const body=table.querySelector('tbody');body.replaceChildren();for(const item of records){const row=el('tr');for(const value of [item.displayName||words(item.material),words(item.origin),String(item.quantity),String(item.price)])row.append(el('td',value));body.append(row);}}mine.replaceChildren(el('h3','My item listings'),table,el('p',data.linked===false?'Link your Minecraft account to see your listings.':'Existing Minecraft listings · manage in game through /exchange.'));}).catch(()=>{if(active)mine.replaceChildren(el('h3','My item listings'),el('p','Your listings are unavailable. Refresh to retry.'));}); + if(context==='public')Promise.resolve().then(async()=>{const response=await fetcher('/api/kits/catalogue',{signal:controller.signal,cache:'no-store'});if(!response.ok)throw Error();const data=await response.json();if(!Array.isArray(data.listings))throw Error();kitRows=data.listings.filter(r=>/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(r.listingId)&&Number.isSafeInteger(r.priceCents)&&r.priceCents>0).map(row=>({...row,id:'kit-'+row.listingId,type:'kits',kitCategory:row.shopType==='clan'?'kits-clan':row.commerceKind==='server_sale'?'kits-legendary':['official_sale','faction_sale'].includes(row.commerceKind)?'kits-office':'kits-player',title:row.name,owner:row.ownerName||row.sellerName,world:'Kit catalogue',price:row.priceCents/100,description:(row.lore||[]).join(' · '),purchaseAvailable:row.purchaseAvailable===true||(row.purchaseAvailable===undefined&&row.commerceKind==='personal_sale')}));if(active){status.textContent=rows.length+' Minecraft listings · '+kitRows.length+' published kit designs · Codex opportunities pending.';render();}}).catch(()=>{if(active){const note=el('p','Kit catalogue is unavailable. Minecraft listings remain separate.','codex-exchange-status');browse.prepend(note);}}); render();load();return()=>{active=false;controller.abort();root.remove();}; } diff --git a/website/scripts/main-menu.mjs b/website/scripts/main-menu.mjs index b593b6a0..1da406aa 100644 --- a/website/scripts/main-menu.mjs +++ b/website/scripts/main-menu.mjs @@ -1,14 +1,14 @@ -export const MAIN_MENU=[["Home","https://www.dunerealms.com/","nav-home-v2.webp"],["Shop","https://shop.dunerealms.com/","nav-shop-v1.webp"],["Boards","https://forums.dunerealms.com/","nav-boards-v2.webp"],["Roster","https://www.dunerealms.com/staff.html","nav-staff-v2.webp"],["Discord","https://www.dunerealms.com/discord.html","nav-discord-v2.webp"],["Exchange","https://www.dunerealms.com/exchange.html","nav-exchange-v2.webp"],["Kits","https://www.dunerealms.com/kits.html","items/office_water.png"],["Politics","https://www.dunerealms.com/government.html","seals/office-landsraad.png"],["Clans","https://clans.dunerealms.com/","nav-clan-v2.webp"],["Companies","https://corp.dunerealms.com/","guild.webp"],["CP","https://cp.dunerealms.com/","nav-account-v2.webp"],["Support","https://support.dunerealms.com/","nav-support-v2.webp"],["Dunopedia","https://wiki.dunerealms.com/","nav-manual-v2.webp"]]; -export function canonicalMenuHref(value){const u=new URL(value,'https://www.dunerealms.com');if(u.hostname==='dunerealms.com')u.hostname='www.dunerealms.com';if(u.hostname==='www.dunerealms.com'&&/^\/(manual|wiki)\.html$/.test(u.pathname))return'https://wiki.dunerealms.com/';if(u.hostname==='cp.dunerealms.com'&&u.pathname==='/'){if(u.hash==='#shop')return'https://shop.dunerealms.com/';if(u.hash==='#exchange')return'https://www.dunerealms.com/exchange.html';}if(['forums','support','cp','clans','corp','wiki'].some(h=>u.hostname===h+'.dunerealms.com'))return u.origin+'/';return u.origin+(u.pathname==='/index.html'?'/':u.pathname);} -export function normalizeMainMenus(doc,currentUrl,links=MAIN_MENU){let changes=0;const set=(node,key,value)=>{if(node.getAttribute(key)!==value){node.setAttribute(key,value);changes++;}}; - for(const nav of doc.querySelectorAll('header nav[aria-label="Main navigation"]')){const old=[...nav.querySelectorAll('a')],ordered=[];for(const[name,href,icon]of links){let a=old.find(x=>!ordered.includes(x)&&canonicalMenuHref(x.href)===href);if(!a){a=doc.createElement('a');changes++;}set(a,'href',href);let image=a.querySelector('img');if(!image){image=doc.createElement('img');a.insertBefore(image,a.firstChild);changes++;}set(image,'src','https://www.dunerealms.com/assets/'+icon);set(image,'alt','');set(image,'width','34');set(image,'height','34');let label=[...a.children].find(x=>x.tagName==='SPAN'&&!x.classList.contains('dune-new-overlay')&&!x.classList.contains('dune-sales-overlay'));if(!label){label=doc.createElement('span');a.append(label);changes++;}set(label,'data-dune-nav-label','1');if(label.textContent!==name){label.textContent=name;changes++;}for(const n of [...a.childNodes])if(n.nodeType===3){n.remove();changes++;}const active=canonicalMenuHref(currentUrl)===href;if(active)set(a,'aria-current','page');else if(a.hasAttribute('aria-current')){a.removeAttribute('aria-current');changes++;}ordered.push(a);} - for(const a of old)if(!ordered.includes(a)){a.remove();changes++;}let cursor=nav.firstElementChild;for(const a of ordered){if(a!==cursor){nav.insertBefore(a,cursor);changes++;}cursor=a.nextElementSibling;}} - return changes; -} -export const CANONICAL_MENU_SCRIPT='\n/* Dune canonical menu begin */\n(()=>{if(window.top!==window.self)return;const MAIN_MENU='+JSON.stringify(MAIN_MENU)+';const canonicalMenuHref='+canonicalMenuHref.toString()+';const normalizeMainMenus='+normalizeMainMenus.toString()+';const sync=()=>normalizeMainMenus(document,location.href,MAIN_MENU);sync();new MutationObserver(sync).observe(document.body,{childList:true,subtree:true});})();\n/* Dune canonical menu end */\n'; -export function withCanonicalMenu(script){ - // Older published assets may contain a generated controller without its marker comments. - // Remove both forms before installing the single current controller. - return script.replace(/\n?\/\* Dune canonical menu begin \*\/[^]*?\/\* Dune canonical menu end \*\/\n?/g,'') - .replace(/\(\(\)=>\{if\(window\.top!==window\.self\)return;const MAIN_MENU=[^]*?const sync=\(\)=>normalizeMainMenus\(document,location\.href,MAIN_MENU\);sync\(\);new MutationObserver\(sync\)\.observe\(document\.body,\{childList:true,subtree:true\}\);\}\)\(\);/g,'')+CANONICAL_MENU_SCRIPT; -} +export const MAIN_MENU=[["Home","https://www.dunerealms.com/","nav-home-v2.webp"],["Shop","https://shop.dunerealms.com/","nav-shop-v1.webp"],["Boards","https://forums.dunerealms.com/","nav-boards-v2.webp"],["Roster","https://www.dunerealms.com/staff.html","nav-staff-v2.webp"],["Discord","https://www.dunerealms.com/discord.html","nav-discord-v2.webp"],["Exchange","https://www.dunerealms.com/exchange.html","nav-exchange-v2.webp"],["Kits","https://www.dunerealms.com/exchange.html?type=kits","items/office_water.png"],["Politics","https://www.dunerealms.com/government.html","seals/office-landsraad.png"],["Clans","https://clans.dunerealms.com/","nav-clan-v2.webp"],["Companies","https://corp.dunerealms.com/","guild.webp"],["CP","https://cp.dunerealms.com/","nav-account-v2.webp"],["Support","https://support.dunerealms.com/","nav-support-v2.webp"],["Dunopedia","https://wiki.dunerealms.com/","nav-manual-v2.webp"]]; +export function canonicalMenuHref(value){const u=new URL(value,'https://www.dunerealms.com');if(u.hostname==='dunerealms.com')u.hostname='www.dunerealms.com';if(u.hostname==='www.dunerealms.com'&&/^\/(manual|wiki)\.html$/.test(u.pathname))return'https://wiki.dunerealms.com/';if(u.hostname==='cp.dunerealms.com'&&u.pathname==='/'){if(u.hash==='#shop')return'https://shop.dunerealms.com/';if(u.hash==='#exchange')return'https://www.dunerealms.com/exchange.html';}if(['forums','support','cp','clans','corp','wiki'].some(h=>u.hostname===h+'.dunerealms.com'))return u.origin+'/';return u.origin+(u.pathname==='/index.html'?'/':u.pathname);} +export function normalizeMainMenus(doc,currentUrl,links=MAIN_MENU){let changes=0;const set=(node,key,value)=>{if(node.getAttribute(key)!==value){node.setAttribute(key,value);changes++;}}; + for(const nav of doc.querySelectorAll('header nav[aria-label="Main navigation"]')){const old=[...nav.querySelectorAll('a')],ordered=[];for(const[name,href,icon]of links){let a=old.find(x=>!ordered.includes(x)&&canonicalMenuHref(x.href)===href);if(!a){a=doc.createElement('a');changes++;}set(a,'href',href);let image=a.querySelector('img');if(!image){image=doc.createElement('img');a.insertBefore(image,a.firstChild);changes++;}set(image,'src','https://www.dunerealms.com/assets/'+icon);set(image,'alt','');set(image,'width','34');set(image,'height','34');let label=[...a.children].find(x=>x.tagName==='SPAN'&&!x.classList.contains('dune-new-overlay')&&!x.classList.contains('dune-sales-overlay'));if(!label){label=doc.createElement('span');a.append(label);changes++;}set(label,'data-dune-nav-label','1');if(label.textContent!==name){label.textContent=name;changes++;}for(const n of [...a.childNodes])if(n.nodeType===3){n.remove();changes++;}const active=canonicalMenuHref(currentUrl)===href;if(active)set(a,'aria-current','page');else if(a.hasAttribute('aria-current')){a.removeAttribute('aria-current');changes++;}ordered.push(a);} + for(const a of old)if(!ordered.includes(a)){a.remove();changes++;}let cursor=nav.firstElementChild;for(const a of ordered){if(a!==cursor){nav.insertBefore(a,cursor);changes++;}cursor=a.nextElementSibling;}} + return changes; +} +export const CANONICAL_MENU_SCRIPT='\n/* Dune canonical menu begin */\n(()=>{if(window.top!==window.self)return;const MAIN_MENU='+JSON.stringify(MAIN_MENU)+';const canonicalMenuHref='+canonicalMenuHref.toString()+';const normalizeMainMenus='+normalizeMainMenus.toString()+';const sync=()=>normalizeMainMenus(document,location.href,MAIN_MENU);sync();new MutationObserver(sync).observe(document.body,{childList:true,subtree:true});})();\n/* Dune canonical menu end */\n'; +export function withCanonicalMenu(script){ + // Older published assets may contain a generated controller without its marker comments. + // Remove both forms before installing the single current controller. + return script.replace(/\n?\/\* Dune canonical menu begin \*\/[^]*?\/\* Dune canonical menu end \*\/\n?/g,'') + .replace(/\(\(\)=>\{if\(window\.top!==window\.self\)return;const MAIN_MENU=[^]*?const sync=\(\)=>normalizeMainMenus\(document,location\.href,MAIN_MENU\);sync\(\);new MutationObserver\(sync\)\.observe\(document\.body,\{childList:true,subtree:true\}\);\}\)\(\);/g,'')+CANONICAL_MENU_SCRIPT; +} diff --git a/website/tests/cp-v2-user-links.test.mjs b/website/tests/cp-v2-user-links.test.mjs index d6c00b5d..43702b8f 100644 --- a/website/tests/cp-v2-user-links.test.mjs +++ b/website/tests/cp-v2-user-links.test.mjs @@ -1,25 +1,25 @@ -import test from 'node:test'; -import assert from 'node:assert/strict'; -import {readFileSync} from 'node:fs'; -import {runInNewContext} from 'node:vm'; -import {nativeServiceURL} from '../control-panel/public/cp-v2/cp-v2-native-services.mjs'; -const source=readFileSync(new URL('../control-panel/public/cp-v2/v2.js',import.meta.url),'utf8'); -const menu=source.slice(0,source.indexOf(';const art=')); -const resolver=source.slice(source.indexOf('function legacyRoute('),source.indexOf('function go(')); -const resolve=runInNewContext(menu+';'+resolver+';legacyRoute'); - -test('legacy links resolve to the actual V2 User page instead of the default passport',()=>{ - for(const id of ['game','security','rewards-codes','tickets']){const route=resolve(id);assert.equal(route.wid,'realm');assert.equal(route.pid,id);} - for(const [id,workspace,page]of [['clans','clan','clan-overview'],['kits-exchange','kits','kits-exchange'],['quests','quests','quests']]){const route=resolve('realm',id);assert.equal(route.wid,workspace);assert.equal(route.pid,page);} - assert.equal(resolve('clans').wid,'clan');assert.equal(resolve('kits-exchange').wid,'kits'); - assert.equal(resolve('bank','bank-history').pid,'bank-statements');assert.equal(resolve('bank','bank-information').pid,'bank-overview');assert.equal(resolve('personal-bank').wid,'bank');assert.equal(resolve('realm','transactions').pid,'bank-statements');assert.equal(resolve('rewards-redeem').initialTab,'redeem');assert.equal(resolve('kit-checkout').initialTab,'kit-checkout');assert.equal(resolve('clan-inbox').pid,'clan-inbox');assert.equal(resolve('shared-inbox').wid,'post');assert.equal(resolve('realm','shared-inbox').wid,'post'); - assert.equal(resolve('dev-queue').wid,'forge');assert.equal(resolve('bureau','permissions').pid,'permissions'); -}); -test('public kit purchase retains only a valid listing identity inside the fixed authenticated checkout destination',()=>{ - const id='12345678-1234-4234-8234-123456789abc',url=new URL(nativeServiceURL('kits-exchange',{listingId:id}));assert.equal(url.origin,'https://cp.dunerealms.com');assert.equal(url.pathname,'/user-service.html');assert.equal(url.searchParams.get('service'),'tailor');assert.equal(url.searchParams.get('kit-listing'),id);assert.equal(url.hash,'#kit-checkout'); - for(const listingId of ['https://outside.example','../secret','bad-id'])assert.equal(new URL(nativeServiceURL('kits-exchange',{listingId})).searchParams.has('kit-listing'),false); - assert.equal(new URL(nativeServiceURL('shared-inbox',{initialTab:'clan-inbox'})).hash,'#clan-inbox');assert.equal(new URL(nativeServiceURL('shared-inbox',{initialTab:'https://outside.example'})).hash,'#shared-inbox'); -}); -test('public Kit Exchange links point at the canonical V2 workshop',()=>{ - const publicSource=readFileSync(new URL('../web/kits.js',import.meta.url),'utf8');assert.match(publicSource,/#realm\/kits-exchange/);assert.doesNotMatch(publicSource,/#kit-checkout/); -}); +import test from 'node:test'; +import assert from 'node:assert/strict'; +import {readFileSync} from 'node:fs'; +import {runInNewContext} from 'node:vm'; +import {nativeServiceURL} from '../control-panel/public/cp-v2/cp-v2-native-services.mjs'; +const source=readFileSync(new URL('../control-panel/public/cp-v2/v2.js',import.meta.url),'utf8'); +const menu=source.slice(0,source.indexOf(';const art=')); +const resolver=source.slice(source.indexOf('function legacyRoute('),source.indexOf('function go(')); +const resolve=runInNewContext(menu+';'+resolver+';legacyRoute'); + +test('legacy links resolve to the actual V2 User page instead of the default passport',()=>{ + for(const id of ['game','security','rewards-codes','tickets']){const route=resolve(id);assert.equal(route.wid,'realm');assert.equal(route.pid,id);} + for(const [id,workspace,page]of [['clans','clan','clan-overview'],['kits-exchange','kits','kits-exchange'],['quests','quests','quests']]){const route=resolve('realm',id);assert.equal(route.wid,workspace);assert.equal(route.pid,page);} + assert.equal(resolve('clans').wid,'clan');assert.equal(resolve('kits-exchange').wid,'kits'); + assert.equal(resolve('bank','bank-history').pid,'bank-statements');assert.equal(resolve('bank','bank-information').pid,'bank-overview');assert.equal(resolve('personal-bank').wid,'bank');assert.equal(resolve('realm','transactions').pid,'bank-statements');assert.equal(resolve('rewards-redeem').initialTab,'redeem');assert.equal(resolve('kit-checkout').initialTab,'kit-checkout');assert.equal(resolve('clan-inbox').pid,'clan-inbox');assert.equal(resolve('shared-inbox').wid,'post');assert.equal(resolve('realm','shared-inbox').wid,'post'); + assert.equal(resolve('dev-queue').wid,'forge');assert.equal(resolve('bureau','permissions').pid,'permissions'); +}); +test('public kit purchase retains only a valid listing identity inside the fixed authenticated checkout destination',()=>{ + const id='12345678-1234-4234-8234-123456789abc',url=new URL(nativeServiceURL('kits-exchange',{listingId:id}));assert.equal(url.origin,'https://cp.dunerealms.com');assert.equal(url.pathname,'/user-service.html');assert.equal(url.searchParams.get('service'),'tailor');assert.equal(url.searchParams.get('kit-listing'),id);assert.equal(url.hash,'#kit-checkout'); + for(const listingId of ['https://outside.example','../secret','bad-id'])assert.equal(new URL(nativeServiceURL('kits-exchange',{listingId})).searchParams.has('kit-listing'),false); + assert.equal(new URL(nativeServiceURL('shared-inbox',{initialTab:'clan-inbox'})).hash,'#clan-inbox');assert.equal(new URL(nativeServiceURL('shared-inbox',{initialTab:'https://outside.example'})).hash,'#shared-inbox'); +}); +test('public Kit Exchange links point at the canonical V2 workshop',()=>{ + const entry=readFileSync(new URL('../web/kits.js',import.meta.url),'utf8'),exchange=readFileSync(new URL('../control-panel/public/cp-v2/cp-v2-exchange-design.mjs',import.meta.url),'utf8');assert.match(entry,/location\.replace\('\/exchange\.html\?type=kits'\)/);assert.match(exchange,/#realm\/kits-exchange/);assert.doesNotMatch(exchange,/#kit-checkout/); +}); diff --git a/website/web/assets/exchange-starport-header-v2.webp b/website/web/assets/exchange-starport-header-v2.webp new file mode 100644 index 00000000..9155c75a Binary files /dev/null and b/website/web/assets/exchange-starport-header-v2.webp differ diff --git a/website/web/assets/minecraft-items/leather_chestplate.png b/website/web/assets/minecraft-items/leather_chestplate.png new file mode 100644 index 00000000..104c1feb Binary files /dev/null and b/website/web/assets/minecraft-items/leather_chestplate.png differ diff --git a/website/web/assets/minecraft-items/netherite_chestplate.png b/website/web/assets/minecraft-items/netherite_chestplate.png new file mode 100644 index 00000000..3ab6ee1f Binary files /dev/null and b/website/web/assets/minecraft-items/netherite_chestplate.png differ diff --git a/website/web/kits.js b/website/web/kits.js index b0e3e3bc..5c46000c 100644 --- a/website/web/kits.js +++ b/website/web/kits.js @@ -1,8 +1,2 @@ -import {kitDirectory,kitAvailable} from './kit-directory.js'; -function enchantmentDetails(quality){ - const profiles={common:['Standard vanilla kit: no enchantments'],uncommon:['All armour: Protection I, Unbreaking I','Boots: Feather Falling I'],rare:['All armour: Protection II, Unbreaking II','Helmet: Respiration I, Aqua Affinity I','Boots: Feather Falling II, Depth Strider I'],very_rare:['All armour: Protection III, Unbreaking III, Mending I','Helmet: Respiration II, Aqua Affinity I','Leggings: Swift Sneak II','Boots: Feather Falling III, Depth Strider II'],legendary:['All armour: Protection IV, Unbreaking III, Mending I, Thorns III','Helmet: Respiration III, Aqua Affinity I','Leggings: Swift Sneak III','Boots: Feather Falling IV, Depth Strider III, Soul Speed III']}; - const box=el('section');box.className='kit-enchantment-profile';box.append(el('h3','Enchantment profile'));const list=el('ul');for(const line of profiles[quality]||[])list.append(el('li',line));box.append(list,el('p','Fixed by kit quality. Preview: game-side activation is pending.'));return box; -} -const el=(tag,text)=>{const n=document.createElement(tag);if(text!==undefined)n.textContent=text;return n},categories=[['all','All Kits'],['personal_sale','Player Kits'],['clan','Clan Kits'],['official_sale','Official Kits'],['faction_sale','Faction Kits'],['server_sale','Server Kits']],art={personal_sale:'clan-atelier-v1.webp',official_sale:'imperial-atelier-v1.webp',faction_sale:'clan-atelier-v1.webp',server_sale:'imperial-atelier-v1.webp'};let selected='all',rows=[],page=1;const quality=document.getElementById('kit-quality'),availability=document.getElementById('kit-availability'),pages=document.getElementById('kit-pages');const menu=document.getElementById('kit-categories'),status=document.getElementById('kit-status'),results=document.getElementById('kit-listings'),search=document.getElementById('kit-search'),sort=document.getElementById('kit-sort');for(const[key,label]of categories){const b=el('button',label);b.type='button';b.dataset.kind=key;b.setAttribute('aria-pressed',String(key===selected));b.onclick=()=>{selected=key;page=1;render()};menu.append(b)} - -function render(){for(const b of menu.children)b.setAttribute('aria-pressed',String(b.dataset.kind===selected));const model=kitDirectory(rows,{query:search.value,category:selected,quality:quality.value,availability:availability.value,sort:sort.value,page});page=model.page;const filtered=model.rows;pages.replaceChildren();if(model.pages>1){for(const[label,step]of [['Previous',-1],['Next',1]]){const button=el('button',label);button.type='button';button.disabled=step<0?page===1:page===model.pages;button.onclick=()=>{page+=step;render();};pages.append(button);}pages.append(el('span','Page '+page+' of '+model.pages));}results.replaceChildren();status.textContent=model.total+' published '+(model.total===1?'design':'designs');if(!filtered.length){const empty=el('article');empty.className='kit-empty';empty.append(el('h2',rows.length?'No matching designs':'No published designs yet'),el('p',rows.length?'Try another name, rarity or availability filter.':'This category is ready for its first commission.'));results.append(empty);return;}for(const r of filtered){const card=el('article');card.className='kit-store-card kit-collectible-listing';card.dataset.quality=r.quality;const image=el('img');image.src='assets/'+art[r.commerceKind];image.alt='Illustrated stillsuit atelier';image.loading='lazy';const visual=el('div');visual.className='kit-store-art';const swatch=el('span');swatch.className='kit-store-colour';swatch.textContent=/^#[A-Fa-f0-9]{6}$/.test(r.color||'')?r.color.toUpperCase():'Colour not recorded';if(/^#[A-Fa-f0-9]{6}$/.test(r.color||''))swatch.style.setProperty('--kit-swatch',r.color);visual.append(image,swatch);card.append(visual,el('small',categories.find(c=>c[0]===(r.shopType==='clan'?'clan':r.commerceKind))?.[1]+' · '+r.quality.replaceAll('_',' ')),el('h2',r.name),el('p','Designed by '+r.sellerName));const lore=el('div');for(const line of r.lore)lore.append(el('p',line));card.append(lore,el('strong',(r.priceCents/100).toFixed(2)+' DM'),el('p',r.completedSales+' completed sales'));const buy=el('a','Buy Kit →');buy.className='kit-store-link';buy.href='https://cp.dunerealms.com/?kit-listing='+encodeURIComponent(r.listingId)+'#realm/kits-exchange';const details=el('details'),summary=el('summary','Kit details');details.append(summary,el('p','Four-piece stillsuit · '+r.quality.replaceAll('_',' ')),el('p','Colour: '+r.color),el('p','Managed by '+(r.ownerName||r.sellerName)),enchantmentDetails(r.quality));card.append(details);if(!kitAvailable(r)){const note=el('p','Published design · in-game delivery opens later.');note.className='kit-delivery-note';card.append(note);}else card.append(buy);results.append(card)}}search.oninput=sort.onchange=quality.onchange=availability.onchange=()=>{page=1;render();};document.getElementById('kit-clear').onclick=()=>{search.value=quality.value=availability.value='';sort.value='sales';selected='all';page=1;render();};async function load(){status.textContent='Loading published kit designs…';try{const response=await fetch('/api/kits/catalogue',{cache:'no-store'}),data=await response.json();if(!response.ok||!Array.isArray(data.listings))throw Error(data.message||'The kit catalogue is temporarily unavailable.');rows=data.listings;render()}catch(e){status.textContent=e.message;results.replaceChildren();const retry=el('button','Retry catalogue');retry.type='button';retry.onclick=load;results.append(retry);}}void load(); +// Compatibility entry: all kit browsing uses the central Exchange. Existing checkout remains intact. +location.replace('/exchange.html?type=kits');