920efd72d6
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
26 lines
1.5 KiB
JavaScript
26 lines
1.5 KiB
JavaScript
// Promote page (2026-11-14): the promo kit from /api/promo-kit with the member's network username in every link.
|
|
// Username: ?u= first, then the signed-in member's (My Spots), then the last one typed here (this browser only).
|
|
(async function () {
|
|
await BL.renderNav('/promote'); BL.renderFooter();
|
|
const $ = BL.$; const RE = /^(?:[A-Za-z0-9_.-]{2,40}|0x[0-9a-fA-F]{40})$/;
|
|
let u = new URLSearchParams(location.search).get('u') || '';
|
|
let signed = false;
|
|
if (!RE.test(u)) {
|
|
u = '';
|
|
try { const me = await BL.getJSON('/api/me'); if (me.signedIn) { const d = await BL.getJSON('/api/my'); if (d && !d.error) { u = d.username || d.address || ''; signed = true; } } } catch (e) {}
|
|
}
|
|
if (!u) { try { u = localStorage.getItem('kit.u') || ''; } catch (e) {} if (!RE.test(u)) u = ''; }
|
|
$('whoIn').value = u;
|
|
if (signed) $('whoNote').textContent = 'Signed in: your links below use ' + (u.startsWith('0x') ? 'your wallet (no network username found yet)' : '@' + u) + '.';
|
|
async function show(name) {
|
|
try { await KitPage.load($('kit'), name); BL.status(''); } catch (e) { BL.status('Could not load the kit. Try again in a moment.', 'err'); }
|
|
}
|
|
$('whoForm').addEventListener('submit', e => {
|
|
e.preventDefault(); const v = $('whoIn').value.trim().replace(/^@/, '');
|
|
if (v && !RE.test(v)) return BL.status('That does not look like a username: letters, numbers, dot, dash or underscore.', 'err');
|
|
try { localStorage.setItem('kit.u', v); } catch (e2) {}
|
|
show(v);
|
|
});
|
|
show(u);
|
|
})();
|