fix: the TAR probe view auto-selects the preset; the keyset selectors refresh (v3.8.0)
Two selector bugs in the new TAR-probe view and one stale-list bug in the RAM view, all from the lazy population of the view-specific preset selects: - cardsAutoSelectByIccid() set sp-card-sel and ram-card-sel only, so the TAR probe view never got the equipped card's preset (and tarExecute() then ran with preset_id: '', i.e. without persisting the counters it consumed); - tarRender()'s keep-fallback was -1 instead of the remembered _ramCardIdx, so the select stayed on "— Select card —" even when the auto-selection had remembered the preset; the TAR pill switch now also calls tarRender(); - the keyset selectors showed a stale "N — not defined in the preset": spKeysetSync() runs during the auto-selection, when ram/tar-card-sel have no options yet, so those lists were built with no preset; ramRender() now rebuilds them (spKeysetSync) once its preset is known - tarRender() already did. Tests: the auto-select covers tar-card-sel; a DOM-driven regression test (ramRender with a remembered preset and a two-keyset preset must show value="2" selected and no "not defined" entry); source guards for ramRender's sync, tarRender's keep and the TAR pill switch. sw cache simple-v339.
This commit is contained in:
+11
-3
@@ -1831,7 +1831,7 @@ function scp80SwitchSubtab(name) {
|
||||
document.getElementById('scp80-sub-ram').classList.toggle('hidden', name !== 'ram');
|
||||
document.getElementById('scp80-sub-tar').classList.toggle('hidden', name !== 'tar');
|
||||
if (name === 'ram') ramRender();
|
||||
if (name === 'tar') tarProbeRender();
|
||||
if (name === 'tar') { tarRender(); tarProbeRender(); }
|
||||
scp80HelpAnchor = { sp: 'secured-packet', ram: 'ram', tar: 'tar-probe' }[name] || 'secured-packet';
|
||||
setHelpAnchor(scp80HelpAnchor);
|
||||
}
|
||||
@@ -8402,6 +8402,10 @@ function ramRender() {
|
||||
sel.appendChild(opt);
|
||||
});
|
||||
if (keep !== null && keep !== undefined && cards[keep]) sel.value = String(keep);
|
||||
// the keyset selector is built from this view's preset: rebuild it now that
|
||||
// the preset is known (the auto-selection runs before the select has its
|
||||
// options, which used to leave a stale "not defined in the preset" entry)
|
||||
spKeysetSync();
|
||||
ramOpChanged();
|
||||
ramExpandedDetailsInit();
|
||||
}
|
||||
@@ -10695,7 +10699,9 @@ function tarRender() {
|
||||
const sel = document.getElementById('tar-card-sel');
|
||||
if (!sel) return;
|
||||
const prev = parseInt(sel.value, 10);
|
||||
const keep = (!isNaN(prev) && cards[prev]) ? prev : -1;
|
||||
// keep the current/remembered selection across rebuilds (the auto-selection
|
||||
// sets _ramCardIdx before this select has its options)
|
||||
const keep = (!isNaN(prev) && cards[prev]) ? prev : _ramCardIdx;
|
||||
sel.innerHTML = '<option value="" data-l10n="— Select card —">— Select card —</option>';
|
||||
cards.forEach((c, i) => {
|
||||
const opt = document.createElement('option');
|
||||
@@ -10703,7 +10709,7 @@ function tarRender() {
|
||||
opt.textContent = c.name || ('Card ' + i);
|
||||
sel.appendChild(opt);
|
||||
});
|
||||
if (keep >= 0) sel.value = String(keep);
|
||||
if (keep !== null && keep !== undefined && cards[keep]) sel.value = String(keep);
|
||||
spKeysetSync();
|
||||
}
|
||||
|
||||
@@ -11849,6 +11855,8 @@ function cardsAutoSelectByIccid(iccid) {
|
||||
if (sp) sp.value = String(idx);
|
||||
const ram = document.getElementById('ram-card-sel');
|
||||
if (ram) ram.value = String(idx);
|
||||
const tar = document.getElementById('tar-card-sel');
|
||||
if (tar) tar.value = String(idx);
|
||||
_ramCardIdx = idx;
|
||||
cardsApply(String(idx));
|
||||
return idx;
|
||||
|
||||
Reference in New Issue
Block a user