GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — RhineLabUI/src/document-decryption.ts at main · LBEILC/RhineLabUI

Expand file tree

/

document-decryption.ts

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
103 lines (96 loc) · 4.09 KB
/

document-decryption.ts

Copy path

File metadata and controls

103 lines (96 loc) · 4.09 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import type { DecryptionFrame } from "./decryption";
type Cover = { window: HTMLElement; ink: HTMLElement; order: number };
/** Decorative redaction, driven by the physical archive's reveal cue. */
export class DocumentDecryption {
private root: HTMLElement | null = null;
private covers: Cover[] = [];
private started: number | null = null;
private progress = 0;
reset(root: HTMLElement, clear: boolean) {
this.remove();
this.root = root;
this.started = null;
this.progress = clear ? 1 : 0;
this.refresh();
}
refresh() {
this.remove();
if (!this.root || this.progress === 1) return;
// Measure text fragments, including wrapped lines, without splitting or
// replacing the actual text. Stage scaling cancels out in local coordinates.
const targets = this.root.querySelectorAll<HTMLElement>(
"h2, .detail-title-cn, .metadata dd, .tab-panel p, .research-notes li, .log-row",
);
targets.forEach((target) => {
target.classList.add("document-redacted");
const bounds = target.getBoundingClientRect();
const scale = bounds.width / target.offsetWidth;
if (!scale || !Number.isFinite(scale)) return;
const walker = document.createTreeWalker(target, NodeFilter.SHOW_TEXT);
const lines: { x: number; y: number; right: number; bottom: number }[] = [];
let node: Node | null;
while ((node = walker.nextNode())) {
if (!node.textContent?.trim()) continue;
const range = document.createRange();
range.selectNodeContents(node);
for (const rect of range.getClientRects()) {
if (!rect.width || !rect.height) continue;
const x = (rect.left - bounds.left) / scale;
const y = (rect.top - bounds.top) / scale;
const right = (rect.right - bounds.left) / scale;
const bottom = (rect.bottom - bounds.top) / scale;
const line = lines.find((entry) => Math.abs(entry.y - y) < 6);
if (line) {
line.x = Math.min(line.x, x);
line.y = Math.min(line.y, y);
line.right = Math.max(line.right, right);
line.bottom = Math.max(line.bottom, bottom);
} else lines.push({ x, y, right, bottom });
}
}
for (const line of lines) {
const window = document.createElement("span");
window.className = "document-redaction-window";
window.setAttribute("aria-hidden", "true");
const left = Math.max(0, line.x - 1);
const right = Math.min(target.clientWidth, line.right + 1);
window.style.cssText = `left:${left}px;top:${line.y - 1}px;width:${right - left}px;height:${line.bottom - line.y + 2}px`;
const ink = document.createElement("span");
ink.className = "document-redaction-ink";
window.append(ink);
target.append(window);
this.covers.push({ window, ink, order: this.covers.length });
}
});
this.paint();
}
update(now: number, frame: DecryptionFrame, reduced: boolean) {
if (!this.root || this.progress === 1) return;
if (reduced) this.progress = 1;
else {
// Keep covered through joining / holding / retraction. The text starts
// opening with the glass, and its easing tail lasts a little longer.
if (this.started === null && frame.clarity > 0) this.started = now;
if (this.started !== null)
this.progress = Math.min(1, Math.max(0, (now - this.started) / 0.95));
}
if (this.progress === 1) this.remove();
else if (this.started !== null) this.paint();
}
private paint() {
const count = Math.max(1, this.covers.length - 1);
for (const cover of this.covers) {
const delay = (cover.order / count) * 0.22;
const t = Math.min(1, Math.max(0, (this.progress - delay) / 0.78));
// Brief acceleration, decisive departure, long deceleration; no bounce.
const eased = t < 0.2
? 0.4 * (t / 0.2) ** 2
: 1 - 0.6 * ((1 - t) / 0.8) ** (16 / 3);
cover.ink.style.transform = `translateX(${eased * 101}%)`;
}
}
private remove() {
for (const cover of this.covers) cover.window.remove();
this.covers = [];
}
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.