// Public games page (2026-10-10): every game in the network, live ones first, then the ones with an opening date. // Data: /api/public/games/all. Play links go to each game's own site (the game signs the visitor in with InstantAdPay). // A ?ref= on this page is kept by the site's viral-link handling and carried onto the Join button. (function () { var esc = function (s) { return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) { return ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]; }); }; var ref = ''; try { ref = new URLSearchParams(location.search).get('ref') || ''; } catch (e) {} if (ref) { var j = document.getElementById('gJoin'); if (j) j.href = '/join?ref=' + encodeURIComponent(ref); } function card(g) { var soon = !g.live && g.opens; var ribbon = g.season ? 'Limited time · ends ' + esc(g.season.ends) + '' : soon ? '' + esc(g.opens) + '' : ''; var play = g.live && g.open ? 'Play' : '' + esc(g.opens || 'Opens soon') + ''; var site = g.host ? '' + esc(g.host) + '' : ''; return '
' + (g.art ? '' : '') + ribbon + '
' + '
' + esc(g.tag || '') + '

' + esc(g.name) + '

' + esc(g.blurb || '') + '

' + (g.pays ? '
Pays: ' + esc(g.pays) + '
' : '') + '
' + play + site + '
'; } fetch('/api/public/games/all').then(function (r) { return r.json(); }).then(function (d) { var games = (d && d.games) || []; var live = games.filter(function (g) { return g.live; }), soon = games.filter(function (g) { return !g.live; }); var L = document.getElementById('gLive'), S = document.getElementById('gSoon'); if (!games.length) { document.getElementById('gEmpty').hidden = false; return; } if (live.length) L.innerHTML = '

Open now · ' + live.length + ' game' + (live.length === 1 ? '' : 's') + '

' + live.map(card).join('') + '
'; if (soon.length) S.innerHTML = '

Opening next

' + soon.map(card).join('') + '
'; }).catch(function () { document.getElementById('gEmpty').hidden = false; }); })();