// LinkSpin support (2026-10-16): the public /support form and the private ticket link page (/support/t/). // Both talk to this site's /api/support routes, which proxy to the one shared desk on InstantAdPay (helpdesk.js). // They pass the curtain, so nothing here may depend on a route that does not (a failed /api/me just means signed out). // Times show in US Central. Members follow up in the Control Room's Help screen (help-screen.js). (function () { const esc = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c])); const CATS = ['Account & sign-in', 'Wallet & payouts', 'Buying packages', 'Ads & campaigns', 'Earning credits & games', 'Team & referrals', 'Other']; const STATUS = { open: 'Open', waiting_on_member: 'Waiting on you', closed: 'Closed' }; const AUTHOR = { member: 'You', admin: 'Marty, LinkSpin support', system: 'LinkSpin' }; const when = ts => ts ? new Date(Number(ts)).toLocaleString('en-US', { timeZone: 'America/Chicago', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) + ' CT' : ''; const linkify = s => esc(s).replace(/(https?:\/\/[^\s<]+[^\s<.,;:!?)\]])/g, '$1'); const $ = id => document.getElementById(id); async function call(path, body) { const o = { method: body === undefined ? 'GET' : 'POST', headers: { Accept: 'application/json' } }; if (body !== undefined) { o.headers['Content-Type'] = 'application/json'; o.body = JSON.stringify(body); } let r; try { r = await (await fetch(path, o)).json(); } catch (e) { throw new Error('Could not reach support. Check your connection and try again.'); } if (r.error && !r.challenge) throw new Error(r.error); return r; } const host = $('supMain'); if (!host) return; const panel = (title, inner) => '
' + (title ? '

' + esc(title) + '

' : '') + '
' + inner + '
'; function threadHtml(v) { const t = v.ticket; return '

' + esc(t.subject) + '

' + esc(STATUS[t.status] || t.status) + '
' + '' + esc(t.ref) + ' · ' + esc(t.category) + ' · opened ' + esc(when(t.created)) + '' + v.messages.map(m => '
' + esc(AUTHOR[m.author] || m.author) + '' + esc(when(m.created)) + '
' + linkify(m.body) + '
').join('') + (t.status === 'closed' ? 'This ticket is closed. Write below and it opens again.' : '') + '
'; } async function page() { const m = /^\/support\/t\/([A-Za-z0-9_.-]{20,80})$/.exec(location.pathname); if (m) return tokenPage(m[1]); let me = null; try { me = await (await fetch('/api/me', { headers: { Accept: 'application/json' } })).json(); } catch (e) {} const signedIn = !!(me && me.signedIn && me.email); host.innerHTML = (signedIn ? panel('', 'You are signed in as ' + esc(me.username ? '@' + me.username : me.email) + '. Your tickets and Marty\'s replies live in Help in your Control Room, the easiest place to follow up. This form works too and files the ticket under your account.') : '') + '

Send a ticket

Marty reads every one
' + '' + (signedIn ? '' : '' + '') + '' + '' + '' + '' + '
' + '
'; $('supForm').addEventListener('submit', async e => { e.preventDefault(); const btn = $('supSend'); if (btn.disabled) return; btn.disabled = true; const msg = $('supMsg'); msg.className = 'msg'; msg.textContent = 'Sending…'; const val = id => { const el = $(id); return el ? el.value : ''; }; try { const g = IAP.guard; await g.formSettled(); let pick = null, r = null; for (let i = 0; i < 4; i++) { r = await call('/api/support', { name: val('supName'), email: val('supEmail'), category: val('supCat'), subject: val('supSubject'), body: val('supBody'), fts: g.FORM_TS, hp_field_x9: g.hpValue($('supHp')), pick }); if (r.challenge) { msg.textContent = ''; pick = await g.iconCheck($('supCheck'), r.challenge, r.error); continue; } break; } if (!r || !r.ok) throw new Error('Could not verify. Refresh the page and try again.'); host.innerHTML = panel('Got it. Your ticket is ' + r.ref, 'Marty reads every ticket and replies as soon as he can. ' + (r.member ? 'His reply shows up in Help in your Control Room and in your email.' : 'We just emailed you a private link to this ticket, so you can check on it or add more detail without signing in. If it does not arrive, look in spam or promotions.') + '' + '
' + (r.member ? 'Open it in Help' : 'View your ticket') + 'Back to LinkSpin
'); window.scrollTo(0, 0); } catch (err) { msg.className = 'msg bad'; msg.textContent = err.message; } finally { btn.disabled = false; } }); } async function tokenPage(tok) { const h = $('supH'); if (h) h.textContent = 'Your support ticket'; host.innerHTML = panel('', 'Loading your ticket…'); let v; try { v = await call('/api/support/t/' + encodeURIComponent(tok)); } catch (e) { host.innerHTML = panel('', '' + esc(e.message) + '
Send a new ticket
'); return; } const draw = v2 => { host.innerHTML = threadHtml(v2) + panel('Your reply', '' + '
' + 'Keep this link private: anyone with it can read and answer this ticket. Members can also follow up from Help in the Control Room.'); const btn = $('tkSend'); btn.addEventListener('click', async () => { if (btn.disabled) return; btn.disabled = true; try { const nv = await call('/api/support/t/' + encodeURIComponent(tok) + '/reply', { body: $('tkBody').value }); draw(nv); const mm = $('tkMsg'); mm.className = 'msg'; mm.textContent = 'Reply sent. Marty will see it.'; } catch (e) { const mm = $('tkMsg'); mm.className = 'msg bad'; mm.textContent = e.message; btn.disabled = false; } }); }; draw(v); } page(); })();