tracker
All repositories: gitoria
2.7 KB
// login.js — the small bridge between ident's <ident-selector> and the tracker shell (components/main.hl; the same// as calendar's/gitoria's login.js — copied unchanged, creator: "login.js is correct, as thats for externals in// general"). 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 trackerLogin, 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.__trackerLogin) { window.__trackerLogin.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.__trackerLogin = { sync };})();
Branches
Latest commits
- 2c95ac46|||PR AP62: re-vendor Hybriel set day62 (source 70341ad2, bin a54f5f08)Tracker
- b9c7c3c8Merge branch 'records-dp74' into mainTracker
- 85cfb4ae|||PR records: AP61 day61, DP74 liveTracker
- b1496147Merge branch 'ap61' into mainTracker
- 2047955bMerge branch 'u12-gateports' into mainTracker
- c8da40f3|||PR AP61: re-vendor Hybriel set day61 (source a05af47c, bin a11042e5)Tracker
- 4e018678|||PR deploy.sh: gates use Tracker's ports 8716-8719 and LC_ALL=C; README: 2 backups keptTracker
- 0b86324aMerge branch 'records-dp73' into mainTracker
- 9ce5f59b|||PR records: DP73 live 613ae0e; deploy.sh keeps 2 backupsTracker
- 613ae0ecMerge branch 'bs3' into mainTracker
- 1383264b|||PR BS3: keep shared synchronous sorting fastTracker
- 63e5ba1a|||PR BS3: guard boot imports and share resumable sort buffersTracker
- 310613f1Merge branch 'records-dp72' into mainTracker
- 6f7b61ba|||PR records: deploy-swap fix live, Kunibert findingsTracker
- c41587d2Merge branch 'bs2' into mainTracker
- 0dd538a6|||PR BS2: finish the boot index in slices so a booting instance keeps answeringTracker
- 019d5cedMerge branch 'records-1110' into mainTracker
- f88ae8b9|||PR records: day56 toggle live, reviewTracker
- b6b3bb4dMerge branch 'ap56e' into mainTracker
- 29a26da9|||PR AP56e: guard hidden show helpers during session syncTracker