Fix vehicle icon lookup and default web account selection

Match archive paths without regard to case and include Golden Eagle
vehicles in icon extraction. Default read-only page state to the
current in-game account. Keep web mutations gated on an explicit
account ID.

Type checking and local icon and account selection checks passed.
In-game acceptance is pending.
This commit is contained in:
N0VAN0M4LY committed 2026-11-25 13:41:35 +08:00
1 parent 26fd6b51b7
commit ec2d3ffbc4
6 files changed
+63 -24

No files matched your search

@@ -43,8 +43,10 @@ function applyStaticTexts() {
async function loadState(userId) {
state = await WtoUi.getJson('/trade.gaijin.net/api/state' + (userId ? '?userId=' + encodeURIComponent(userId) : ''));
if (userId && !state.currentUserId) return loadState('');
if (state.currentUserId) WtoUi.saveAccount(state.currentUserId);
if (userId && !state.currentUserId) {
WtoUi.clearSavedAccount();
return loadState('');
}
WtoUi.fillAccountSelect($('accountSelect'), state.accounts, state.currentUserId);
$('gjnVal').textContent = WtoUi.gjn(state.balance.gjnCents);
$('goldVal').textContent = WtoUi.num(state.balance.goldenEagles);
@@ -112,12 +114,15 @@ function listingCard(listing) {
const foot = document.createElement('div');
foot.className = 'card-foot';
foot.innerHTML = '<span class="price"></span><button class="buy"></button>';
foot.innerHTML = '<span class="price"></span>';
foot.querySelector('.price').textContent = WtoUi.gjn(listing.gjnCostCents) + ' GJN';
const button = foot.querySelector('button');
button.textContent = state.currentUserId ? t('buy') : t('pickAccount');
button.disabled = !state.currentUserId;
button.onclick = () => buy(listing.itemdefId);
const btn = Object.assign(document.createElement('button'), {
className: 'buy',
textContent: state.currentUserId ? t('buy') : t('pickAccount'),
disabled: !state.currentUserId,
});
if (!btn.disabled) btn.onclick = () => buy(listing.itemdefId);
foot.appendChild(btn);
card.appendChild(foot);
return card;
}
@@ -135,7 +140,10 @@ $('tabs').onclick = (event) => {
activeCat = tab.dataset.cat;
renderGrid();
};
$('accountSelect').onchange = (event) => loadState(event.target.value);
$('accountSelect').onchange = (event) => {
WtoUi.saveAccount(event.target.value);
loadState(event.target.value);
};
$('countryFilter').onchange = renderGrid;
$('classFilter').onchange = renderGrid;
$('searchInput').oninput = renderGrid;