173 lines
7.2 KiB
JavaScript
173 lines
7.2 KiB
JavaScript
import { listGames } from '../data/games/index.js';
|
||
import { escapeHtml } from './formatters.js';
|
||
|
||
const ALL_METHODS = [
|
||
'all',
|
||
'Walking',
|
||
'Horde',
|
||
'Old Rod',
|
||
'Good Rod',
|
||
'Super Rod',
|
||
'Surf',
|
||
'Rock Smash',
|
||
'Dive',
|
||
'DexNav Hidden',
|
||
'Mirage Spot',
|
||
'Soaring',
|
||
'Gift',
|
||
'Gift Egg',
|
||
'Trade',
|
||
'Static',
|
||
'Fossil',
|
||
'Breeding',
|
||
'Evolution',
|
||
];
|
||
|
||
export function renderHeader(game, state, progress, profilesWithCounts = null) {
|
||
const methodOptions = ALL_METHODS.map((m) => {
|
||
const label = m === 'all' ? 'All Methods' : m;
|
||
return `<option value="${escapeHtml(m)}" ${state.methodFilter === m ? 'selected' : ''}>${escapeHtml(label)}</option>`;
|
||
}).join('');
|
||
|
||
const versionPills = listGames()
|
||
.map((g) => {
|
||
const isActive = g.id === game.id;
|
||
const cls = g.themeClass || (g.id === 'omega-ruby' ? 'version-or' : 'version-as');
|
||
return `
|
||
<button
|
||
type="button"
|
||
class="version-switch-btn ${cls} ${isActive ? 'active' : ''}"
|
||
data-switch-game="${escapeHtml(g.id)}"
|
||
aria-pressed="${isActive}"
|
||
>${escapeHtml(g.title)}</button>
|
||
`;
|
||
})
|
||
.join('');
|
||
|
||
const profileList =
|
||
profilesWithCounts ||
|
||
(state.profiles || [{ id: 'default', name: 'Save 1', caughtCount: state.caught?.size || 0 }]);
|
||
|
||
const profileOptions = profileList
|
||
.map((p) => {
|
||
const countText = Number.isInteger(p.caughtCount) ? ` (${p.caughtCount})` : '';
|
||
return `<option value="${escapeHtml(p.id)}" ${p.id === state.profileId ? 'selected' : ''}>${escapeHtml(p.name)}${escapeHtml(countText)}</option>`;
|
||
})
|
||
.join('');
|
||
|
||
const rulesetSoloLabel =
|
||
game.id === 'omega-ruby' ? 'Strict Solo OR Cartridge' : 'Strict Solo AS Cartridge';
|
||
const rulesetAllLabel =
|
||
game.id === 'omega-ruby'
|
||
? 'Show All (incl. Trade / AS / Events)'
|
||
: 'Show All (incl. Trade / OR / Events)';
|
||
|
||
return `
|
||
<header class="app-header ${escapeHtml(game.themeClass || 'version-as')}">
|
||
<div class="header-top">
|
||
<div class="brand-block">
|
||
<div class="brand-badges">
|
||
<a class="hub-home-link" href="../" title="Back to Professor Oak Tracker Hub">← Hub</a>
|
||
<div class="version-switcher" role="group" aria-label="Game Version">
|
||
${versionPills}
|
||
</div>
|
||
<span class="platform-pill">${escapeHtml(game.platform)}</span>
|
||
</div>
|
||
<h1 class="app-title">Professor Oak Challenge Tracker</h1>
|
||
<p class="app-subtitle">
|
||
Inspired by the Luminescent 2.1 Tracker — check any Pokémon <span class="mint-inline">Caught</span> to highlight every occurrence across Areas & Pokédex. Evolutions unlock at each upcoming Gym Leader / Champion level cap, and exclusive picks lock out alternatives automatically.
|
||
</p>
|
||
</div>
|
||
|
||
<div class="progress-panel">
|
||
<div class="profile-bar">
|
||
<label class="profile-label" for="profile-select">Save</label>
|
||
<select class="select-input select-sm profile-select" id="profile-select" aria-label="Active save profile">
|
||
${profileOptions}
|
||
</select>
|
||
<button type="button" class="btn-ghost btn-xs" data-action="new-profile" title="Create a new save profile">+ New</button>
|
||
<button type="button" class="btn-ghost btn-xs" data-action="rename-profile" title="Rename active save profile">Rename</button>
|
||
${
|
||
profileList.length > 1
|
||
? '<button type="button" class="btn-ghost btn-xs btn-danger" data-action="delete-profile" title="Delete active save profile">Del</button>'
|
||
: ''
|
||
}
|
||
</div>
|
||
<div class="progress-stats-row">
|
||
<div>
|
||
<span class="progress-count">${progress.totalCaught}</span>
|
||
<span class="progress-sep">/</span>
|
||
<span class="progress-total">${progress.totalObtainable}</span>
|
||
<span class="progress-caption">${state.ruleset === 'solo' ? 'Solo POC Caught' : 'All Dex Caught'}</span>
|
||
</div>
|
||
<span class="progress-pct">${progress.percent}%</span>
|
||
</div>
|
||
<div class="progress-track" role="progressbar" aria-valuenow="${progress.percent}" aria-valuemin="0" aria-valuemax="100">
|
||
<div class="progress-fill" style="width: ${progress.percent}%"></div>
|
||
</div>
|
||
<div class="progress-meta-row">
|
||
<span>Remaining: <strong>${progress.totalRemaining}</strong></span>
|
||
<div class="header-actions">
|
||
<button type="button" class="btn-ghost btn-sm" data-action="export-json">Export Save</button>
|
||
<button type="button" class="btn-ghost btn-sm" data-action="import-json">Import</button>
|
||
<button type="button" class="btn-ghost btn-sm btn-danger" data-action="reset-progress">Reset</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="header-toolbar">
|
||
<nav class="tab-nav" aria-label="Tracker views">
|
||
<button type="button" class="tab-btn ${state.activeTab === 'routes' ? 'active' : ''}" data-tab="routes">
|
||
Areas & Routes
|
||
</button>
|
||
<button type="button" class="tab-btn ${state.activeTab === 'pokedex' ? 'active' : ''}" data-tab="pokedex">
|
||
Pokédex & Evolution Methods
|
||
</button>
|
||
<button type="button" class="tab-btn ${state.activeTab === 'guide' ? 'active' : ''}" data-tab="guide">
|
||
POC Stones & Tips
|
||
</button>
|
||
</nav>
|
||
|
||
<div class="filter-controls">
|
||
<div class="search-wrap">
|
||
<input
|
||
type="search"
|
||
id="global-search"
|
||
class="search-input"
|
||
placeholder="Search Pokémon, trainer, stone..."
|
||
value="${escapeHtml(state.searchQuery)}"
|
||
autocomplete="off"
|
||
/>
|
||
${state.searchQuery ? '<button type="button" class="search-clear" data-action="clear-search" title="Clear search">×</button>' : ''}
|
||
</div>
|
||
|
||
${
|
||
state.activeTab === 'routes'
|
||
? `<select class="select-input" id="method-filter" aria-label="Filter encounter method">${methodOptions}</select>`
|
||
: ''
|
||
}
|
||
|
||
<select class="select-input" id="ruleset-select" aria-label="Pokédex ruleset">
|
||
<option value="solo" ${state.ruleset === 'solo' ? 'selected' : ''}>${escapeHtml(rulesetSoloLabel)}</option>
|
||
<option value="all" ${state.ruleset === 'all' ? 'selected' : ''}>${escapeHtml(rulesetAllLabel)}</option>
|
||
</select>
|
||
|
||
<label class="toggle-chip ${state.uncaughtOnly ? 'active' : ''}">
|
||
<input type="checkbox" id="uncaught-only-toggle" ${state.uncaughtOnly ? 'checked' : ''} />
|
||
<span>Uncaught Only</span>
|
||
</label>
|
||
|
||
<label
|
||
class="toggle-chip ${state.includeSuperTraining ? 'active' : ''}"
|
||
title="Optional: unlock early stone evolutions via Secret Super Training (510 EV minigames) as soon as their base forms are caught"
|
||
>
|
||
<input type="checkbox" id="super-training-toggle" ${state.includeSuperTraining ? 'checked' : ''} />
|
||
<span>Secret Super Training</span>
|
||
</label>
|
||
</div>
|
||
</div>
|
||
</header>
|
||
`;
|
||
}
|