c621fecb54
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
34 lines
2.9 KiB
JavaScript
34 lines
2.9 KiB
JavaScript
// BixPay guide (/bixpay, 2026-10-29): the CTA carries the viewer's resolved partner link (their own when signed in, else the
|
||
// member whose ?ref brought them here or whose sponsor cookie they carry, else the network link), always through the counted
|
||
// /go/bixpay link. The server already folded ?ref into the sponsor cookie; the ref is passed along too so the first view resolves.
|
||
// In-app browsers (Gmail, Telegram, Facebook webviews): BIX's register page runs a Cloudflare check that often fails there, and
|
||
// the invite token lives only in the URL, so a member who then reopens BIX elsewhere registers with no sponsor (bizventures,
|
||
// 2026-10-29: referrer N/A). Those viewers get a notice with the link to copy into a real browser.
|
||
(function () {
|
||
var cta = document.getElementById('bixCta'), using = document.getElementById('bixUsing'), soon = document.getElementById('bixSoon');
|
||
var box = document.getElementById('bixInApp'), boxLink = document.getElementById('bixInAppLink'), boxCopy = document.getElementById('bixInAppCopy');
|
||
if (!cta) return;
|
||
function inApp() {
|
||
var u = navigator.userAgent || '';
|
||
if (/FBAN|FBAV|FB_IAB|Instagram|Line\/|Twitter|Snapchat|GSA\/|Telegram|\bwv\b|WebView/i.test(u)) return true;
|
||
return /iPhone|iPad|iPod/.test(u) && !/Safari\//.test(u); // an iOS web view: no Safari token
|
||
}
|
||
var ref = '';
|
||
try { ref = new URLSearchParams(location.search).get('ref') || ''; } catch (e) { ref = ''; }
|
||
fetch('/api/public/bixpay' + (ref ? '?ref=' + encodeURIComponent(ref) : ''), { credentials: 'same-origin' }).then(function (r) { return r.json(); }).then(function (d) {
|
||
if (!d || !d.live) { if (soon) soon.hidden = false; cta.href = '/my#wallet'; if (using) using.textContent = 'Sign in to your dashboard and open the Wallet tab.'; return; }
|
||
cta.href = d.go;
|
||
if (using) using.textContent = d.whose === 'you' ? 'The button opens your own BixPay partner link.' : d.whose === 'sponsor' ? 'The button opens ' + d.name + "'s BixPay partner link." + (d.signedIn ? ' Add yours in Members > Profile.' : '') : 'The button opens the network’s BixPay partner link.' + (d.signedIn ? ' Add yours in Members > Profile.' : '');
|
||
if (box && inApp()) {
|
||
box.hidden = false;
|
||
if (boxLink) boxLink.textContent = d.go;
|
||
if (boxCopy) boxCopy.addEventListener('click', function () {
|
||
var done = function () { boxCopy.textContent = 'Copied'; setTimeout(function () { boxCopy.textContent = 'Copy link'; }, 2000); };
|
||
var select = function () { try { var r = document.createRange(); r.selectNodeContents(boxLink); var s = window.getSelection(); s.removeAllRanges(); s.addRange(r); boxCopy.textContent = 'Selected: copy it'; } catch (e) {} }; // no native dialogs
|
||
if (navigator.clipboard && navigator.clipboard.writeText) navigator.clipboard.writeText(d.go).then(done, select);
|
||
else select();
|
||
});
|
||
}
|
||
}).catch(function () {});
|
||
})();
|