Files
rea/website/public/assets/main.js
T
ysopwnableandGitHub a6ba772c08 docs(website): add Notion case study and improve onboarding
The Electron guide currently uses a teaching fixture. Add a real Notion clipboard case with REA findings, short source excerpts and responsive figures, alongside the existing DX-Ball reconstruction.

- Trace the saved Notion 7.6.1 preload API through its wrappers to the clipboard receiver. Attribute the separate web-cache module probes to their original harness. Public content uses relative source locations and generic example data; packages and complete captures stay local.
- Add a Showcases index and links from the homepage and JavaScript guide. Simplify homepage copy while preserving the approved headline and closing question.
- Show copyable agent installation prompts and the direct setup command. Keep terminal cursors blinking consistently and respect reduced-motion settings.
- Provide one Notes example ZIP. Generate it from the six public source files before website checks and manual Pages deployment; verify its contents against the source. Pages remains manual-only.

Validation:
- `npm run check:fast`
- `python3 scripts/prepare-website.py` and `python3 scripts/verify-website.py`
- Browser checks at `/` and `/rea/`: downloads, prompt/command copying, responsive layouts, keyboard navigation, reduced motion and DX-Ball comparison controls.
- Published REA 4.1.0 preload analysis and feature traces; source/claim/privacy review.
- Real Hopper/Ghidra verification: not performed (website-only change).
2026-10-07 20:59:56 +08:00

63 lines
2.1 KiB
JavaScript

function initializeCopyButtons() {
document.querySelectorAll("[data-copy]").forEach((button) => {
button.addEventListener("click", async () => {
const target = document.getElementById(button.getAttribute("data-copy"));
if (target === null) return;
const status = document.getElementById("copy-status");
const content = target.textContent.trim();
const text =
target.closest(".terminal-prompt") === null
? content
: content.replace(/\s+/g, " ");
try {
await navigator.clipboard.writeText(text);
button.textContent = "Copied";
if (status !== null) status.textContent = "Code copied to clipboard.";
} catch {
const range = document.createRange();
range.selectNodeContents(target);
const selection = window.getSelection();
if (selection !== null) {
selection.removeAllRanges();
selection.addRange(range);
}
button.textContent = "Selected";
if (status !== null)
status.textContent = "Code selected. Use your keyboard to copy it.";
}
window.setTimeout(() => {
button.textContent = "Copy";
}, 2000);
});
});
}
initializeCopyButtons();
function initializeStepComparisons() {
document.querySelectorAll("[data-step-comparison]").forEach((comparison) => {
const buttons = comparison.querySelectorAll("[data-select-step]");
buttons.forEach((button) => {
button.addEventListener("click", () => {
const selected = button.getAttribute("data-select-step");
buttons.forEach((candidate) => {
candidate.setAttribute("aria-pressed", String(candidate === button));
});
comparison.querySelectorAll("[data-step]").forEach((fragment) => {
fragment.classList.toggle(
"is-active",
fragment.getAttribute("data-step") === selected,
);
});
comparison.querySelectorAll("[data-step-note]").forEach((note) => {
note.hidden = note.getAttribute("data-step-note") !== selected;
});
});
});
});
}
initializeStepComparisons();