From 24f1eb6cc611f458c45f0ac4046efce51211d7d3 Mon Sep 17 00:00:00 2001
From: srdusr <99972264+srdusr@users.noreply.github.com>
Date: Sat, 6 Dec 2025 00:58:00 +0200
Subject: Fix content packs, seed the leaderboard, and add the missing site
furniture
Naming
- "Typing Test" removed from the browser tab, the crate description and the
READMEs. The scope outgrew it: solo practice, live races, code drills and
adaptive weak-key training.
Content
- Movies was prose *about* film, not film quotes - the same mistake the
programming pack had. Replaced with 28 attributed lines. New anime pack,
28 lines across 24 series.
- This follows the model TypeRacer states outright ("type quotes from popular
music, songs, anime, comic books and more"): short excerpts attributed to
the work they came from. The scalable half of their approach is user
submission with moderation, which is a feature this does not have yet.
Leaderboard
- An empty board tells a new player nobody is here. Bots now race the eight
fixed-length leaderboard modes, seeded with a fortnight of backdated results
on first run and one new result every 90 seconds after.
- They are ordinary users carrying is_bot, returned by the same query and
labelled "bot" in the UI. Seeding a board is reasonable; passing synthetic
scores off as human results is not, so the flag travels with the row.
- Seeding is checked per mode. A single result from the live ticker used to
satisfy an "any bot results" guard and leave every other mode empty forever.
Stats
- The per-key accuracy data Practice mode is built on was computed, used to
generate text, and never shown. The screen now ranks your weakest keys with
the error rate and pause length behind each one.
- Added recent form against your lifetime average, best accuracy, and tests
this week.
Multiplayer standings
- Now place, racer, WPM, accuracy and time, with column labels - the columns
TypeRacer and 10FastFingers both show.
Site furniture
- Share (Web Share where available, clipboard otherwise - no third-party
button, no tracking script), a GitHub link, and a real privacy page written
from what the code actually stores rather than from a template.
Button hierarchy
- Everything was an outlined box of roughly equal weight, so a screen's one
real action, a settings toggle and a filter chip looked alike. Three tiers
now: primary (filled, one per screen), default (outlined), quiet (toggles
and filters, bordered only when hovered or active).
---
web/src/siteFooter.js | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
create mode 100644 web/src/siteFooter.js
(limited to 'web/src/siteFooter.js')
diff --git a/web/src/siteFooter.js b/web/src/siteFooter.js
new file mode 100644
index 0000000..1d5139e
--- /dev/null
+++ b/web/src/siteFooter.js
@@ -0,0 +1,66 @@
+import { attachTooltips } from './tooltip.js';
+
+// The links every site is expected to carry: where the source lives, who made
+// it, and what it does with your data. Kept to one line at the foot of the
+// menu rather than a page of its own, because there is very little to say and
+// a whole screen would overstate it.
+//
+// Edit these to point at the real destinations.
+export const LINKS = {
+ github: 'https://github.com/srdusr/typerpunk',
+ privacy: '#privacy',
+};
+
+// Share is a Web Share invocation where the browser has one (every mobile
+// browser, Safari, and Edge), and a clipboard copy everywhere else. Neither
+// needs a network call or a third-party button, so there is no tracking
+// script here and nothing to consent to.
+async function share(result) {
+ const url = window.location.origin;
+ const text = result
+ ? `I just typed ${Math.round(result.wpm)} wpm at ${Math.round(result.accuracy)}% accuracy on TyperPunk.`
+ : 'TyperPunk - competitive typing in the terminal and the browser.';
+
+ if (navigator.share) {
+ try {
+ await navigator.share({ title: 'TyperPunk', text, url });
+ return 'shared';
+ } catch {
+ // A cancelled share sheet is not a failure; fall through to copy.
+ }
+ }
+ try {
+ await navigator.clipboard.writeText(`${text} ${url}`);
+ return 'copied';
+ } catch {
+ return 'failed';
+ }
+}
+
+/// `result` is optional: with one, Share offers the score just achieved;
+/// without, it offers the site.
+export function renderSiteFooter(root, { result, onShowPrivacy } = {}) {
+ const wrap = document.createElement('div');
+ wrap.className = 'site-footer';
+ wrap.innerHTML = `
+
+
+
+
+
+
+
+ `;
+ root.appendChild(wrap);
+ attachTooltips(wrap);
+
+ const shareBtn = wrap.querySelector('[data-action="share"]');
+ shareBtn.addEventListener('click', async () => {
+ const outcome = await share(result);
+ shareBtn.textContent = outcome === 'copied' ? 'Copied' : outcome === 'failed' ? 'Copy failed' : 'Shared';
+ setTimeout(() => { shareBtn.textContent = 'Share'; }, 1800);
+ });
+ wrap.querySelector('[data-action="privacy"]').addEventListener('click', () => onShowPrivacy?.());
+
+ return () => wrap.remove();
+}
--
cgit v1.2.3