LOADING ARCADEโฆ
= 0 ? h.slice(0, q) : h).toLowerCase() || 'home';
var search = q >= 0 ? h.slice(q) : '';
if (route === 'index' || route === 'games') route = 'home';
return { route: route, search: search };
}
function render() {
var p = parseHash();
var html = pageSource(p.route);
if (!html) { p = { route: 'home', search: '' }; html = pageSource('home'); }
current = p; try { window.__dianeRoute && window.__dianeRoute(p.route); } catch (e) {}
boot.classList.remove('hide');
html = html.replace('window.__SEARCH = ""', 'window.__SEARCH = ' + JSON.stringify(p.search));
stage.onload = function () {
boot.classList.add('hide');
try {
var d = stage.contentDocument;
if (d && d.title) document.title = d.title;
if (p.route === 'home' && location.hash === '#/home-games') d.getElementById('games') && d.getElementById('games').scrollIntoView();
} catch (e) {}
};
stage.srcdoc = window.__dianeInject ? window.__dianeInject(p.route, html) : html;
}
// Convert an old-style link ("profile.html", "game.html?game=x", "#games") into a route
window.__arcadeGo = function (href) {
href = String(href || '');
if (href === '#games') { var d = stage.contentDocument; var g = d && d.getElementById('games'); if (g) g.scrollIntoView({behavior:'smooth'}); return; }
var m = href.match(/^\.?\/?([^?#]+?)(\.html?)?(\?.*)?(#.*)?$/i);
if (!m) return;
var key = (m[1] + (m[2] || '')).toLowerCase();
var route = FILE_ROUTES[key] || FILE_ROUTES[(m[1] + '.html').toLowerCase()] || m[1].toLowerCase();
var target = '#/' + route + (m[3] || '');
if (location.hash === target) { render(); } else { location.hash = target; }
};
window.__arcadeReload = render;
window.addEventListener('hashchange', render);
render();
})();