In this section
- GlobalGrid2050 — Time to 2050 Page render · globalgrid2050 / time_to_2050/index.html lines 1–223
- GlobalGrid2050 — V11 Page render · globalgrid2050 / v11/index.html lines 1–58
- Ventus Card render · globalgrid2050 / ventus/wiring/VENTUS-card.js lines 1–277
GlobalGrid2050 — Time to 2050 Page
A web page that draws SVG graphics. Published at https://globalgrid2050.com/time_to_2050/.
renderglobalgrid2050 / time_to_2050/index.html · lines 1–223 of 223 · Entry point
- What it does
- It draws its content. Defines update. Side effects: changes the web page (DOM).
- Inputs & outputs
- Out: web page; SVG drawing.
- Downstream impact
- It is itself an entry point, published at https://globalgrid2050.com/time_to_2050/.
- What it achieves
- Defines `update`.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- globalgrid2050 · time_to_2050 · page
- Uses
- none found
- Used by
- none found
- Produces
- update
- Defines here
- update
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 time_to_2050/index.html:1-223 · blob 7618363799f666ae86fa5767ec3d2b2890714d80 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: unknown · users: none · canonical: production_core
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hourglass to 2050</title>
<style>
:root {
--ink: #ffffff;
--sand: #ffffff;
--bg: #000000;
}
body {
margin: 0;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: var(--bg);
font-family: 'Courier New', Courier, monospace;
color: var(--ink);
}
.wrap {
display: flex;
flex-direction: column;
align-items: center;
gap: 1.4em;
padding: 2em 1em;
text-align: center;
}
.hourglass {
width: min(60vmin, 300px);
height: auto;
}
.glass-title {
font-size: clamp(1.1rem, 5vmin, 1.6rem);
font-weight: bold;
letter-spacing: 0.08em;
}
.today-countdown {
font-size: clamp(1.3rem, 6vmin, 2rem);
font-weight: bold;
letter-spacing: 0.06em;
font-variant-numeric: tabular-nums;
margin-top: -0.6em;
}
.time-display {
font-size: clamp(1.6rem, 7vmin, 2.6rem);
font-weight: bold;
letter-spacing: 0.06em;
font-variant-numeric: tabular-nums;
}
.date-display {
font-size: clamp(1rem, 4.5vmin, 1.4rem);
font-weight: bold;
letter-spacing: 0.04em;
}
.countdown-value {
font-size: clamp(1rem, 4.5vmin, 1.3rem);
font-weight: bold;
font-variant-numeric: tabular-nums;
}
/* Falling sand stream animation */
.stream-dash {
stroke-dasharray: 3 4;
animation: fall 0.5s linear infinite;
}
@keyframes fall {
to { stroke-dashoffset: -7; }
}
@media (prefers-reduced-motion: reduce) {
.stream-dash { animation: none; }
}
</style>
</head>
<body>
<div class="wrap">
<div class="glass-title">Time Left Today</div>
<div class="today-countdown" id="todayCountdown"></div>
<svg class="hourglass" viewBox="0 0 200 320" aria-label="Hourglass showing time remaining today">
<defs>
<!-- Top bulb interior shape -->
<clipPath id="topClip">
<path d="M40 30 H160 V60 C160 100 130 130 104 152 H96 C70 130 40 100 40 60 Z"/>
</clipPath>
<!-- Bottom bulb interior shape -->
<clipPath id="bottomClip">
<path d="M96 168 H104 C130 190 160 220 160 260 V290 H40 V260 C40 220 70 190 96 168 Z"/>
</clipPath>
</defs>
<!-- Top sand (drains as 2050 approaches) -->
<g clip-path="url(#topClip)">
<rect id="topSand" x="40" y="30" width="120" height="122" fill="var(--sand)" opacity="0.9"/>
</g>
<!-- Bottom sand (fills as 2050 approaches) -->
<g clip-path="url(#bottomClip)">
<rect id="bottomSand" x="40" y="168" width="120" height="122" fill="var(--sand)" opacity="0.9"/>
</g>
<!-- Falling stream through the neck -->
<line id="stream" class="stream-dash" x1="100" y1="150" x2="100" y2="240"
stroke="var(--sand)" stroke-width="2.5" opacity="0.85"/>
<!-- Glass outline -->
<path d="M40 30 H160 V60 C160 100 130 130 104 152 V168 C130 190 160 220 160 260 V290 H40 V260 C40 220 70 190 96 168 V152 C70 130 40 100 40 60 Z"
fill="none" stroke="var(--ink)" stroke-width="4" stroke-linejoin="round"/>
<!-- Wooden-style frame: top and bottom caps -->
<rect x="26" y="14" width="148" height="16" rx="4" fill="var(--bg)" stroke="var(--ink)" stroke-width="4"/>
<rect x="26" y="290" width="148" height="16" rx="4" fill="var(--bg)" stroke="var(--ink)" stroke-width="4"/>
<!-- Side posts -->
<line x1="32" y1="30" x2="32" y2="290" stroke="var(--ink)" stroke-width="4"/>
<line x1="168" y1="30" x2="168" y2="290" stroke="var(--ink)" stroke-width="4"/>
</svg>
<div class="time-display" id="timeDisplay"></div>
<div class="date-display" id="dateDisplay"></div>
<div>
<div class="countdown-value" id="countdownValue"></div>
</div>
</div>
<script>
const timeDisplay = document.getElementById('timeDisplay');
const dateDisplay = document.getElementById('dateDisplay');
const countdownValue = document.getElementById('countdownValue');
const todayCountdown = document.getElementById('todayCountdown');
const topSand = document.getElementById('topSand');
const bottomSand = document.getElementById('bottomSand');
const stream = document.getElementById('stream');
// Daily hourglass: flips at 00:00 local time on the viewer's device.
// Top bulb is 100% at midnight and drains to 0% at 23:59:59.999;
// the bottom fills in step. The 2050 countdown line is unaffected.
const target = new Date(2050, 0, 1, 0, 0, 0);
const TOP_Y = 30, TOP_H = 122; // top sand area (full bulb)
const BOT_Y = 168, BOT_H = 122; // bottom sand area
function update() {
const now = new Date();
// Digital time (24h, local)
timeDisplay.textContent = now.toLocaleTimeString('en-GB');
// British date: Wednesday 10 June 2026
dateDisplay.textContent = now.toLocaleDateString('en-GB', {
weekday: 'long', day: 'numeric', month: 'long', year: 'numeric'
});
// Countdown to 2050
let diff = target - now;
if (diff <= 0) {
countdownValue.textContent = 'Welcome to 2050!';
stream.style.display = 'none';
topSand.setAttribute('height', 0);
bottomSand.setAttribute('y', BOT_Y);
bottomSand.setAttribute('height', BOT_H);
return;
}
const days = Math.floor(diff / 86400000);
let rem = diff - days * 86400000;
const hours = Math.floor(rem / 3600000); rem -= hours * 3600000;
const mins = Math.floor(rem / 60000); rem -= mins * 60000;
const secs = Math.floor(rem / 1000);
countdownValue.textContent =
String(hours).padStart(2, '0') + ':' +
String(mins).padStart(2, '0') + ':' +
String(secs).padStart(2, '0') + ' \u00B7 ' +
days.toLocaleString() + ' days to 2050';
// Sand level = fraction of the viewer's local day elapsed (00:00 -> 24:00)
const msToday = ((now.getHours() * 60 + now.getMinutes()) * 60
+ now.getSeconds()) * 1000 + now.getMilliseconds();
const frac = msToday / 86400000;
// Time remaining until the end of today (local midnight)
let remMs = 86400000 - msToday;
const remH = Math.floor(remMs / 3600000); remMs -= remH * 3600000;
const remM = Math.floor(remMs / 60000); remMs -= remM * 60000;
const remS = Math.floor(remMs / 1000);
todayCountdown.textContent =
String(remH).padStart(2, '0') + ':' +
String(remM).padStart(2, '0') + ':' +
String(remS).padStart(2, '0');
// Top bulb: sand sits at the bottom of the bulb and shrinks upward...
// physically sand drains from the bottom, so the remaining pile's top
// surface drops: remaining height anchored at the bulb's base.
const topRemainH = TOP_H * (1 - frac);
topSand.setAttribute('y', TOP_Y + (TOP_H - topRemainH));
topSand.setAttribute('height', topRemainH);
// Bottom bulb: pile grows from empty at midnight to full by 23:59:59.
const botH = BOT_H * frac;
bottomSand.setAttribute('y', BOT_Y + (BOT_H - botH));
bottomSand.setAttribute('height', botH);
}
update();
setInterval(update, 250);
</script>
</body>
</html>GlobalGrid2050 — V11 Page
A web page that loads pinned (`loadPinned`). Published at https://globalgrid2050.com/v11/. It loads pinned (`loadPinned`).
renderglobalgrid2050 / v11/index.html · lines 1–58 of 58 · Entry point
- What it does
- It draws its content. Defines loadPinned. Side effects: changes the web page (DOM).
- Inputs & outputs
- Out: web page.
- Downstream impact
- It is itself an entry point, published at https://globalgrid2050.com/v11/.
- What it achieves
- V11 Solar DC Topology Engine — Validated Full-Array Build. It responds to click and load events.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- globalgrid2050 · v11 · page
- Uses
- none found
- Used by
- none found
- Produces
- loadPinned
- Defines here
- loadPinned
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 v11/index.html:1-58 · blob 167526894fd60ae49c93f458489755a6590852c0 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: unknown · users: none · canonical: production_core
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<title>V11 Solar DC Topology Engine — Validated Full-Array Build</title>
<style>
:root{color-scheme:dark;--bg:#05090d;--panel:#0b151d;--line:#29485b;--text:#e9f4fa;--muted:#91a9b8;--cyan:#51d8ff;--amber:#ffb84d;--green:#55dda0}
*{box-sizing:border-box}html,body{margin:0;min-height:100%;background:var(--bg);color:var(--text);font:14px/1.45 ui-monospace,SFMono-Regular,Menlo,monospace}header{padding:14px 16px;border-bottom:1px solid var(--line);background:var(--panel);position:sticky;top:0;z-index:2}.top{display:flex;justify-content:space-between;gap:12px;align-items:center;flex-wrap:wrap}.eyebrow{color:var(--cyan);font-wei … [line shortened here: 1,793 characters; full line on GitHub]
</style>
</head>
<body>
<header>
<div class="top">
<div>
<div class="eyebrow">GLOBALGRID2050 · V11 VALIDATED BUILD</div>
<h1>Solar DC Topology Analysis Engine</h1>
<div class="status">Full-array V8-style topology · immutable tested commit</div>
</div>
<div class="actions">
<a href="../">GlobalGrid2050 home</a>
<a href="https://github.com/Ventusltd/v11/pull/3">PR 3</a>
<a href="https://github.com/Ventusltd/v11/actions/runs/30861254944">Validation run</a>
<a class="primary" id="open-live" href="https://rawcdn.githack.com/Ventusltd/v11/f870883dfdfcabf2edcc800ff7a17e41fb0aa05a/browser/workbench.html">Open full page</a>
<button id="reload" type="button">Reload pinned build</button>
</div>
</div>
<p class="note">Pinned to the validated product commit below: 24 separate strings × 30 modules, 12 MPPT groups, 24 physical inputs, Leapfrog/Sequential/Compare modes and mobile-safe scrolling. The V10 laboratory remains read-only and separate.</p>
<div class="authority" aria-label="V11 validation authority">
<div><span>Tested product SHA</span><strong>f870883dfdfcabf2edcc800ff7a17e41fb0aa05a</strong></div>
<div class="pass"><span>Validation result</span><strong>PASS · run 30861254944</strong></div>
<div><span>Chromium evidence</span><strong>8874417285</strong></div>
<div><span>Public endpoint evidence</span><strong>8874409833</strong></div>
</div>
</header>
<main>
<section class="frame-shell">
<div class="frame-label"><span>Validated V11 full-array workbench</span><span id="loaded-at">loading…</span></div>
<iframe id="v11-frame" title="V11 validated full-array solar DC topology workbench" allow="clipboard-read; clipboard-write"></iframe>
</section>
</main>
<script>
(() => {
'use strict';
const base = 'https://rawcdn.githack.com/Ventusltd/v11/f870883dfdfcabf2edcc800ff7a17e41fb0aa05a/browser/workbench.html';
const frame = document.getElementById('v11-frame');
const loadedAt = document.getElementById('loaded-at');
function loadPinned(){
frame.src = base;
loadedAt.textContent = `requested ${new Date().toLocaleTimeString()}`;
}
document.getElementById('reload').addEventListener('click', loadPinned);
frame.addEventListener('load', () => { loadedAt.textContent = `loaded ${new Date().toLocaleTimeString()}`; });
loadPinned();
})();
</script>
</body>
</html>Ventus Card
A JavaScript file in the wiring folder of GlobalGrid2050 that converts to world (`toWorld`) and steps anim (`stepAnim`). Served with the page at https://globalgrid2050.com/ventus/wiring/.
Set aside from the main view: 98% of its lines are the same as kuiper-grid/drawing/kuiper-card.js (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 97% of lines shared with Kuiper Card; read that one first. All set-aside files, with reasons. Nothing was deleted.
Evidence
- line-jaccard 0.9774 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 kuiper-grid/drawing/kuiper-card.js:1-277 d76a0c3635a858e4e087db51aa46d419c325cd72
- sha256 3010e6f4aaaa839366612b0456b113c793fe7783b3dae156bf5206a2ceee98da
- target sha256 5e632857c5a3501aae563f61ef2bb44cef03923c020066caa35b64e7fe88bad8
- group of 3 (identity.json near-copy edges >= 0.9)
- canonical rule: reachable, newest stamp, core repo, most lines
renderglobalgrid2050 / ventus/wiring/VENTUS-card.js · lines 1–277 of 277 · Entry point · pattern revealUnderHead (shared by 3 files)
- What it does
- It draws its content. Defines 19 functions or classes, including toWorld, cardFor, esc, gh, ghLink. Side effects: changes the web page (DOM); reads or writes files; makes network requests.
- Downstream impact
- Used directly by 1 file: Renderer (globalgrid2050, https://globalgrid2050.com/ventus/wiring/renderer.html). It is itself an entry point, published at https://globalgrid2050.com/ventus/wiring/.
- What it achieves
- It shows new (`showNew`) and is built from the to world helper (`toWorld`) and the card for helper (`cardFor`). A cartridge of the VENTUS shell. It responds to toggle and click events.
- Why it matters
- Loaded by the Renderer page at https://globalgrid2050.com/ventus/wiring/renderer.html.
- Application
- globalgrid2050 · ventus/wiring · script
- Uses
- none found
- Used by
- loaded by Renderer (script src)
- Produces
- toWorld, cardFor, esc, gh, ghLink, el, drow, linkTo, workTable, rawFile, workCode, open
- Defines here
- toWorld, cardFor, esc, gh, ghLink, el, drow, linkTo, workTable, rawFile, workCode, open, revealUnderHead, show, put, goKey, arriveAt, showNew, stepAnim
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 ventus/wiring/VENTUS-card.js:1-277 · blob 5ecdf83c16b0c4771120895eb5fb36bde7cdebb0 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem, network · domain stage: unknown · users: none · canonical: production_core
'use strict';
// VENTUS-card.js - a cartridge of the VENTUS shell. Cut from the whole page with no change of behaviour;
// replaced, when it is, by a newer file the pointer names and the composer checks by its hash.
// ------------------------------------------------------------------------------ the controls
function toWorld(px, py){ return [cx + (px - innerWidth/2)/zoom, cy - (py - innerHeight/2)/zoom]; }
// A KEY THAT LANDS IN A CARRIED FILE SHOWS THE CODE. Until every commit's file list is published a
// browser cannot work out which file a key belongs to, so the answer is worked out beforehand, one
// public file at a time, and the page simply looks it up. Where there is no card the page says what
// it knows and does not pretend otherwise.
function cardFor(k){ return cards.find(c => k >= c.k0 && k < c.k0 + c.lines) || null; }
function esc(t){ return String(t).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'); }
const CONTEXT = 10;
// THE ONE RULE THAT MAKES THE ADDRESS OF A LINE ON GITHUB, the same rule tools/cards.py writes
// down, so a change of commit ids can be answered by making every link again from the fields.
// The owner used to be written in here by hand: correct by luck, and wrong the first time a
// carried file came from anywhere else.
// ONE RULE, TWO SHAPES. A whole piece of work is a commit; a line is a path inside it. Nothing in
// this page types a GitHub address: every one of them comes out of here, from data, so when the
// commit ids change they can all be made again by rebuilding the data.
function gh(o){
if (!o || !o.owner || !o.repo || !o.commit) return null;
const base = 'https://github.com/' + o.owner + '/' + o.repo;
if (!o.path) return base + '/commit/' + o.commit;
return base + '/blob/' + o.commit + '/' + o.path + (o.line ? '#L' + o.line : '');
}
function ghLink(c, line){
return gh({ owner:c.owner, repo:c.repo, commit:c.commit, path:c.path, line:line });
}
// ===== THE POP CARD =========================================================================
// The card this estate refined over many iterations, brought over rather than approximated again.
// Grid Atlas's popup look, a state chip with ONE writer, and a code window that is one <pre> with
// one text node: the numbers are part of the text, so copying the code copies what is on the
// screen, and the tapped line is marked by a bar placed from the line height.
function el(tag, cls, text){ const e = document.createElement(tag); if (cls) e.className = cls;
if (text != null) e.textContent = text; return e; }
function drow(dl, k, v){ dl.append(el('dt', null, k)); const d = el('dd', null, v); dl.append(d); return d; }
function linkTo(href, text){ const a = el('a', 'cc-link', text); a.href = href; a.target = '_blank'; a.rel = 'noopener'; return a; }
let cardToken = 0, cardSource = null, PG = null, glowBuf = null, glowCount = 0, glowOff = false;
// THE ESTATE'S ONE GATHERING ANIMATION, used as it stands. If it cannot be read the sparks simply stay
// where the work is: the page is quieter, and nothing is pretended.
// THE CODE A PIECE OF WORK CHANGED, THE WAFER'S WAY. The table of what each piece of work changed is one
// small module, asked for the first time a dot is tapped. The file is read from the public repository at
// that exact commit. Nothing is fetched for a repository that is not provably public.
let WORK = null, workWhy = null; const rawCache = new Map();
{ const st = document.createElement('style'); // the look of the other-files buttons travels with this part
st.textContent = '#card .cc-nav{display:flex;gap:.35rem;flex-wrap:wrap;margin:.3rem 0}'
+ '#card .cc-mini{background:#0a0a0a;color:#00ffff;border:1px solid #444;border-radius:3px;font:inherit;font-size:11px;padding:.3rem .5rem;cursor:pointer}'
+ '#card .cc-mini.cc-on{border-color:#00ffff;color:#fff}';
document.head.appendChild(st); }
// Historical source browsing is disabled in this generic drawing release.
function workTable(){return Promise.resolve({});}
function rawFile(){return Promise.reject(new Error('Source browsing is not part of this drawing release.'));}
// THE SAME WINDOW, ASKED FOR BY PLACE. A runner holds this page's code window against the wafer's own card on
// the same lines of the same public files and fails unless the text is the same. This is not a second way of
// showing code: it is the one way (the same file reader, the same window) with the place given from outside.
window.__VENTUSCode = async (owner, repo, commit, path, line) => { const lines = await rawFile(owner, repo, commit, path);
const at = Math.min(Math.max(1, line | 0), lines.length), from = Math.max(1, at - CONTEXT), to = Math.min(lines.length, at + CONTEXT);
const rows = codeWindow(lines, from, to, at).node.textContent.split(String.fromCharCode(10));
return { from, to, at, rows:rows.map((t, i) => ({ n:from + i, text:t.slice(8) })) }; };
function workCode(a, r, s){
if (!r.pub) { s.setTag('EMPTY', 'This work is not public, so its code is not shown.'); return; }
const det = card.querySelector('details.cc-q');
if (det && !det.open && !s.asked) { s.asked = true; s.setTag('WAIT', 'open this to read the code this piece of work changed');
det.addEventListener('toggle', () => { if (det.open && s.live()) workCode(a, r, s); }, { once:true }); return; }
s.setTag('LOAD', 'finding what this piece of work changed\u2026');
workTable().then(table => { if (!s.live()) return;
if (!table) { s.setTag('FAIL', 'The list of what each piece of work changed could not be read: ' + workWhy); return; }
const row = table[a.c.sha];
if (!row) { s.setTag('EMPTY', 'This piece of work changed no code a card can show: data, pictures, or files that were only removed.'); return; }
const full = row[0], count = row[1], files = row.slice(2);
const pick = el('div', 'cc-nav'), head = el('div', 'cc-codehead'), holder = el('div');
s.body.append(head, pick, holder);
const open = i => { const path = files[i][0], line = files[i][1], name = path.split('/').pop();
for (const b of pick.children) b.classList.toggle('cc-on', b.getAttribute('data-i') === String(i));
head.textContent = 'This piece of work changed ' + fmt(count) + (count === 1 ? ' file' : ' files') + '. Showing ' + path + '.';
holder.replaceChildren(); cardShown = null;
s.setTag('LOAD', 'reading ' + name + ' as it stood that day\u2026');
rawFile(r.owner, r.name, full, path).then(lines => { if (!s.live()) return;
const at = Math.min(Math.max(1, line), lines.length), from = Math.max(1, at - CONTEXT), to = Math.min(lines.length, at + CONTEXT);
const w = codeWindow(lines, from, to, at); holder.append(w.node);
const src = el('div', 'cc-source'), g = linkTo(gh({ owner:r.owner, repo:r.name, commit:full, path:path, line:at }), 'GitHub'); g.classList.add('cc-gh');
src.append(g); holder.append(src);
cardShown = { work:true, path, line:at, lines, window:w, sheet:s, from, to };
s.setTag('OK', 'lines ' + fmt(from) + ' to ' + fmt(to) + ' of ' + fmt(lines.length) + ', around the first line this work changed (line ' + fmt(at) + ')');
requestAnimationFrame(() => { if (s.live()) revealUnderHead(); }); revealUnderHead(); dirty = true;
}).catch(e => { if (s.live()) s.setTag('FAIL', name + ' could not be read from the public repository: ' + (e && e.message || e) + '. Nothing is shown in its place.'); }); };
files.forEach((f, i) => { const b = el('button', 'cc-mini', f[0].split('/').pop()); b.type = 'button'; b.setAttribute('data-i', i); b.title = f[0];
b.addEventListener('click', e => { e.stopPropagation(); open(i); }); pick.append(b); });
if (count > files.length) pick.append(el('span', 'cc-small', ' and ' + fmt(count - files.length) + ' more'));
if (files.length < 2) pick.style.display = 'none';
open(0);
});
}
// THE CODE IS BROUGHT IN UNDER THE HEAD, never over it: the window's top is put just below the head's foot,
// and then the marked line is brought to the middle of the window.
function revealUnderHead(){ const w = cardShown && cardShown.window; if (!w) return;
const head = card.querySelector('.cc-head'), floor = head ? head.getBoundingClientRect().bottom : card.getBoundingClientRect().top;
card.scrollTop += w.node.getBoundingClientRect().top - (floor + 4);
w.scrollToTarget(); }
{ const st = document.createElement('style');
st.textContent = '#card .cc-head{position:sticky;top:-8px;z-index:2;background:#000;padding-top:8px;margin-top:-8px}'
+ '#card.codeopen .cc-tile-what,#card.codeopen .scada-brand,#card.codeopen .cc-plain,#card.codeopen .cc-links{display:none}'
+ '#card.codeopen .cc-tile{padding:8px 12px;margin:2px 0 6px}#card.codeopen .cc-tile-name{font-size:16px;margin-bottom:.35rem}'
+ '#card.codeopen .cc-tile-open{padding:.4rem 0}#card.codeopen .cc-tile-part{margin-bottom:.15rem}'
+ '@media (max-width:640px){#card.codeopen .cc-code{max-height:24vh}}';
document.head.appendChild(st); }
function show(a){
card.classList.remove('codeopen');
cardShown = null;
if (!a) { closeCard(); return; }
if (a.silent) {
const x = a.next, s = sheet('Nothing was recorded here', '');
s.setTag('EMPTY', 'This point falls between two pieces of work, so no line of code has this address.');
if (x) { const p = el('div', 'cc-row');
const go = el('a', 'cc-link', 'Go to the next work: ' + repos[x.repo].name + ', ' + day(x.unix));
// BESIDE THE ADDRESS BAR, NOT BESIDE THE SHELL. Under the composer the page's base is the shell's own
// folder, and a bare ?key= would lead there instead of to the one address that never changes.
go.href = location.pathname + buildLink({ key:x.k0 }); go.setAttribute('data-key', x.k0);
p.append(go); s.body.append(p); }
return;
}
const r = repos[a.c.repo], c = cardFor(a.k);
litRepo = a.c.repo;
const s = sheet('Line ' + fmt(a.k), c ? ' \u00b7 ' + c.path.split('/').pop() : ' \u00b7 ' + r.name);
// THE ORDER OF THE CARD IS THE ORDER OF THE QUESTIONS A PERSON WHO SIGNS ASKS. What is this for,
// and where do I open it; whose is it; what was done and when. How it is made comes last and
// closed, one tap further in, for the engineer who is in the room but does not sign.
{ const found = r.pub ? appFor(r.owner, r.name, c ? c.path : null) : null;
const det = el('details', 'cc-q'); det.append(el('summary', null, 'See the code behind this'));
for (const kid of Array.from(card.children)) if (!kid.classList.contains('cc-x')) det.append(kid);
let top;
// WHERE TO PUT THE VISITOR. A carried file knows its own page; any other piece of work has the
// page its files agreed on. Where that page is the application's own front door, the tile is the
// application's, as before.
const near = r.pub ? ((c && c.page) || pageOfWork[a.c.sha] || null) : null;
const theApp = found && found.app ? found.app : null;
if (near && !(theApp && theApp.live === near.address)) {
top = el('a', 'cc-tile cc-app cc-page'); top.href = near.address; top.target = '_blank'; top.rel = 'noopener';
top.setAttribute('data-app', theApp ? theApp.app : ''); top.setAttribute('data-page', near.address);
if (theApp) top.append(el('div', 'cc-tile-part', 'part of ' + theApp.button));
top.append(el('div', 'cc-tile-name', near.title || near.address.replace(/^https?:\/\//, '')));
top.append(el('span', 'cc-tile-open', 'OPEN THIS PAGE'));
} else if (found && found.app) {
top = el('a', 'cc-tile cc-app'); top.href = found.app.live; top.target = '_blank'; top.rel = 'noopener';
top.setAttribute('data-app', found.app.app);
top.append(el('div', 'cc-tile-name', found.app.button));
if (whatItDoes[found.app.live]) top.append(el('div', 'cc-tile-what', whatItDoes[found.app.live] + '.'));
top.append(el('span', 'cc-tile-open', 'OPEN ' + found.app.button));
} else {
top = el('div', 'cc-notile cc-app');
top.setAttribute('data-app', found && found.unproved ? '?' : '');
top.append(el('div', null, 'This work has no page of its own yet.'));
}
// THE LINKS A CARD CARRIES, IN THE OPEN AND IN AS FEW WORDS AS THEY NEED: the application (above),
// GitHub as one quiet word for those who know what it is, and the site itself whenever there is
// nothing else to offer, so that no card is ever a dead end.
const links = el('div', 'cc-row cc-links');
{ const gu = r.pub ? gh({ owner:r.owner, repo:r.name, commit:a.c.sha }) : null;
if (!near && !(found && found.app)) {
// the front door of the site this work is served from, where it has one; else the main site
const door = (r.pub && frontOfWork[a.c.sha]) || 'https://www.globalgrid2050.com/';
const hl = linkTo(door, door.replace(/^https?:\/\//, '').replace(/\/$/, ''));
hl.classList.add('cc-home'); links.append(hl); }
// GITHUB IS HUMBLE: one small grey word at the very bottom of the code fold, for those who know
// what it is. Never a sentence, and never in the way of a visitor who does not.
if (gu) { const src = el('div', 'cc-source'); const gl = linkTo(gu, 'source'); gl.classList.add('cc-gh');
src.append(gl); det.append(src); cardSource = src; } }
const brand = el('div', 'scada-brand'), inner = el('div');
inner.append(el('div', 'scada-brand-main', 'Ventus'), el('div', 'scada-brand-sub', 'Cables & Connectivity\u00ae'));
brand.append(inner);
const plain = el('div', 'cc-plain', 'Engineering work in ' + r.name + ', done on ' + day(a.c.unix) + '.');
// THE HEADER IS THE HEADER. It stays at the top of the card whatever is opened under it.
const head = el('div', 'cc-head'); head.append(top, links, brand, plain);
card.append(head, det);
det.open = codeOpen; card.classList.toggle('codeopen', det.open);
det.addEventListener('toggle', () => { card.classList.toggle('codeopen', det.open); });
// ASKED FOR MUST MEAN SEEN. With the tile, the brand and the plain line above it, the code opened
// below the fold of the card on a phone. Opening it brings the window into view, then the line.
det.addEventListener('toggle', () => { if (det.open && cardShown && cardShown.window) revealUnderHead(); dirty = true; }); }
const meta = el('dl', 'cc-dl');
drow(meta, 'work', r.name + ' \u00b7 ' + day(a.c.unix));
const u = r.pub ? gh({ owner:r.owner, repo:r.name, commit:a.c.sha }) : null;
const d = drow(meta, 'history', '');
if (u) { d.append(linkTo(u, 'source')); d.append(' \u00b7 commit ' + a.c.sha.slice(0, 7)); }
else d.textContent = 'not public, so there is no link';
s.body.append(meta);
if (!c) { workCode(a, r, s); return; }
const j = a.k - c.k0;
s.setTag('LOAD', 'reading the lines around it from this site\u2026');
const put = data => {
if (!s.live()) return;
cardShown = { card:c, line:j, data, sheet:s };
const short = c.commit.slice(0, 7), fileName = c.path.split('/').pop();
// THE ARITHMETIC THIS CARD IS ABOUT TO RELY ON, CHECKED BEFORE IT IS RELIED ON. The pack was
// built from git and every line proved against it when it was built; what can still go wrong
// here is the pack and the list disagreeing about the length of the file, and then every number
// below would be a guess.
if (!c.here || data.lines !== c.lines || data.text.length !== c.lines || !(j >= 0 && j < c.lines)) {
s.setTag('FAIL', !c.here
? 'This file is no longer in the repository, so its neighbours today would not be this line\u2019s neighbours. Nothing around it is shown.'
: 'The record says this file has ' + fmt(c.lines) + ' lines and the text carried for it has '
+ fmt(data.text.length) + ', so the numbering cannot be trusted. Nothing around it is shown.');
const h = el('div', 'cc-codehead');
h.append(c.path + ' \u00b7 ' + c.repo + ' @ ' + short + ' \u00b7 line ' + fmt(j + 1) + ' \u00b7 ');
h.append(linkTo(ghLink(c, j + 1), 'source'));
s.body.append(h);
dirty = true; return;
}
const from = Math.max(1, j + 1 - CONTEXT), to = Math.min(data.text.length, j + 1 + CONTEXT);
const head = el('div', 'cc-codehead');
head.append(c.path + ' \u00b7 ' + c.repo + ' @ ' + short + ' \u00b7 line ' + fmt(j + 1)
+ ' \u00b7 showing ' + fmt(from) + '\u2013' + fmt(to) + ' of ' + fmt(data.text.length) + ' \u00b7 ');
head.append(linkTo(ghLink(c, j + 1), 'source'));
s.body.append(head);
s.body.append(el('div', 'cc-check',
'These lines are carried on this site, read from ' + c.repo + ' at commit ' + short
+ ' when this page was built and checked line for line against it then \u00b7 '
+ fmt(j + 1 - from) + ' above, ' + fmt(to - j - 1) + ' below. Scroll inside the window to see them all;'
+ ' a long line scrolls sideways.'));
const w = codeWindow(data.text, from, to, j + 1);
s.body.append(w.node);
cardShown.window = w;
s.setTag('OK', 'the line and the lines around it, as the file stood that day');
s.body.append(el('div', 'cc-disclaimer',
'Provided as is, without warranty of any kind; a chart, not a design.'));
if (cardSource && cardSource.parentNode) cardSource.parentNode.append(cardSource);
requestAnimationFrame(() => { if (s.live()) revealUnderHead(); });
revealUnderHead();
dirty = true;
};
if (cardCache[c.file]) { put(cardCache[c.file]); return; }
fetch('cosmos/cards/' + c.file).then(x => x.json()).then(dd => { cardCache[c.file] = dd; put(dd); })
.catch(e => s.setTag('FAIL', 'the lines around this one could not be read from this site: ' + (e && e.message || e)));
}
function goKey(k){ endIsolate(); const p = keyPlace(k); target = { x:p[0], y:p[1] }; show(address(k)); flyTo(p[0], p[1], 14); }
// ARRIVING BY SOMEBODY ELSE'S LINK. The view flies, the arrow is shot, the card opens: three things
// in that order, because a card that appears over a picture of nine thousand pieces of work asks to
// be taken on trust, and an arrow from the middle of the record to one dot does not.
function arriveAt(k){
endIsolate();
const a = address(k);
if (!a) return;
const p = keyPlace(k);
target = null; arrow = null; arrowTip = null; card.style.display = 'none';
flyTo(p[0], p[1], Math.max(14, zoom));
setTimeout(() => { arrow = { k, t0:performance.now() }; dirty = true; }, 920);
setTimeout(() => { target = { x:p[0], y:p[1] }; show(a); dirty = true; }, 920 + ARROW_MS);
}
// SHOW NEW CODE. "New" is entered from the newest commit, not from the wall clock, so the same
// page gives the same answer tomorrow. Keys run in time order, so what is new is always one
// contiguous band at the rim: the boundary is a single circle, and that circle is drawn.
function showNew(hours){
endIsolate();
const last = commits[commits.length-1].unix, cut = last - hours*3600;
newFrom = findBy('unix', cut - 1) + (commits[0].unix >= cut ? 0 : 1); if (newFrom >= commits.length) newFrom = commits.length - 1;
litRepo = -1; target = null; card.style.display = 'none'; tween = null;
const R = Math.sqrt(SPACE); cx = 0; cy = 0; zoom = (Math.min(cv.width, cv.height)/2) * 0.80 / R;
anim_hours = hours; anim = { t0:performance.now(), hours, R }; dirty = true;
}
function stepAnim(){
const t = (performance.now() - anim.t0) / 1000; dirty = true;
if (t < 1.6) { const u = t/1.6; pulse = anim.R * (u*u*(3-2*u)); flash = 0; }
else if (t < 2.5) { pulse = -1; flash = 1 - 0.45*((t-1.6)/0.9); if (selftest && selftest.wantPixels === undefined) selftest.wantPixels = true; }
else { const c = commits[newFrom], n = commits.length - newFrom; let lines = 0; for (let i = newFrom; i < commits.length; i++) lines += commits[i].lines;
flash = 0.35; anim = null; const p = keyPlace(c.k0); target = { x:p[0], y:p[1], boundary:true };
card.style.display = 'block';
{ const r0 = repos[c.repo], u0 = r0.pub ? gh({ owner:r0.owner, repo:r0.name, commit:c.sha }) : null;
card.classList.remove('sheet');
card.innerHTML = 'NEW CODE · the last ' + anim_hours + ' hours of work, as a band at the rim'
+ '\n<b>' + fmt(n) + '</b> pieces of work, <b>' + fmt(lines) + '</b> lines added'
+ '\nbegins with <b>' + r0.name + '</b>, ' + day(c.unix)
+ (u0 ? '\n<a class="cc-gh" style="color:#666;font-size:10.5px" href="' + u0 + '" target="_blank" rel="noopener">GitHub</a>' : ''); }
flyTo(p[0], p[1], 14);
if (selftest) finishSelftest(c, n, lines); }
}
let anim_hours = 24;
// THE TESTS, run by the page on itself with ?selftest=new, so the verdict is not an opinion.