0f56d3c7bb
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
35 lines
4.2 KiB
JavaScript
35 lines
4.2 KiB
JavaScript
// 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=<username> 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/' + encodeURIComponent(ref); } // the sponsored join page itself (bare /join used to 404, Diann 2026-10-11)
|
|
function card(g) {
|
|
var soon = !g.live && g.opens;
|
|
var ribbon = g.season ? '<span class="ribbon">Limited time · ends ' + esc(g.season.ends) + '</span>' : soon ? '<span class="ribbon soon">' + esc(g.opens) + '</span>' : '';
|
|
var play = g.live && g.open ? '<a class="btn" href="' + esc(g.open) + '" target="_blank" rel="noopener">Play</a>' : '<span class="btn" aria-disabled="true">' + esc(g.opens || 'Opens soon') + '</span>';
|
|
var site = g.host ? '<span class="host">' + esc(g.host) + '</span>' : '';
|
|
var art = g.video ? '<video controls playsinline preload="none" poster="' + esc(g.poster || g.art || '') + '" src="' + esc(g.video) + '" style="width:100%;height:100%;object-fit:cover;display:block;background:#000"></video>' : (g.art ? '<img src="' + esc(g.art) + '" alt="" loading="lazy"' + (g.artPos ? ' style="object-position:' + esc(g.artPos) + ' center"' : '') + '>' : '');
|
|
return '<div class="gcard"><div class="art">' + art + ribbon + '</div>' +
|
|
'<div class="body"><span class="tag">' + esc(g.tag || '') + '</span><h3>' + esc(g.name) + '</h3><p>' + esc(g.blurb || '') + '</p>' +
|
|
(g.pays ? '<div class="pays">Pays: <b>' + esc(g.pays) + '</b></div>' : '') +
|
|
'<div class="row">' + play + site + '</div></div></div>';
|
|
}
|
|
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 = '<h2 class="gsec">Open now · ' + live.length + ' game' + (live.length === 1 ? '' : 's') + '</h2><div class="ggrid">' + live.map(card).join('') + '</div>';
|
|
if (soon.length) S.innerHTML = '<h2 class="gsec">Opening next</h2><div class="ggrid">' + soon.map(card).join('') + '</div>';
|
|
}).catch(function () { document.getElementById('gEmpty').hidden = false; });
|
|
// featured warriors from the PolyWarriors market (2026-10-10): the rarest listings, with the forged art
|
|
fetch('/api/public/pw-featured').then(function (r) { return r.json(); }).then(function (d) {
|
|
var f = (d && d.featured) || []; if (!f.length) return; var S = document.getElementById('gSoon'); var host = document.createElement('div'); host.id = 'gFeatured';
|
|
host.innerHTML = '<h2 class="gsec">From the PolyWarriors market <small style="letter-spacing:0;text-transform:none;font-size:11px"> <a href="' + esc(d.market) + '" target="_blank" rel="noopener">open the market</a></small></h2><div class="fgrid">' + f.map(function (x) {
|
|
return '<a class="fcard" href="' + esc(x.url) + '" target="_blank" rel="noopener" style="--rc:' + esc(x.color) + '"><div class="fpic"><img src="' + esc(x.image) + '" alt="" loading="lazy"><span class="ftag">' + esc(x.rarity) + '</span>' + (x.forSale ? '<span class="fsale">For sale</span>' : '') + '</div><div class="fb"><b>' + esc(x.name) + ' #' + String(x.serial).padStart(4, '0') + '</b>' + (x.forge ? '<small>Forged ' + esc(x.forge.grade) + ' ' + esc(x.forge.score) + '</small>' : '') + (x.forSale ? '<span class="fp">' + esc(x.price) + ' POL</span>' : '') + '</div></a>'; }).join('') + '</div>';
|
|
S.parentNode.insertBefore(host, S.nextSibling);
|
|
}).catch(function () {});
|
|
})();
|