Split the game page into partials under src/, assembled into one index.html at build
site/index.html (900 KB of HTML, CSS and JS in one file) becomes src/: a shell (src/index.html), styles/ and game/, concatenated in path order by scripts/lib/page.js. The assembled page is byte-identical to the old file, so load time and in-game performance are unchanged. - scripts/build.js replaces build.sh (same env vars, same output) - npm run dev: a zero-dependency dev server that assembles on every request - tests assemble the page in memory; npm test runs every tests/*.test.js - perf-bench takes --base-ref to build a git ref's page - scripts/legacy/split-index-html.js is the splitter, kept for older branches
This commit is contained in:
parent
295e68cc46
commit
67a40942b4
113 changed files with 5584 additions and 5195 deletions
24
src/game/95-modals/30-modal-and-names.js
Normal file
24
src/game/95-modals/30-modal-and-names.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// Keyboard focus moves into the modal, so Enter or Space can't keep pressing a hidden button behind it.
|
||||
function openModal(html){if($('modal').hidden)markLayer();$('modalCard').innerHTML=html;$('modal').hidden=false;const a=document.activeElement;if(a&&a!==document.body&&!a.closest('#modal')){a.blur();const m=$('modalCard');m.tabIndex=-1;m.focus({preventScroll:true});}}
|
||||
function closeModal(){if(!$('modal').hidden)markLayer();$('modal').hidden=true;UI.pending=null;}
|
||||
const NETWORK_NAMES=[
|
||||
'Packet Pals','Shinternet','Post, Telegraph & Tubes','Peering Pressure','Best Effort Telecom',
|
||||
'Mostly Online','Buffering & Sons','Lord of the Pings','The Ping Dynasty',
|
||||
'LAN Before Time','Bits Please','Hopless Networks','Route of All Evil',
|
||||
'TTL You Later','Fiber McFiberface','RFC 1149 Avian Carriers','Spanning Tree Huggers',
|
||||
'Dial-Up & Cry','404 Telecom','Loss Leaders','Last Mile Standing',
|
||||
'Have You Tried Off & On','Bogon Voyage','Default Route 66','Anycast Away',
|
||||
'Hot Potato Routing','Null Route Rangers','Looking Glass Half Full','Jumbo Frame Shop',
|
||||
'Route Flap Jacks','Split Horizon & Co.','Path of Least Resistance',
|
||||
];
|
||||
function randomNetworkName(current){
|
||||
// Naming must not advance a running scenario's seeded simulation.
|
||||
const names=NETWORK_NAMES.filter(n=>n!==current);
|
||||
return names[Math.floor(_rand()*names.length)];
|
||||
}
|
||||
const HTIW='https://tkjaer.github.io/how-the-internet-works/';
|
||||
// The real thing: an interactive, zoomable guide to how packets actually travel. Go read it.
|
||||
// Where players hang out: the community Signal group.
|
||||
const SIGNAL='https://signal.group/#CjQKIJwvEt5fYt1pvw7J2pV664CyUyGJXmAJLV8ia3nUdAD7EhA_FzdxflEzkNmcvDHdVgLQ';
|
||||
const chatHtml=()=>`<a class="plug chat" href="${SIGNAL}" target="_blank" rel="noopener"><span class="pi" aria-hidden="true">💬</span><span><b>${tr('Join the NOC chat')}</b><span class="meta">${tr('Our Signal group: swap screenshots, report bugs and argue about peering policy with other players. Fewer backhoes than the real thing.')}</span></span><span class="go">${tr('Join →')}</span></a>`;
|
||||
const plugHtml=(big)=>`<a class="plug" href="${HTIW}" target="_blank" rel="noopener"><span class="pi" aria-hidden="true">🌍</span><span><b>How the Internet Works</b><span class="meta">${big?tr('The real thing, by Thomas Kjær Aabo: a zoomable, interactive map of how your packets actually travel, from Wi-Fi to undersea fiber, today, in 2010 and in 1995. This game makes it up as it goes. That one gets it right.'):tr('The real thing: follow a packet from Wi-Fi to undersea fiber.')}</span></span><span class="go">${tr('Explore →')}</span></a>`;
|
||||
Loading…
Add table
Add a link
Reference in a new issue