notes
All repositories: gitoria
2.6 KB
// login.js — the small bridge between ident's <ident-selector> and the notes shell (components/main.hl; the same// as gitoria's login.js). Plain JS because hl:web cannot listen to a custom DOM event: `ident-login`// (event.detail.code, the one-time code) goes into the hidden input #identcode, whose `change` the shell handles// (→ face notesLogin, server-side exchange). The shell keeps the selector element's class at `in` / `out`; it is// mirrored here into the selector's `loggedIn` (false = back to "choose ident").// BACK TO THE PAGE: the "Log in with ident" click gets `?next=<this page>` in its return URL (project.hl safePath).// RUNS ONCE PER DOCUMENT: hl:web re-creates the header and its <script>s when the login state flips, the// selector element is then a NEW one; listeners sit on `document`, the CURRENT #selector is looked up each// time, and a one-time code is handed to the shell at most once.(() => {if (window.__notesLogin) { window.__notesLogin.sync(); return; }const sync = () => {const sel = document.getElementById('selector');// not upgraded yet: a property set now would shadow the element's own accessorif (!sel || !window.customElements || !customElements.get('ident-selector')) return;const want = sel.classList.contains('in');if (sel.loggedIn !== want) sel.loggedIn = want;};new MutationObserver(sync).observe(document.documentElement, { subtree: true, childList: true, attributes: true, attributeFilter: ['class'] });if (window.customElements) customElements.whenDefined('ident-selector').then(sync);const handed = new Set();document.addEventListener('ident-login', (e) => {const code = e.detail && e.detail.code;const input = document.getElementById('identcode');if (!input || !code || handed.has(code)) return; // a one-time code is exchanged oncehanded.add(code);input.value = code;input.dispatchEvent(new Event('change', { bubbles: true }));});const withNext = (a) => {try {const u = new URL(a.href);const ret = new URL(u.searchParams.get('return'));const here = location.pathname + location.search;ret.search = '';if (here !== '/' && here.length <= 500) ret.searchParams.set('next', here);u.searchParams.set('return', ret.href);a.href = u.href;} catch (err) { /* keep the server's href: the login still works, it returns to / */ }};const onButton = (e) => {const a = e.target && e.target.closest && e.target.closest('#loginbutton');if (a) withNext(a);};for (const t of ['click', 'auxclick', 'contextmenu']) document.addEventListener(t, onButton, true);window.__notesLogin = { sync };})();
Branches
- mainmain branch
Latest commits
- 2149e902notes mission 002 (4/4): code order — README file map + same-output test, STATUS, LOG, report; tests/letcount.py, tests/realdata-baseline.mjs, tests/realdata-compare.pymre
- 47db4fc1notes mission 002 (3/4): code order — let only where reassigned (58 dropped; 34 left: 19 reassigned, 15 loop-bound); gates 50/0 + 18/0, live-data run = step 2mre
- 3f8cb383notes mission 002 (2/4): code order — topics, map, thin wrappers: lib/util.hl, lib/notes(-helpers).hl, lib/users.hl (+userOfLoginCode, tagOf), lib/api(-helpers).hl; project.hl = map; login routes take &req/&sessions (failed-login reason now kept); dead notes#1 functions removed; gates 50/0 + 18/0mre
- 8cda5412notes mission 002 (1/4): code order — files moved: lib/notes.hl, lib/users.hl, lib/jsoncheck.hl, components/styles.hl (imports only); gates 50/0 + 18/0, live-data run identicalmre
- 47dad68bnotes: Hybriel master 06617221 (plugin allocators 3a781359 + 413f60e4, mpackdb 2cb7ae5e, http1 773de63e); gates 50/0 + 18/0mre
- a4a2b2aeantcolony#40: tracker missions moved too — references to them in missions/reports/LOG.md updatedmre
- 3dea0ef2notes: Hybriel master 190aa11d (fc838894 GC correctness, #126 closure scopes, #127); gate 50/0mre
- e27c7d71notes: Hybriel master 8efba065 (#126 GC by bytes, #48 lambda params copy; audit: nothing to fix; gate 50/0)mre
- 124613b6antcolony#40: mission references point to the moved missionsmre
- 1ca2f34dantcolony#40: history (LOG.md), worker briefs (missions/) and reports moved here from antcolony, numbered per project; old numbers in antcolony docs/mission-map.mdmre
- 2bebebdanotes: Hybriel master ff51cf46 (re-vendor round)mre
- 3eff126dnotes#3: installable app (manifest + own icon/favicon; notes' own sw.js kept)mre
- 9883c540deploy.sh: back up live storage/.sessions/.env before every deploy (newest 5 kept)mre
- eee693b8deploy.sh: never send .git or .gitignore to Byrodinmre
- c8904061State of 2026-09-27, before the move to gitoriamre