gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Branchrecords-hm55d3edaa05|||PR records: HM55 start, PROCEDURES.mdTrackerrecords-hm55/login.js

2.7 KB

  1. // login.js — the small bridge between ident's <ident-selector> and the tracker shell (components/main.hl; the same
  2. // as calendar's/gitoria's login.js — copied unchanged, creator: "login.js is correct, as thats for externals in
  3. // general"). Plain JS because hl:web cannot listen to a custom DOM event: `ident-login`
  4. // (event.detail.code, the one-time code) goes into the hidden input #identcode, whose `change` the shell handles
  5. // (→ face trackerLogin, server-side exchange). The shell keeps the selector element's class at `in` / `out`; it is
  6. // mirrored here into the selector's `loggedIn` (false = back to "choose ident").
  7. // BACK TO THE PAGE: the "Log in with ident" click gets `?next=<this page>` in its return URL (project.hl safePath).
  8. // RUNS ONCE PER DOCUMENT: hl:web re-creates the header and its <script>s when the login state flips, the
  9. // selector element is then a NEW one; listeners sit on `document`, the CURRENT #selector is looked up each
  10. // time, and a one-time code is handed to the shell at most once.
  11. (() => {
  12. if (window.__trackerLogin) { window.__trackerLogin.sync(); return; }
  13. const sync = () => {
  14. const sel = document.getElementById('selector');
  15. // not upgraded yet: a property set now would shadow the element's own accessor
  16. if (!sel || !window.customElements || !customElements.get('ident-selector')) return;
  17. const want = sel.classList.contains('in');
  18. if (sel.loggedIn !== want) sel.loggedIn = want;
  19. };
  20. new MutationObserver(sync).observe(document.documentElement, { subtree: true, childList: true, attributes: true, attributeFilter: ['class'] });
  21. if (window.customElements) customElements.whenDefined('ident-selector').then(sync);
  22. const handed = new Set();
  23. document.addEventListener('ident-login', (e) => {
  24. const code = e.detail && e.detail.code;
  25. const input = document.getElementById('identcode');
  26. if (!input || !code || handed.has(code)) return; // a one-time code is exchanged once
  27. handed.add(code);
  28. input.value = code;
  29. input.dispatchEvent(new Event('change', { bubbles: true }));
  30. });
  31. const withNext = (a) => {
  32. try {
  33. const u = new URL(a.href);
  34. const ret = new URL(u.searchParams.get('return'));
  35. const here = location.pathname + location.search;
  36. ret.search = '';
  37. if (here !== '/' && here.length <= 500) ret.searchParams.set('next', here);
  38. u.searchParams.set('return', ret.href);
  39. a.href = u.href;
  40. } catch (err) { /* keep the server's href: the login still works, it returns to / */ }
  41. };
  42. const onButton = (e) => {
  43. const a = e.target && e.target.closest && e.target.closest('#loginbutton');
  44. if (a) withNext(a);
  45. };
  46. for (const t of ['click', 'auxclick', 'contextmenu']) document.addEventListener(t, onButton, true);
  47. window.__trackerLogin = { sync };
  48. })();

Branches

Latest commits

  • d3edaa05|||PR records: HM55 start, PROCEDURES.mdTracker
  • 3059f86cMerge branch 'records-design-rule' into mainTracker
  • 421a4809|||PR records: his-design rule (Apollo 2026-11-13)Tracker
  • d1390692Merge branch 'records-dp75b' into mainTracker
  • a4d1a7d2|||PR records: later steps checked, branch auditTracker
  • e070e16fMerge branch 'records-dp75' into mainTracker
  • 642b4fa8|||PR records: DP75 day62 live, AP62 briefTracker
  • bfc4ea4dMerge branch 'ap62' into mainTracker
  • 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