forked from unimatrix/web
Restore scrolling for directly opened organisation control panels
This commit is contained in:
parent
ebb1ac3586
commit
9e833a4db9
4 changed files with 13 additions and 3 deletions
|
|
@ -1 +1 @@
|
|||
export function clanCPDocument(source){return source.replace('<title>DuneRealms · Account Centre</title>','<title>DuneRealms · Clan CP</title>').replace(/<header class="dune-site-header"[^>]*>[\s\S]*?<\/header>/,'').replace(/<footer class="site-footer"><\/footer>/,'').replace(/<script src="https:\/\/www\.dunerealms\.com\/portal-navigation\.js" defer><\/script>/,'').replace(/<link rel="stylesheet" href="https:\/\/www\.dunerealms\.com\/portal-navigation\.css">/,'').replace(/<body\b[^>]*>/,'<body data-cp-mode="clan" class="clan-cp-shell">').replace(/<section class="command-banner">[\s\S]*?<\/section>/,'').replace('</head>','<link rel="stylesheet" href="/v2/cp-v2-clan-shell.css?v=single-scroll-2"><link rel="stylesheet" href="/v2/cp-v2-claims.css"></head>').replace('</body>','<script type="module" src="/v2/cp-v2-clan-size.mjs"></script></body>');}
|
||||
export function clanCPDocument(source){return source.replace('<title>DuneRealms · Account Centre</title>','<title>DuneRealms · Clan CP</title>').replace(/<header class="dune-site-header"[^>]*>[\s\S]*?<\/header>/,'').replace(/<footer class="site-footer"><\/footer>/,'').replace(/<script src="https:\/\/www\.dunerealms\.com\/portal-navigation\.js" defer><\/script>/,'').replace(/<link rel="stylesheet" href="https:\/\/www\.dunerealms\.com\/portal-navigation\.css">/,'').replace(/<body\b[^>]*>/,'<body data-cp-mode="clan" class="clan-cp-shell">').replace(/<section class="command-banner">[\s\S]*?<\/section>/,'').replace('</head>','<link rel="stylesheet" href="/v2/cp-v2-clan-shell.css?v=single-scroll-3"><link rel="stylesheet" href="/v2/cp-v2-claims.css"></head>').replace('</body>','<script type="module" src="/v2/cp-v2-clan-size.mjs"></script></body>');}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
html:has(body.clan-cp-shell){overflow:hidden}body.clan-cp-shell{display:flow-root;overflow:visible;min-height:0}.clan-cp-shell .layout{min-height:0}
|
||||
html:has(body.clan-cp-shell){overflow:auto}html.dune-embedded:has(body.clan-cp-shell){overflow:hidden}body.clan-cp-shell{display:flow-root;overflow:visible;min-height:0}.clan-cp-shell .layout{min-height:0}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
if(parent!==window)document.documentElement.classList.add('dune-embedded');
|
||||
const referrerOrigin=(()=>{try{return new URL(document.referrer).origin;}catch{return '';}})();
|
||||
const outer=['https://clans.dunerealms.com','https://www.dunerealms.com'].includes(referrerOrigin)?referrerOrigin:'https://clans.dunerealms.com';
|
||||
let queued=false,last=0;function measure(){queued=false;if(parent===window)return;const height=Math.ceil(Math.max(document.body.scrollHeight,document.body.getBoundingClientRect().height))+2;if(height!==last&&height>=100&&height<=200000){last=height;parent.postMessage({type:'dune-embed-size',height},outer);}}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import test from 'node:test';import assert from 'node:assert/strict';
|
|||
import {clientClanRows} from '../control-panel/public/cp-v2/cp-v2-client-clans.mjs';
|
||||
import {jarvisApplicationDocument} from '../control-panel/jarvis-application-shell.mjs';
|
||||
import {readFile} from 'node:fs/promises';
|
||||
import {runInNewContext} from 'node:vm';
|
||||
const clan=(id,name=id)=>({id:'clan:'+id,kind:'clan',name});
|
||||
test('client register includes every descendant, excludes the parent and unrelated clans, and preserves direct allegiance',()=>{
|
||||
const network={nodes:[clan('parent'),clan('other'),...Array.from({length:14},(_,i)=>clan('child'+i)),clan('grandchild')],edges:[...Array.from({length:14},(_,i)=>({from:'clan:parent',to:'clan:child'+i})),{from:'clan:child0',to:'clan:grandchild'}]};
|
||||
|
|
@ -15,5 +16,13 @@ test('confirmed graph traversal tolerates duplicate edges, cannot loop, and does
|
|||
test('standalone application shell opts into its own document scrolling and retains the existing embedded clan shell',async()=>{
|
||||
const source=await readFile(new URL('../control-panel/public/cp-v2/index.html',import.meta.url),'utf8'),html=jarvisApplicationDocument(source),css=await readFile(new URL('../control-panel/public/cp-v2/cp-v2-jarvis.css',import.meta.url),'utf8');
|
||||
assert.match(html,/class="clan-cp-shell jarvis-standalone-shell"/);assert.match(html,/href="\/v2\/cp-v2-jarvis.css"/);assert.doesNotMatch(html,/cp-v2-clan-size.mjs/);assert.match(css,/html:has\(body\.jarvis-standalone-shell\)\{[^}]*overflow-y:auto/);
|
||||
const clanCSS=await readFile(new URL('../control-panel/public/cp-v2/cp-v2-clan-shell.css',import.meta.url),'utf8');assert.match(clanCSS,/html:has\(body\.clan-cp-shell\)\{overflow:hidden\}/);
|
||||
const clanCSS=await readFile(new URL('../control-panel/public/cp-v2/cp-v2-clan-shell.css',import.meta.url),'utf8');assert.match(clanCSS,/html:has\(body\.clan-cp-shell\)\{overflow:auto\}/);assert.match(clanCSS,/html\.dune-embedded:has\(body\.clan-cp-shell\)\{overflow:hidden\}/);
|
||||
});
|
||||
test('clan sizing marks only embedded documents so direct CP pages retain native page scrolling',async()=>{
|
||||
const source=await readFile(new URL('../control-panel/public/cp-v2/cp-v2-clan-size.mjs',import.meta.url),'utf8');
|
||||
for(const embedded of [false,true]){
|
||||
const added=[],window={addEventListener(){}},parent=embedded?{}:window;
|
||||
runInNewContext(source,{window,parent,URL,document:{referrer:'https://clans.dunerealms.com/',documentElement:{classList:{add:name=>added.push(name)}},body:{}},requestAnimationFrame(){},ResizeObserver:class{observe(){}}});
|
||||
assert.deepEqual(added,embedded?['dune-embedded']:[]);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff