mirror of
https://github.com/myronblair/tomtomgames
synced 2026-06-30 17:51:08 -05:00
Pass saved alias to platform on launch; copy to clipboard
- platforms table gets url_alias_param column (configurable per platform) - Admin game form has new "Username URL Param" field — leave blank if platform doesn't support it, or set to e.g. "username" if it does - Platform cards now use onclick openPlatform() instead of plain href: copies player's saved alias to clipboard on every click, and if url_alias_param is set appends ?param=alias to the launch URL - Toast notification confirms "Alias copied — paste into login" Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -661,6 +661,7 @@ body::before{content:'';position:fixed;inset:0;background-image:linear-gradient(
|
||||
</div>
|
||||
<div class="section-title"><span>PLAY NOW</span></div>
|
||||
<div class="platform-grid" id="platform-grid"></div>
|
||||
<div id="platform-alias-toast" style="position:fixed;bottom:80px;left:50%;transform:translateX(-50%) translateY(10px);background:rgba(0,0,0,.88);color:#fff;font-size:14px;font-weight:700;padding:10px 18px;border-radius:24px;white-space:nowrap;opacity:0;transition:opacity .3s,transform .3s;pointer-events:none;z-index:999;border:1px solid rgba(0,229,255,.25)"></div>
|
||||
</div>
|
||||
|
||||
<!-- ═══ BUY TOKENS (milkyswipe style) ═══ -->
|
||||
@@ -1405,19 +1406,40 @@ async function refreshUser() {
|
||||
}
|
||||
|
||||
// ─── PLATFORMS ─────────────────────────────────────────────
|
||||
function openPlatform(slug, url, aliasParam) {
|
||||
const alias = savedAliases[slug] || '';
|
||||
let launchUrl = url;
|
||||
if (alias && aliasParam) {
|
||||
const sep = url.includes('?') ? '&' : '?';
|
||||
launchUrl = url + sep + encodeURIComponent(aliasParam) + '=' + encodeURIComponent(alias);
|
||||
}
|
||||
window.open(launchUrl, '_blank', 'noopener');
|
||||
if (alias) {
|
||||
navigator.clipboard?.writeText(alias).catch(() => {});
|
||||
const t = document.getElementById('platform-alias-toast');
|
||||
if (t) {
|
||||
t.textContent = '📋 "' + alias + '" copied — paste into login';
|
||||
t.style.opacity = '1'; t.style.transform = 'translateY(0)';
|
||||
clearTimeout(t._timer);
|
||||
t._timer = setTimeout(() => { t.style.opacity='0'; t.style.transform='translateY(10px)'; }, 3000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function buildPlatforms() {
|
||||
if (!CFG.platforms || !CFG.platforms.length) return;
|
||||
|
||||
const grid = document.getElementById('platform-grid');
|
||||
if (grid) {
|
||||
grid.innerHTML = CFG.platforms.map(p => `
|
||||
<a href="${p.url}" target="_blank" class="platform-card" style="--p-color:${p.color}">
|
||||
<div class="platform-card" style="--p-color:${p.color};cursor:pointer"
|
||||
onclick="openPlatform('${p.id}',${JSON.stringify(p.url)},${JSON.stringify(p.alias_param||'')})">
|
||||
<div class="platform-img-wrap">
|
||||
<img src="/assets/img/${p.id}.svg" alt="${p.name}" onerror="this.style.display='none'">
|
||||
</div>
|
||||
<div class="platform-name">${p.name}</div>
|
||||
<div class="play-btn">TAP TO PLAY →</div>
|
||||
</a>`).join('');
|
||||
</div>`).join('');
|
||||
}
|
||||
|
||||
// Populate selects — clear dynamic options first to prevent duplicates on re-call
|
||||
|
||||
Reference in New Issue
Block a user