21e105b953
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
66 lines
3.2 KiB
JavaScript
66 lines
3.2 KiB
JavaScript
// Generation Pay chart — personalizes to the member's live on-chain position.
|
||
// Row status: catching a generation requires qualified (2 directs) + level >= gen.
|
||
(function () {
|
||
'use strict';
|
||
function getId() {
|
||
var q = new URLSearchParams(location.search).get('id');
|
||
if (q && /^\d{1,15}$/.test(q)) return q;
|
||
var inp = document.getElementById('gpIdInput');
|
||
if (inp && /^\d{1,15}$/.test(inp.value)) return inp.value;
|
||
try { var s = localStorage.getItem('ctb.myId') || localStorage.getItem('rmc.toolsId'); if (s && /^\d{1,15}$/.test(s)) return s; } catch (e) {}
|
||
return '';
|
||
}
|
||
|
||
var meEl = document.getElementById('gpMe');
|
||
var stHead = document.getElementById('gpStH');
|
||
var rows = Array.prototype.slice.call(document.querySelectorAll('#gpTable tbody tr'));
|
||
|
||
function clearStatus() {
|
||
meEl.style.display = 'none';
|
||
stHead.style.display = 'none';
|
||
rows.forEach(function (r) {
|
||
r.classList.remove('catching', 'missing');
|
||
var st = r.querySelector('.st'); if (st) { st.textContent = ''; st.style.display = 'none'; }
|
||
});
|
||
}
|
||
|
||
async function personalize(id) {
|
||
clearStatus();
|
||
if (!/^\d{1,15}$/.test(id)) return;
|
||
var d;
|
||
try { d = await (await fetch('/api/public/member?id=' + id)).json(); } catch (e) { return; }
|
||
if (!d || !d.registered) return;
|
||
var qualified = (d.directCount || 0) >= 2;
|
||
var half = d.tier === 1;
|
||
meEl.style.display = 'block';
|
||
meEl.innerHTML = '<b>#' + d.id + '</b> · ' + (d.tierName || '') + ' · Level ' + d.level + ' (' + (d.levelName || '') + ') · ' +
|
||
(qualified ? '<span style="color:var(--teal)">✓ qualified (2/2)</span>' : '<span style="color:#f0a05a">⚠ ' + (d.directCount || 0) + '/2 — you catch nothing until you have your 2 directs</span>') +
|
||
(half ? ' · <span style="color:#f0a05a">Standard tier: your receive amounts are HALF the Premium figures below</span>' : '') +
|
||
(qualified ? '<br>Your level catches generations <b>1–' + Math.min(d.level, 7) + '</b>' + (d.level < 7 ? ' — your next upgrade extends your reach to generation ' + (d.level + 1) + '.' : ' — full depth reach.') : '');
|
||
stHead.style.display = '';
|
||
rows.forEach(function (r) {
|
||
var g = Number(r.getAttribute('data-gen'));
|
||
var st = r.querySelector('.st'); if (!st) return;
|
||
st.style.display = '';
|
||
if (g === 8) { st.textContent = 'pass-overs only'; return; }
|
||
if (!qualified) { r.classList.add('missing'); st.textContent = 'needs 2 directs'; return; }
|
||
if (d.level >= g) { r.classList.add('catching'); st.textContent = '✓ catching now'; }
|
||
else { r.classList.add('missing'); st.textContent = 'needs Level ' + g; }
|
||
});
|
||
}
|
||
|
||
var input = document.getElementById('gpIdInput');
|
||
var initial = getId();
|
||
if (input && initial) input.value = initial;
|
||
if (initial) personalize(initial);
|
||
var deb;
|
||
if (input) input.addEventListener('input', function () {
|
||
var v = input.value.replace(/\D/g, '').slice(0, 15); input.value = v;
|
||
if (/^\d{1,15}$/.test(v)) { try { localStorage.setItem('rmc.toolsId', v); } catch (e) {} }
|
||
clearTimeout(deb); deb = setTimeout(function () { personalize(v); }, 500);
|
||
});
|
||
|
||
var pb = document.getElementById('gpPrintBtn');
|
||
if (pb) pb.addEventListener('click', function () { window.print(); });
|
||
})();
|