GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Websites and apps / globalgrid2050 / /

Versioned Homepage and 1 more file

A JavaScript file in the assets folder of GlobalGrid2050 that draws active pages. It fetches JSON (`fetchJson`), validates presentation (`validatePresentation`) and validates types (`validateTypes`).

583 lines of JavaScript and HTML from globalgrid2050, in 2 files. Topic: Websites and apps. Section 1896 of 2044.

Cut 2026-12-06T03:07:51+00:00. A copy for reading; the repository at the stated commit is the source.

In the State lines below, domain stage, users and canonical status are rule-based first approximations from code and path evidence (rules explore-agent-rules-v1), not observed facts: the rules.

In this section

  1. GlobalGrid2050 Homepage Before Four Nests render · globalgrid2050 / homepage-before-four-nests-20260925.html lines 1–286
  2. Versioned Homepage interaction · globalgrid2050 / homepage-shell/assets/versioned-homepage.js lines 1–297

GlobalGrid2050 Homepage Before Four Nests

A web page that draws homepage catalogue, cables, solar and substations, using IEC 60909 and IEC 60228, and uses data from the GridAtlas, ventus-grid-engine and stars repositories. Published at https://globalgrid2050.com/homepage-before-four-nests-20260925.html.

renderglobalgrid2050 / homepage-before-four-nests-20260925.html · lines 1–286 of 286 · version 2026-09-25 · Entry point · pattern browsing (shared by 28 files)

What it does
It draws homepage catalogue, cables, solar and substations. Defines 8 functions or classes, including esc, rowsFor, passes, sortRows, row. Side effects: changes the web page (DOM); makes network requests.
Why it exists in the grid workflow
Domain terms in the code: cables, solar, substations, 400kV, 132kV, 33kV.
Inputs & outputs
In: data source: gridatlas data; data source: ventus-grid-engine data; data source: stars data; data source: galaxies-wafers data; JSON file homepage-catalogue.json; form fields (user input). Out: web page. Voltage levels named: 400kV, 132kV, 33kV.
Downstream impact
Used directly by 1 file: GlobalGrid2050 Historical Builds (globalgrid2050, https://globalgrid2050.com/historical_builds.html). Reached from 86 other entry points, including Homepage V037 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v037.html); Homepage V038 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v038.html); Homepage V039 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v039.html). It is itself an entry point, published at https://globalgrid2050.com/homepage-before-four-nests-20260925.html.
What it achieves
It sorts rows (`sortRows`) and is built from the esc step (`esc`) and the rows for helper (`rowsFor`). Open-source knowledge and tools for electrical energy systems. Its code works with 132 kV, 400 kV and 33 kV. It reads `./catalogue/homepage-catalogue.json`. It responds to click and input events.
Why it matters
Feeds the GlobalGrid2050 Historical Builds map page (cables and solar) at https://globalgrid2050.com/historical_builds.html.
Application
globalgrid2050 · / · page
Uses
Kuiper Grid — Drawing Page (link), GridAtlas — Atlas Page (link), GlobalGrid2050 — Kuiper Grid Page (link), GlobalGrid2050 — Plant Page (link), Manual (link), GlobalGrid2050 — Compute Page (link), GlobalGrid2050 — Kuiper Page (link), GlobalGrid2050 Historical Builds (link), and 41 more
Used by
linked from GlobalGrid2050 Historical Builds (link)
Produces
esc, rowsFor, passes, sortRows, row, th, browsing, build
Defines here
esc, rowsFor, passes, sortRows, row, th, browsing, build
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 homepage-before-four-nests-20260925.html:1-286 · blob 0e6ffa49fb5cbb19696cc3225b3d464bebc7daad · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, network · domain stage: unknown · users: none · canonical: production_core
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="data:,">
<title>GlobalGrid2050</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
  :root { color-scheme: dark; }
  html { background:#000; }
  body { background:#000; color:#fff; font-family:Courier,monospace; padding:40px; max-width:980px; margin:0 auto; font-size:20px; line-height:1.6; }
  h1 { margin:0 0 6px; }
  a { color:#66ccff; text-decoration:none; }
  a:hover { text-decoration:underline; }
  .lede { color:#aaa; font-size:16px; margin:0 0 22px; }
  #q { width:100%; padding:12px; background:#111; color:#fff; border:1px solid #444; font-family:Courier,monospace; font-size:18px; margin:6px 0 10px; box-sizing:border-box; }
  #q:focus { outline:none; border-color:#66ccff; }
  .controls { display:flex; gap:8px; flex-wrap:wrap; align-items:center; margin:0 0 18px; font-size:14px; }
  .controls button, .controls select { background:#000; color:#aab3bf; border:1px solid #343b45; padding:7px 10px; font:700 12px Courier,monospace; cursor:pointer; text-transform:uppercase; }
  .controls button.on, .controls button:hover, .controls select:hover { border-color:#00ffff; color:#00ffff; }
  .controls .count { margin-left:auto; color:#7a7a7a; }
  details.area { border-bottom:1px solid #333; }
  details.area > summary { list-style:none; cursor:pointer; padding:14px 0; color:#00ffff; font-weight:bold; letter-spacing:.5px; font-size:24px; }
  details.area > summary::-webkit-details-marker { display:none; }
  details.area > summary::before { content:"[+] "; }
  details.area[open] > summary::before { content:"[−] "; }
  details.area > summary:hover { color:#66ffff; }
  .current { display:block; margin:4px 0 14px; padding:12px 0; border-top:1px solid #333; border-bottom:1px solid #333; color:#00ffff; font-weight:bold; font-size:26px; line-height:1.15; }
  .current small { display:block; color:#53ff4c; font-size:14px; font-weight:bold; margin-top:4px; }
  .tablewrap { overflow-x:auto; -webkit-overflow-scrolling:touch; margin:0 0 10px; }
  table { width:100%; border-collapse:collapse; font-size:14px; min-width:760px; }
  th { text-align:left; color:#00ffff; padding:8px 10px; border-bottom:1px solid #333; cursor:pointer; white-space:nowrap; user-select:none; }
  th[data-sort]:hover { color:#66ffff; }
  th .dir { color:#7a7a7a; }
  td { padding:8px 10px; border-bottom:1px solid #1c1c1c; vertical-align:top; overflow-wrap:anywhere; }
  td.name a { color:#66ccff; font-weight:bold; }
  td.name .title { display:block; color:#aaa; font-size:12px; }
  .status-current { color:#53ff4c; font-weight:bold; } .status-test { color:#ffbe45; } .status-archived, .status-live { color:#7a7a7a; }
  code { color:#9aa3af; font-size:12px; }
  .more { background:#000; color:#aab3bf; border:1px solid #343b45; padding:8px 14px; font:700 12px Courier,monospace; cursor:pointer; margin:0 0 18px; text-transform:uppercase; }
  .more:hover { border-color:#00ffff; color:#00ffff; }
  .noresult { color:#888; padding:20px 0; }
  .footer { margin-top:50px; font-size:14px; color:#aaa; line-height:1.5; }
  .compute { margin-top:18px; padding-top:14px; border-top:1px solid #1f2a20;
    color:#4ade80; font-size:13px; line-height:1.6; }
  .compute strong { color:#86efac; font-weight:600; }
  .compute .figs { color:#34d399; font-variant-numeric:tabular-nums; }
  .compute a { color:#4ade80; text-decoration:underline; }
  .compute .cond { color:#3f9c6a; font-size:12px; }
  .footer a { color:#5a5a5a; }
  details.nest { margin:0 0 14px 18px; border-bottom:0; } details.nest > summary { font-size:18px; padding:8px 0; } details.nest .current { font-size:18px; margin:0; padding:8px 0; border-top:0; } details.nest .current small { font-size:13px; font-weight:normal; }

  /* THE DOORS. Static bytes, no JavaScript, no fetch. Everything below this
     block is drawn by script from a 289 KB catalogue; until 21 September 2026
     that meant the served HTML contained no link to the work at all, so a
     scraper, a link preview or a reader with script disabled saw an empty
     page. A door costs nothing and survives a failed fetch. */
  nav.doors { margin: 0 0 26px; border-top: 1px solid #333; border-bottom: 1px solid #333; padding: 6px 0 10px; }
  nav.doors h2 { font-size: 15px; color: #00ffff; letter-spacing: .5px; margin: 12px 0 8px; text-transform: uppercase; }
  nav.doors a { display: block; font-size: 19px; font-weight: bold; color: #66ccff; padding: 7px 0; border-bottom: 1px solid #1c1c1c; }
  nav.doors a small { display: block; color: #9aa3af; font-size: 13px; font-weight: normal; margin-top: 2px; }
  nav.doors p.note { color: #8a8a8a; font-size: 13px; margin: 10px 0 0; }
@media(max-width:600px){ body{padding:22px;font-size:18px} details.area>summary{font-size:22px} .current{font-size:22px} }
  .working-release { margin:0 0 24px; padding:16px 20px; border:1px solid #53ff4c; background:#07130b; color:#53ff4c; font-family:"Courier New",monospace; }
  .working-release > summary { color:#53ff4c; margin:0 0 6px; font-size:20px; line-height:1.35; letter-spacing:.06em; }
  .working-release p { margin:4px 0 10px; font-size:13px; }
  .working-release a { display:block; color:#53ff4c; padding:7px 0; font-size:18px; font-weight:bold; }
  .working-release a.older { color:#53ff4c; font-size:13px; font-weight:normal; }
  details.working-release > summary, details.working-release > summary:hover { color:#53ff4c; }

/* Current tools first, complete version history retained. */
body{max-width:1040px;padding:28px 32px;font:16px/1.5 "Courier New",Courier,monospace}h1{font-size:28px;letter-spacing:.03em}.mission{max-width:880px;margin:10px 0 24px;color:#bac4c0;font-size:15px}
a:focus-visible,summary:focus-visible,button:focus-visible,input:focus-visible{outline:2px solid #baffb5;outline-offset:4px}
.working-release{padding:12px 18px;margin-bottom:24px;border:1px solid #53ff4c;background:#040c06}details.working-release>summary{font-size:20px;padding:8px 0}.release-label{display:inline-block;font-size:12px;letter-spacing:.03em}.working-release>a{border-top:1px solid #17351e;font-size:17px;padding:12px 0;line-height:1.4}.working-release>a small{display:block;font-size:12px;font-weight:normal;co  … [line shortened here: 624 characters; full line on GitHub]
h2{font-size:13px;letter-spacing:.1em;margin:0 0 8px;color:#b2bcb8}.tool-list>a{display:grid;grid-template-columns:220px 1fr 20px;align-items:center;gap:14px;min-height:48px;padding:8px 0;border-top:1px solid #25302c;color:#53ff4c;font-size:17px;font-weight:bold}.tool-list small{color:#acb8b2;font-size:13px;font-weight:normal}.reference-links{display:flex;flex-wrap:wrap;gap:4px 24px;margin:12px 0   … [line shortened here: 467 characters; full line on GitHub]
.archive-panel{border-top:1px solid #34403a;border-bottom:1px solid #34403a;padding:4px 0}.archive-panel>summary{cursor:pointer;color:#b9c9c0;padding:14px 0;font-size:14px;font-weight:bold;letter-spacing:.04em}.archive-help,.search-label{color:#a3b2aa;font-size:13px}#q{font-size:14px}#menu details.area>summary{font-size:18px;padding:12px 0}#menu details.nest>summary{font-size:15px}#menu .current{f  … [line shortened here: 537 characters; full line on GitHub]
.contribute{margin:24px 0}.contribute p{color:#bac4c0;margin:8px 0;font-size:14px}.contribute a{display:inline-block;color:#53ff4c;padding:8px 0;margin-right:24px;font-size:13px}.footer{border-top:1px solid #25302c;padding-top:14px;margin-top:18px;font-size:11px;color:#829188}.footer p{margin:7px 0}.footer .funding{color:#a3b2aa;font-size:12px}.compute{font-size:11px;margin-top:12px}.compute>summa  … [line shortened here: 544 characters; full line on GitHub]
@media(max-width:600px){body{padding:20px 18px}h1{font-size:25px}.mission{font-size:13px;margin-bottom:18px}.working-release{padding:10px 12px}.release-label{display:block;margin-left:38px;font-size:10px}details.working-release>summary{font-size:18px}.tool-list>a{grid-template-columns:1fr 20px;gap:2px 8px;font-size:16px}.tool-list small{grid-column:1;grid-row:2;font-size:12px}.tool-list span{grid-  … [line shortened here: 525 characters; full line on GitHub]
</style>
<meta name="description" content="Open-source knowledge and tools for electrical energy systems. Explore wiring, renewable energy projects and the electricity network.">
</head>
<body>
<header>
<h1>GLOBALGRID2050</h1>
<p class="mission">Open-source knowledge and tools for electrical energy systems. Document, understand and improve the grid &mdash; together.</p>
</header>
<main id="primary-content">
<details id="current-working-release" class="area working-release" open>
<summary id="working-release-title">VENTUS WIRING <span class="release-label">CURRENT WORKING RELEASE</span></summary>
<p>20260922-A &middot; Simulation environment &middot; NOT A REAL DESIGN</p>
<a href="/ventus/wiring/inverter-48.html">&rarr; DC STRING WIRING <small>24 connected strings &middot; 48 cables &middot; one animated string</small></a>
<a href="/ventus/wiring/inverter-station.html">&rarr; AC LV WIRING <small>28 inverters &middot; 84 phase cables &middot; two transformer sections</small></a>
<details class="older-release"><summary>Previous drawing</summary><a class="older" href="/kuiper-grid/drawing/">Older version: solar array drawing</a></details>
</details>
<nav class="tool-list" aria-labelledby="tools-title">
<h2 id="tools-title">TOOLS</h2>
<a href="./uk_renewables_pipeline/202609082224/">Pipeline News <small>Renewable energy project register</small><span aria-hidden="true">&rarr;</span></a>
<a href="https://ventusltd.github.io/gridatlas/atlas/">Grid Atlas <small>Electricity network mapping</small><span aria-hidden="true">&rarr;</span></a>
<a href="/kuiper-grid/">Kuiper <small>Grid, substation and solar string views</small><span aria-hidden="true">&rarr;</span></a>
<a href="/plant/">Solar string voltage <small>Module count and cold-weather voltage check</small><span aria-hidden="true">&rarr;</span></a>
</nav>
<nav class="reference-links" aria-label="Guides and methods">
<a href="/kuiper-grid/manual.html">User guide</a><a href="/compute/">Calculation methods</a><a href="/kuiper/">Kuiper work browser</a>
</nav>
<details id="version-archive" class="archive-panel">
<summary>ALL TOOLS &amp; VERSION HISTORY</summary>
<p class="archive-help">Earlier releases, development tools and the complete navigation tree. Search the recorded builds by name, date or commit.</p>
<div class="archive-search">
  <label class="search-label" for="q">Search recorded builds</label>
<input type="text" id="q" placeholder="Name, date or commit" autocomplete="off">
  <div class="controls">
    <span class="count" id="count"></span>
  </div>
  <div id="menu"></div>
</div>
<nav class="archive-links" aria-label="Archive and recovery"><a href="/historical_builds.html">Full build archive</a><a href="/homepage_versions/20260922-before-refresh/">Previous homepage &mdash; 22 September 2026</a></nav>
</details>
<section class="contribute" aria-labelledby="contribute-title"><h2 id="contribute-title">CONTRIBUTE</h2>
<p>You do not need to code. Share a source, document a process, report a problem or improve a tool.</p>
<a href="/how_to_work_with_globalgrid2050/">How to contribute &rarr;</a><a href="https://github.com/Ventusltd/globalgrid2050">Source code &rarr;</a>
</section>
</main>
<footer class="footer">
<p class="funding">Funded by VENTUS LTD. Built through open collaboration.</p>
  <p><strong>Disclaimer:</strong> Content provided for general technical documentation and research purposes only.</p>
  <p><a href="./historical_builds.html">Full archive</a></p>
  <details id="gpu-compute" class="compute"><summary>GPU COMPUTE &amp; VERIFICATION</summary>
    <p><strong>GlobalGrid2050 explores current technology with Claude and Codex AI,
    and actively studies <a href="https://github.com/cupy/cupy">CuPy</a> for faster
    independent compute on local machines.</strong> Selected numerical studies use local hardware and comparisons against reference implementations.</p>
    <p class="figs">Taken on one machine, 20 September 2026 &mdash; a complete solar
    string-and-block design space of <strong>1,020,600,000</strong> designs:
    <strong>177,289,777</strong> cases/s on the GPU with CuPy against
    <strong>12,767,553</strong> cases/s on twelve CPU workers, a <strong>13.89&times;</strong>
    difference, the billion run in <strong>5.6 s</strong>. A second kernel reached
    <strong>306,440,267</strong> cases/s, <strong>40.82&times;</strong> its CPU reference.
    Verification: 100,000 cases on a coprime stride, <strong>0 differ</strong> between the
    scalar reference, the CPU vectorisation and the GPU, worst relative difference
    0.00e+00 against a 1e-9 tolerance.</p>
    <p class="cond">Conditions, because a rate without them is not evidence: one
    machine, one 16 GB card that was shared with other work during the runs, single
    and double precision both checked and agreeing on every verdict. CPU watts were
    never recorded &mdash; no wall meter, no RAPL read &mdash; so no efficiency ratio
    between processor and card is stated here or anywhere else in this work. A claim
    of &ldquo;tens of millions a second&rdquo; for a third kernel was tested and
    <em>not</em> reached, falling 3.0&times; short; it is recorded as not reached.
    Method, figures and the solar block models: <a href="./compute/">Independent compute</a> &middot; code at <a href="https://github.com/Ventusltd/gpu-drivers-for-global-grid">gpu-drivers-for-global-grid</a>.</p>
  </details>
</footer>
<script>
/* THREE NESTS, THREE ROWS EACH, EVERYTHING ELSE ON DEMAND.
 *
 * The data is ./catalogue/homepage-catalogue.json, generated - never typed -
 * from the tree and git. The page is a VIEW over it: the nest headline is the
 * one current release, the table beneath shows the three newest rows, and the
 * rest are behind "show more" and the search. At 409 rows or a million, the DOM
 * only ever carries what is on screen; filtering and sorting happen on the
 * array. The same slice-the-view-never-the-data rule as Pipeline News.
 *
 * Columns: stamp-name (yyyymmddhhmm-name-of-the-project, UTC) · status ·
 * commit · barcode. There is no agent column: a version is identified by its
 * UTC stamp-name and its git tree hash, and which agent cut it is not part of
 * that identity. It was drawing attention away from both references, so it is
 * off the page - the agent fields stay in the catalogue and stay searchable. The barcode is the git tree hash, `git rev-parse
 * HEAD:<path>`: a content address that changes if and only if the version
 * changes - the same role the REPD REF plays for a project in Pipeline News.
 * It is what every runner pins, so a CI pin is copied from the table. */
const NESTS = [
  { key: "pipeline-news", title: "Pipeline News", families: ["pipeline-news"], testProject: "test-code-pipeline-news" },
  { key: "grid-atlas",    title: "Grid Atlas",    families: ["grid-atlas"],    testProject: "test-code-grid-atlas" },
  { key: "about-media",   title: "About & Media", families: ["about-media"],   testProject: null },
];
const PAGE = 3;
const state = { q: "", agent: "", status: "", sort: { key: "stamp", dir: -1 }, open: {} };
let ALL = [];
const esc = s => String(s ?? "").replace(/[&<>"']/g, c => ({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[c]));

function rowsFor(nest) {
  return ALL.filter(e => nest.families.includes(e.family) || (nest.testProject && e.project === nest.testProject) || (nest.key === "grid-atlas" && e.project === "test-code-cable-geometry") || (nest.key === "about-media" && e.project === "test-code"));
}
function passes(e) {
  if (state.agent && (e.agent || "") !== state.agent) return false;
  if (state.status && (e.status || "") !== state.status) return false;
  if (state.q) {
    const hay = [e.id, e.title, e.agent, e.agent_source, e.commit, e.tree, e.family, e.status, e.kind].join(" ").toLowerCase();
    if (!hay.includes(state.q)) return false;
  }
  return true;
}
function sortRows(rows) {
  const { key, dir } = state.sort;
  return rows.slice().sort((a, b) => {
    const x = String(a[key] ?? ""), y = String(b[key] ?? "");
    if (x === y) return (b.stamp || "").localeCompare(a.stamp || "");
    return x < y ? -dir : dir;
  });
}
function row(e) {
  const tree = e.tree ? `<code title="${esc(e.tree)} — click to copy" data-copy="${esc(e.tree)}" style="cursor:copy">${esc(e.tree.slice(0, 12))}</code>` : `<code>—</code>`;
  const commit = e.commit ? `<code title="${esc(e.commit_full || e.commit)}">${esc(e.commit)}</code>` : `<code>—</code>`;
  return `<tr>
    <td class="name"><a href="${encodeURI(e.url)}">${esc(e.id)}</a><span class="title">${esc(e.title)}</span></td>
    <td class="status-${esc(e.status || "")}">${esc(e.status || "")}</td>
    <td>${commit}</td><td>${tree}</td></tr>`;
}
function th(label, key) {
  const on = state.sort.key === key;
  return `<th data-sort="${key}">${label} <span class="dir">${on ? (state.sort.dir < 0 ? "▼" : "▲") : "↕"}</span></th>`;
}
/* ARCHIVED, NOT DELETED.
 *
 * The owner asked for the site to be archived down to a search box and Pipeline
 * News. Archived is the operative word: the catalogue still carries all 400-odd
 * versions, the generator is untouched, and nothing has been removed from the
 * data. What changed is the VIEW - the same slice-the-view-never-the-data rule
 * the table has always followed.
 *
 * So Pipeline News is the page. Grid Atlas and About & Media are not shown
 * until the reader asks for them, and the moment anything is typed in the
 * search box or a filter is pressed, every nest returns and the search runs
 * across all of them. A homepage that hid its own history behind a link nobody
 * clicks would not be an archive, it would be a loss. */
const DEFAULT_NESTS = ["pipeline-news"];
function browsing() { return Boolean(state.q || state.agent || state.status); }

function build() {
  const menu = document.getElementById("menu");
  let html = "", total = 0, shown = 0;
  const nests = browsing() ? NESTS : NESTS.filter(n => DEFAULT_NESTS.includes(n.key));
  for (const nest of nests) {
    const all = rowsFor(nest);
    const current = all.find(e => e.status === "current");
    const rows = sortRows(all.filter(passes));
    total += rows.length;
    const limit = state.open[nest.key] ? rows.length : PAGE;
    const visible = rows.slice(0, limit); shown += visible.length;
    const head = current && !state.q && !state.agent && !state.status
      ? `<a class="current" href="${encodeURI(current.url)}">${esc(current.id)}</a>` : "";
    const table = rows.length ? `<div class="tablewrap"><table><thead><tr>${th("Version · UTC stamp-name", "id")}${th("Status", "status")}${th("Commit", "commit")}<th title="git rev-parse HEAD:&lt;path&gt; — a content address: it changes if and only if the version changes. The value every runner pins.">Barcode · git tree</th></tr></thead><tbody>${visible.map(row).join("")}</tbody></table></div>` :  … [line shortened here: 459 characters; full line on GitHub]
    const more = rows.length > PAGE ? `<button class="more" data-more="${nest.key}">${state.open[nest.key] ? "show 3" : `show all ${rows.length}`}</button>` : "";
    const open = browsing() ? " open" : "";
    /* JUST THE WORKING VERSION.
     *
     * The owner, after publishing 202609081016 on the offshore cable engine:
     * archive everything else, leave just this working version. So the default
     * view is the one current release and nothing beneath it - no table of older
     * releases, no show-all. Every one of them is still in the catalogue and
     * returns the moment anything is typed in the search or a filter is pressed;
     * the notice below says how many and how. Archived, not deleted. */
    const body = browsing() ? `${table}${more}` : "";
    const summary = browsing()
      ? `${esc(nest.title)} <span style="color:#7a7a7a;font-size:15px">(${rows.length})</span>`
      : esc(nest.title);
    html += `<details class="area"${open}><summary>${summary}</summary>${head}${body}</details>`;
  }
  /* Say what is being withheld and how to reach it, in the place the reader is
     already looking. An archive nobody can find is indistinguishable from a
     deletion. */
  if (!browsing()) {
    html += `<details class="area"><summary>Grid Atlas</summary><a class="current" href="https://ventusltd.github.io/gridatlas/atlas/">Grid Atlas</a></details>`;
    html += `<details class="area"><summary>Grid Engine</summary><details class="area nest"><summary>Sandbox</summary><a class="current" href="https://ventusltd.github.io/ventus-grid-engine/?graph=overview">Overview</a><a class="current" href="https://ventusltd.github.io/ventus-grid-engine/?graph=engine-graph">Module Map</a><a class="current" href="https://ventusltd.github.io/stars/table.html?bloc  … [line shortened here: 2,010 characters; full line on GitHub]
    html += `<details class="area"><summary>Integrated Development Environments</summary><details class="area nest"><summary>Energy Data</summary><a class="current" href="https://globalgrid2050.com/testcode/202609151428/">UK Renewables Project Register &middot; 202609151428</a><a class="current" href="https://globalgrid2050.com/testcode/202609150125/">Energy Demand by Sector &middot; 202609150125<  … [line shortened here: 1,849 characters; full line on GitHub]
    html += `<details class="area"><summary>Testcode</summary><details class="area nest"><summary>Code Wafer</summary><a class="current" href="https://globalgrid2050.com/testcode/202609160224/">GlobalGrid2050 code represented on a wafer &middot; 202609160224</a><a class="current" href="https://globalgrid2050.com/testcode/202609160207/">Line Wafer &middot; 202609160207</a></details></details>`;
    html += `<details class="area"><summary>The Translator of Systems</summary><details class="area nest"><summary>One wafer, every system</summary><a class="current" href="https://globalgrid2050.com/testcode/wafer-development-environment/202609192215-proof-s0004/">The real-systems wafer &middot; 202609180245</a><a class="current" href="https://globalgrid2050.com/testcode/wafer-development-environ  … [line shortened here: 2,948 characters; full line on GitHub]
    html += `<details class="area" open><summary>Kuiper<a class="current" href="/kuiper-grid/drawing/">Solar array drawing<small>Place modules, edit string wiring and explore a generic farm</small></a></summary><details class="area nest"><summary>Earlier examples, development builds and manual</summary><a class="current" href="/plant/">Earlier plant examples<small>Cold-morning string voltage examp  … [line shortened here: 1,197 characters; full line on GitHub]
    html += `<details class="area"><summary>Kuiper: proofs</summary><details class="area nest"><summary>Every line ever written, one wafer</summary><a class="current" href="https://globalgrid2050.com/testcode/wafer-development-environment/202609192238-proof-k0030/">202609192238-proof-k0030<small># Kuiper: the engineering behind this site, and the code behind any line of it</small></a><a class="cur  … [line shortened here: 6,612 characters; full line on GitHub]
    html += `<details class="area"><summary>Cable Cross-sections</summary><details class="area nest"><summary>Drawn on the wafer, layer by layer</summary><a class="current" href="https://globalgrid2050.com/testcode/wafer-development-environment/202609190330-cable-cross-sections/?draw=cable">Single core 800 mm&sup2; aluminium, 19/33 kV &middot; overall 63.0 mm</a><a class="current" href="https://gl  … [line shortened here: 4,070 characters; full line on GitHub]
  }
  menu.innerHTML = html;
  document.getElementById("count").textContent = browsing() ? `${shown} of ${total} shown` : "";
}
document.addEventListener("click", ev => {
  const c = ev.target.closest("[data-copy]");
  if (c && navigator.clipboard) { navigator.clipboard.writeText(c.dataset.copy); c.textContent = "copied"; setTimeout(() => { c.textContent = c.dataset.copy.slice(0, 12); }, 900); return; }
  const t = ev.target.closest("[data-more],[data-status],th[data-sort]");
  if (!t) return;
  if (t.dataset.more !== undefined) { state.open[t.dataset.more] = !state.open[t.dataset.more]; build(); }
  else if (t.dataset.status !== undefined) { state.status = t.dataset.status; document.querySelectorAll("[data-status]").forEach(b => b.classList.toggle("on", b === t)); build(); }
  else if (t.dataset.sort) { const k = t.dataset.sort; state.sort = { key: k, dir: state.sort.key === k ? -state.sort.dir : -1 }; build(); }
});
document.getElementById("q").addEventListener("input", e => { state.q = e.target.value.trim().toLowerCase(); build(); });
fetch("./catalogue/homepage-catalogue.json").then(r => r.json()).then(d => { ALL = d.entries; build(); })
  .catch(err => { document.getElementById("menu").innerHTML = `<p class="noresult">Catalogue unavailable: ${esc(err.message)}. <a href="./historical_builds.html">Full archive</a>.</p>`; });
</script>
</body>
</html>

Versioned Homepage

A JavaScript file in the assets folder of GlobalGrid2050 that draws active pages. It fetches JSON (`fetchJson`), validates presentation (`validatePresentation`) and validates types (`validateTypes`).

interactionglobalgrid2050 / homepage-shell/assets/versioned-homepage.js · lines 1–297 of 297 · Entry point · pattern bounded (shared by 4 files)

What it does
It draws active pages. Defines 17 functions or classes, including matchesQuery, fetchJson, onDemand, hydrate, node. Side effects: changes the web page (DOM); makes network requests.
Inputs & outputs
In: JSON file homepage.json; JSON file active-pages.json; JSON file presentation.json; JSON file entity-types.json.
Downstream impact
Used directly by 2 files: Homepage V128 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v128.html); Homepage V130 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v130.html).
What it achieves
Defines `matchesQuery`, `fetchJson`, `onDemand` and 14 more. It responds to click, toggle and pointerdown events.
Why it matters
Loaded by the Homepage V128 page at https://globalgrid2050.com/homepage_versions/homepage_v128.html and 1 other page.
Application
globalgrid2050 · homepage-shell/assets · script
Uses
none found
Used by
loaded by Homepage V128 (script src), loaded by Homepage V130 (script src), mentioned in Standalone (comment link)
Produces
matchesQuery, fetchJson, onDemand, hydrate, node, safeUrl, appUrl, link, validate, releaseRow, validatePresentation, developmentStrip
Defines here
matchesQuery, fetchJson, onDemand, hydrate, node, safeUrl, appUrl, link, validate, releaseRow, validatePresentation, developmentStrip, validateTypes, bounded, render, entityNode, renderTable
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 homepage-shell/assets/versioned-homepage.js:1-297 · blob 1dc7ebe9ccfdc5adc33b32bc24a063cb2ed08147 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom, network · domain stage: unknown · users: none · canonical: production_core
(function () {
  'use strict';
  const configUrl = new URL('../data/homepage.json', document.currentScript.src);
  const activityUrl = new URL('../data/active-pages.json', document.currentScript.src);
  const presentationUrl = new URL('../data/presentation.json', document.currentScript.src);
  const typesUrl = new URL('../data/entity-types.json', document.currentScript.src);
  let entityTypes = {};
  const mount = document.getElementById('nests');
  const search = document.getElementById('homepageSearch');
  const status = document.getElementById('searchStatus');
  const catalogueBody = document.getElementById('catalogueRows');
  const searchText = new WeakMap();
  function matchesQuery(entity, query) {
    if (!searchText.has(entity)) { const meta = entityTypes[entity.id]; searchText.set(entity, [entity.id, entity.title, entity.subtitle, entity.description, meta.type, meta.purpose, ...meta.audience, ...meta.roles, ...entity.releases.map(release => [release.id, release.label, release.url, release.status, release.source_ref].join(' '))].join(' ').toLocaleLowerCase()); }
    return searchText.get(entity).includes(query);
  }
  async function fetchJson(url) {
    const controller = new AbortController();
    const timeout = setTimeout(() => controller.abort(), 8000);
    try {
      const response = await fetch(url, { signal: controller.signal });
      if (!response.ok) throw new Error('Catalogue unavailable');
      return await response.json();
    } finally { clearTimeout(timeout); }
  }
  function onDemand(details, populate) {
    let ready = false;
    const hydrate = () => {
      if (ready) return;
      populate();
      ready = true;
    };
    details.querySelector('summary').addEventListener('click', hydrate);
    details.addEventListener('toggle', () => { if (details.open) hydrate(); });
    return hydrate;
  }
  const node = (tag, text, className) => {
    const element = document.createElement(tag);
    if (text !== undefined) element.textContent = text;
    if (className) element.className = className;
    return element;
  };
  function safeUrl(value) {
    if (typeof value !== 'string') throw new Error('Missing URL');
    const url = new URL(value);
    if (url.protocol !== 'https:' || url.username || url.password) throw new Error('Unsafe URL');
    return value;
  }
  function appUrl(value) {
    const url = new URL(safeUrl(value));
    if (/(^|\.)github\.com$/i.test(url.hostname) || /(^|\.)githubusercontent\.com$/i.test(url.hostname)) throw new Error('Expected an app URL');
    return value;
  }
  function link(label, url, className) {
    const a = node('a', label, className);
    a.href = appUrl(url);
    return a;
  }
  function validate(data) {
    if (data.schema_version !== 1 || !Array.isArray(data.entities) || !Array.isArray(data.view?.items)) throw new Error('Unsupported catalogue');
    const ids = new Set();
    for (const entity of data.entities) {
      if (typeof entity.id !== 'string' || ids.has(entity.id) || !entity.title || !Array.isArray(entity.releases)) throw new Error('Invalid entity');
      ids.add(entity.id);
      const releases = new Set();
      for (const release of entity.releases) {
        if (!release.id || releases.has(release.id) || !release.label || !['available', 'candidate'].includes(release.status)) throw new Error('Invalid release');
        releases.add(release.id);
        safeUrl(release.url);
        if (release.archive_url) safeUrl(release.archive_url);
        if (release.published_at != null && release.published_at !== '' && !Number.isFinite(Date.parse(release.published_at))) throw new Error('Invalid release date');
      }
      if (!entity.releases.some(release => release.id === entity.operative_release_id && release.status === 'available')) throw new Error('Missing operative release');
    }
    const byId = new Map(data.entities.map(entity => [entity.id, entity]));
    for (const entity of data.entities) {
      const seen = new Set([entity.id]);
      let parent = entity.parent_id;
      while (parent) {
        if (!byId.has(parent) || seen.has(parent)) throw new Error('Invalid parent');
        seen.add(parent);
        parent = byId.get(parent).parent_id;
      }
    }
    const pinned = new Set();
    for (const item of data.view.items) {
      if (!byId.has(item.entity_id) || pinned.has(item.entity_id) || byId.get(item.entity_id).parent_id) throw new Error('Invalid pinned entity');
      pinned.add(item.entity_id);
    }
    safeUrl(data.view.archive_url);
    if (data.development !== undefined && !Array.isArray(data.development)) throw new Error('Invalid development list');
    for (const item of data.development || []) {
      if (!item.label || item.status !== 'In development') throw new Error('Invalid development item');
      safeUrl(item.url);
    }
    return byId;
  }
  function releaseRow(release, operative) {
    const row = node('div', undefined, 'release');
    row.append(node('span', operative ? 'Operative' : release.status === 'candidate' ? 'Candidate' : 'Archived', 'release-state'));
    let target = release.url;
    if (!operative && release.archive_url && release.archive_kind !== 'manifest') {
      try { target = appUrl(release.archive_url); } catch (_) { /* Keep the app link. */ }
    }
    row.append(link(release.label, target, 'release-link'));
    return row;
  }
  function validatePresentation(config, byId) {
    if (!config || config.schema_version !== 1 || !Number.isInteger(config.page_size) || config.page_size < 1 || config.page_size > 100 || !Array.isArray(config.highlights) || config.highlights.length > 4) throw new Error('Invalid presentation settings');
    const seen = new Set();
    for (const item of config.highlights) {
      if (!byId.has(item.entity_id) || seen.has(item.entity_id) || typeof item.label !== 'string' || !item.label.trim() || item.label.length > 40) throw new Error('Invalid highlight');
      seen.add(item.entity_id);
    }
  }
  function developmentStrip(items) {
    if (!items.length) return;
    const strip = node('section', undefined, 'development-strip');
    strip.setAttribute('aria-label', 'Explore our apps');
    const label = node('span', 'GLOBALGRID2050', 'development-label');
    const viewport = node('div', undefined, 'development-viewport');
    const track = node('div', undefined, 'development-track');
    const group = node('div', undefined, 'development-group');
    items.forEach(item => group.append(link(item.label, item.url)));
    track.append(group);
    const clone = group.cloneNode(true);
    clone.setAttribute('aria-hidden', 'true');
    clone.querySelectorAll('a').forEach(a => a.tabIndex = -1);
    // Keep the visible repeat clickable without moving focus into hidden content.
    clone.addEventListener('pointerdown', event => event.preventDefault());
    track.append(clone);
    viewport.append(track);
    strip.append(label, viewport);
    document.getElementById('highlights').after(strip);
  }
  function validateTypes(metadata, byId) {
    const types = new Set(['engine', 'application', 'dataset', 'equipment', 'project', 'reference', 'drawing', 'catalogue']);
    if (!metadata || metadata.schema_version !== 1 || !metadata.records || typeof metadata.records !== 'object' || Array.isArray(metadata.records) || Object.keys(metadata.records).length !== byId.size) throw new Error('Invalid entity metadata');
    const bounded = (value, limit) => typeof value === 'string' && value.trim().length > 0 && value.length <= limit;
    for (const [id, meta] of Object.entries(metadata.records)) {
      if (!byId.has(id) || !meta || !types.has(meta.type) || !bounded(meta.purpose, 1000) || !Array.isArray(meta.audience) || !meta.audience.length || meta.audience.length > 10 || !meta.audience.every(value => bounded(value, 100))) throw new Error('Invalid entity metadata record');
      if (!Array.isArray(meta.roles) || meta.roles.length > 10 || !meta.roles.every(value => bounded(value, 100)) || new Set(meta.roles).size !== meta.roles.length) throw new Error('Invalid entity roles');
      if (meta.capability_evidence !== undefined) {
        if (!meta.capability_evidence || !bounded(meta.capability_evidence.summary, 1000)) throw new Error('Invalid capability evidence');
        appUrl(meta.capability_evidence.url);
      }
    }
    return metadata.records;
  }
  function render(data, presentation, metadata) {
    const byId = validate(data);
    validatePresentation(presentation, byId);
    entityTypes = validateTypes(metadata, byId);
    const highlights = document.getElementById('highlightCards');
    highlights.replaceChildren();
    for (const item of presentation.highlights) {
      const entity = byId.get(item.entity_id);
      const release = entity.releases.find(release => release.id === entity.operative_release_id);
      const card = link('', release.url, 'highlight-card');
      card.dataset.entityId = entity.id;
      card.append(node('span', item.label, 'highlight-label'), node('strong', entity.title));
      if (entity.subtitle) card.append(node('span', entity.subtitle, 'highlight-description'));
      highlights.append(card);
    }
    document.getElementById('highlights').hidden = presentation.highlights.length === 0;
    const records = [];
    const childrenByParent = new Map();
    for (const entity of data.entities) {
      if (!childrenByParent.has(entity.parent_id)) childrenByParent.set(entity.parent_id, []);
      childrenByParent.get(entity.parent_id).push(entity);
    }
    function entityNode(entity, position, open) {
      const details = node('details', undefined, 'entity');
      details.id = entity.id;
      details.open = Boolean(open);
      const summary = node('summary');
      const title = node('span', entity.title, 'title');
      if (entity.subtitle) title.append(node('small', entity.subtitle));
      summary.append(node('span', position, 'number'), title);
      const inside = node('div', undefined, 'inside');
      if (entity.description) inside.append(node('p', entity.description));
      const operative = entity.releases.find(release => release.id === entity.operative_release_id);
      inside.append(link((entity.launch_label || 'Open ' + entity.title) + ' →', operative.url, 'launch'));
      inside.append(releaseRow(operative, true));
      const history = node('details', undefined, 'versions');
      const other = entity.releases.filter(release => release.id !== operative.id).sort((a, b) => (Date.parse(b.published_at) || 0) - (Date.parse(a.published_at) || 0));
      history.append(node('summary', 'Versions (' + other.length + ')'));
      const hydrateHistory = onDemand(history, () => {
        if (other.length) other.forEach(release => history.append(releaseRow(release, false)));
        else history.append(node('p', 'No earlier versions listed.'));
      });
      inside.append(history);
      const record = { entity, details, history, hydrateHistory, children: [] };
      records.push(record);
      for (const child of childrenByParent.get(entity.id) || []) {
        const childNode = entityNode(child, '↳', false);
        record.children.push(child.id);
        inside.append(childNode);
      }
      details.append(summary, inside);
      return details;
    }
    const fragment = document.createDocumentFragment();
    data.view.items.forEach((item, index) => fragment.append(entityNode(byId.get(item.entity_id), String(index + 1).padStart(2, '0'), item.open)));
    mount.replaceChildren(fragment);
    let page = 0;
    let filtered = data.entities;
    function renderTable() {
      catalogueBody.replaceChildren();
      for (const entity of filtered.slice(page * presentation.page_size, (page + 1) * presentation.page_size)) {
      const operative = entity.releases.find(release => release.id === entity.operative_release_id);
      const row = node('tr');
      row.dataset.entityId = entity.id;
      const name = node('th');
      name.scope = 'row';
      name.append(link(entity.title, operative.url));
      name.append(node('small', entity.id, 'entity-key'));
      const versions = node('details', undefined, 'table-versions');
      versions.append(node('summary', operative.label));
      onDemand(versions, () => { for (const release of entity.releases) {
        const version = releaseRow(release, release.id === operative.id);
        version.append(node('small', release.id, 'entity-key'));
        versions.append(version);
      } });
      const versionCell = node('td');
      versionCell.append(versions);
      const meta = entityTypes[entity.id];
      const typeCell = node('td');
      const semantic = node('details', undefined, 'entity-type');
      semantic.append(node('summary', meta.type));
      onDemand(semantic, () => {
        semantic.append(node('p', 'Intended purpose: ' + meta.purpose), node('p', 'For: ' + meta.audience.join(', ')));
        if (meta.roles.length) semantic.append(node('p', 'Intended roles: ' + meta.roles.join(', ')));
        if (meta.capability_evidence) { semantic.append(node('p', 'Recorded evidence: ' + meta.capability_evidence.summary), link('View evidence', meta.capability_evidence.url)); }
      });
      typeCell.append(semantic);
      row.append(name, typeCell, node('td', entity.subtitle || byId.get(entity.parent_id)?.title || '\u2014'), versionCell);
      catalogueBody.append(row);
      }
      const count = filtered.length;
      document.getElementById('catalogueEmpty').hidden = count > 0;
      document.getElementById('cataloguePage').textContent = count ? (page * presentation.page_size + 1) + '\u2013' + Math.min((page + 1) * presentation.page_size, count) + ' of ' + count + ' apps' : '0 apps';
      document.getElementById('cataloguePrevious').disabled = page === 0;
      document.getElementById('catalogueNext').disabled = (page + 1) * presentation.page_size >= count;
    }
    document.getElementById('cataloguePagination').hidden = false;
    document.getElementById('cataloguePrevious').addEventListener('click', () => { if (page > 0) { page--; renderTable(); } });
    document.getElementById('catalogueNext').addEventListener('click', () => { if ((page + 1) * presentation.page_size < filtered.length) { page++; renderTable(); } });
    renderTable();
    document.getElementById('catalogue').hidden = false;
    document.getElementById('archiveLink').href = appUrl(data.view.archive_url);
    document.getElementById('searchControls').hidden = false;
    let saved = null;
    search.addEventListener('input', () => {
      const query = search.value.trim().toLocaleLowerCase();
      if (query && !saved) saved = new Map(Array.from(mount.querySelectorAll('details'), detail => [detail, detail.open]));
      const matches = new Map();
      for (const record of records.slice().reverse()) {
        const ownMatch = matchesQuery(record.entity, query);
        const match = ownMatch || record.children.some(id => matches.get(id));
        matches.set(record.entity.id, match);
        record.details.hidden = !match;
        if (query) {
          record.details.open = match;
          record.history.open = record.entity.releases.some(release => release.id !== record.entity.operative_release_id && [release.label, release.url, release.status, release.source_ref].join(' ').toLocaleLowerCase().includes(query));
          if (record.history.open) record.hydrateHistory();
        }
      }
      if (!query && saved) {
        saved.forEach((open, detail) => { detail.open = open; });
        saved = null;
      }
      filtered = data.entities.filter(entity => matchesQuery(entity, query));
      page = 0;
      renderTable();
      const count = filtered.length;
      status.textContent = query ? count ? count + ' matching apps and versions.' : 'No matching tools or versions.' : '';
    });
  }
  Promise.all([configUrl, presentationUrl, typesUrl].map(fetchJson)).then(([data, presentation, metadata]) => {
    render(data, presentation, metadata);
    // Activity is optional: a missing feed must never hide the main collection.
    fetchJson(activityUrl).then(feed => {
      if (!Array.isArray(feed.items)) throw new Error('Invalid app list');
      for (const item of feed.items) {
        if (typeof item.label !== 'string' || !item.label.trim()) throw new Error('Missing app label');
        appUrl(item.url);
      }
      developmentStrip(feed.items);
    }).catch(() => { /* Keep the collection available without a ticker. */ });
  }).catch(error => {
    status.textContent = 'Version details are unavailable. The main links below remain available.';
    console.error('Homepage catalogue:', error);
  });
}());