n opens the NOC dashboard, and a letter right after it opens a tab

n then o, u, c, t, r or l, within a second, opens Overview, Customers,
Connections, Traffic, Links & routers or Leased lines. n never closes
the dashboard, so n c switches tabs without it flashing shut; Escape
closes it. Shift on the way does not cancel the wait, any other key
does. The ? list shows the letters.
This commit is contained in:
Charlie Allom 2026-11-03 10:20:15 +00:00
parent 23eeddf44f
commit d88684d86e
No known key found for this signature in database
10 changed files with 43 additions and 8 deletions

View file

@ -6,7 +6,7 @@ All notable changes to this project are documented here. The project follows
## [Unreleased]
- New keyboard shortcuts: [ and ] step through your POPs, - and = zoom the map out and in, and ? lists every shortcut. Help links to the list too.
- New keyboard shortcuts: [ and ] step through your POPs, - and = zoom the map out and in, n opens the NOC dashboard, and ? lists every shortcut. A letter right after n opens one of the dashboard's tabs, such as n c for Connections, and Help links to the list too.
## [2.6.0] — 2026-11-03

View file

@ -2374,6 +2374,7 @@
"keys.esc":"Esc",
"keys.game_speed":"Spielgeschwindigkeit: ½×, 1×, 2×, 4×, 8×",
"keys.keyboard_shortcuts":"Tastenkürzel",
"keys.noc_dashboard_a_letter_right":"NOC-Dashboard. Ein Buchstabe direkt danach öffnet einen Tab:",
"keys.pause_or_play":"Pause oder weiter",
"keys.previous_or_next_of_your":"Vorheriger oder nächster deiner POPs",
"keys.show_this_list":"Diese Liste zeigen",

View file

@ -2372,6 +2372,7 @@
"keys.esc":"Esc",
"keys.game_speed":"Velocidad del juego: ½×, 1×, 2×, 4×, 8×",
"keys.keyboard_shortcuts":"Atajos de teclado",
"keys.noc_dashboard_a_letter_right":"Panel del NOC. Una letra justo después abre una pestaña:",
"keys.pause_or_play":"Pausar o reanudar",
"keys.previous_or_next_of_your":"Tu POP anterior o siguiente",
"keys.show_this_list":"Mostrar esta lista",

View file

@ -2372,6 +2372,7 @@
"keys.esc":"Échap",
"keys.game_speed":"Vitesse du jeu : ½×, 1×, 2×, 4×, 8×",
"keys.keyboard_shortcuts":"Raccourcis clavier",
"keys.noc_dashboard_a_letter_right":"Tableau de bord NOC. Une lettre juste après ouvre un onglet :",
"keys.pause_or_play":"Pause ou reprise",
"keys.previous_or_next_of_your":"Ton POP précédent ou suivant",
"keys.show_this_list":"Afficher cette liste",

View file

@ -2372,6 +2372,7 @@
"keys.esc":"Esc",
"keys.game_speed":"Velocità di gioco: ½×, 1×, 2×, 4×, 8×",
"keys.keyboard_shortcuts":"Scorciatoie da tastiera",
"keys.noc_dashboard_a_letter_right":"Dashboard NOC. Una lettera subito dopo apre una scheda:",
"keys.pause_or_play":"Pausa o riprendi",
"keys.previous_or_next_of_your":"Il tuo POP precedente o successivo",
"keys.show_this_list":"Mostra questo elenco",

View file

@ -2372,6 +2372,7 @@
"keys.esc":"Esc",
"keys.game_speed":"Velocidade do jogo: ½×, 1×, 2×, 4×, 8×",
"keys.keyboard_shortcuts":"Atalhos de teclado",
"keys.noc_dashboard_a_letter_right":"Dashboard do NOC. Uma letra logo depois abre uma aba:",
"keys.pause_or_play":"Pausar ou continuar",
"keys.previous_or_next_of_your":"Seu POP anterior ou próximo",
"keys.show_this_list":"Mostrar esta lista",

View file

@ -1,15 +1,22 @@
/* ---------- Keyboard shortcuts: [ ] step through your POPs, - = zoom, ? lists every key ----------
/* ---------- Keyboard shortcuts: [ ] step through your POPs, - = zoom, n (then a letter) the NOC, ? lists every key ----------
Space, 0–4 and Escape live with the map's input (96-map/90-input.js), / with Find a city. */
// Your POPs in the order Find a city lists them, so [ and ] walk the same list.
const popOrder=()=>S&&S.pops?Object.keys(S.pops).filter(isCity).sort((a,b)=>CITY[a].name.localeCompare(CITY[b].name)):[];
function showKeys(){const k=s=>`<span class="kbd">${s}</span>`;
const rows=[[k(tr('keys.space')),tr('keys.pause_or_play')],[k('0')+' – '+k('4'),tr('keys.game_speed')],[k('/'),tr('find.find_a_city')],[k('[')+' '+k(']'),tr('keys.previous_or_next_of_your')],[k('-')+' '+k('='),tr('keys.zoom_the_map_out_or')],[k(tr('keys.esc')),tr('keys.close_a_window_or_deselect')],[k('?'),tr('keys.show_this_list')]];
// n opens the NOC dashboard, and a letter within KEY_LEAD ms of it picks a tab (n c: Connections). n never closes the
// dashboard, so n c switches tabs without it flashing shut; Escape closes it.
const DASH_KEYS={o:'overview',u:'cust',c:'conn',t:'traffic',r:'infra',l:'lease'},KEY_LEAD=1000;let keyLead=0;
function showKeys(){const k=s=>`<span class="kbd">${s}</span>`,TN={overview:tr('common.overview'),cust:tr('common.customers'),conn:tr('common.connections'),traffic:tr('common.traffic'),infra:tr('common.links_routers'),lease:tr('common.leased_lines')};
const tabs=Object.entries(DASH_KEYS).map(([l,t])=>`<span class="keytab">${k(l)} ${TN[t]}</span>`).join(' ');
const rows=[[k(tr('keys.space')),tr('keys.pause_or_play')],[k('0')+' – '+k('4'),tr('keys.game_speed')],[k('/'),tr('find.find_a_city')],[k('[')+' '+k(']'),tr('keys.previous_or_next_of_your')],[k('-')+' '+k('='),tr('keys.zoom_the_map_out_or')],[k('n'),`${tr('keys.noc_dashboard_a_letter_right')}<br>${tabs}`],[k(tr('keys.esc')),tr('keys.close_a_window_or_deselect')],[k('?'),tr('keys.show_this_list')]];
openModal(`<div style="display:flex;align-items:center"><h2 style="font-size:28px">⌨️ ${tr('keys.keyboard_shortcuts')}</h2><button class="x" data-act="helpClose" aria-label="${tr('common.close')}">×</button></div>
<dl class="keylist">${rows.map(([a,b])=>`<dt>${a}</dt><dd>${b}</dd>`).join('')}</dl><div class="btns" style="margin-top:14px">${btn(UI.started?tr('common.back_to_the_map'):tr('common.got_it'),'helpClose',{},'big')}</div>`,'keys');}
document.addEventListener('keydown',e=>{
// Many layouts type [ and ] with Option or AltGr held, so Alt alone is fine; Ctrl or Cmd belongs to the browser.
if(e.metaKey||(e.ctrlKey&&!e.altKey)||(e.target.closest&&e.target.closest('input,textarea,select,[contenteditable]')))return;
const k=e.key,step={'[':-1,']':1}[k],zoom={'-':-1,'_':-1,'=':1,'+':1}[k];
if(e.key==='Shift'||e.metaKey||(e.ctrlKey&&!e.altKey)||(e.target.closest&&e.target.closest('input,textarea,select,[contenteditable]')))return;
const k=e.key.length===1?e.key.toLowerCase():e.key,step={'[':-1,']':1}[k],zoom={'-':-1,'_':-1,'=':1,'+':1}[k];
const lead=Date.now()-keyLead<KEY_LEAD;keyLead=0;
if(lead&&DASH_KEYS[k]&&!$('dash').hidden){e.preventDefault();ACT.dashTab({k:DASH_KEYS[k]});return;}
if(k==='n'){if(!S||!UI.started||!$('modal').hidden)return;e.preventDefault();if($('dash').hidden)ACT.dash();if(!$('dash').hidden)keyLead=Date.now();return;}
if(k==='?'){if(e.repeat)return;if($('modal').hidden){if(S&&UI.started){e.preventDefault();ACT.keys();}}else if($('modal').className==='keys'){e.preventDefault();closeModal();}return;}
if(!(step||zoom)||!S||!UI.started||!$('modal').hidden)return;
e.preventDefault();if(step)ACT.popStep({d:step});else ACT.zoomStep({d:zoom});});

View file

@ -2373,6 +2373,7 @@
"keys.esc":"Esc",
"keys.game_speed":"Game speed: ½×, 1×, 2×, 4×, 8×",
"keys.keyboard_shortcuts":"Keyboard shortcuts",
"keys.noc_dashboard_a_letter_right":"NOC dashboard. A letter right after it opens a tab:",
"keys.pause_or_play":"Pause or play",
"keys.previous_or_next_of_your":"Previous or next of your POPs",
"keys.show_this_list":"Show this list",

View file

@ -163,6 +163,7 @@ input.t{width:100%;box-sizing:border-box;border:3px solid var(--ink);border-radi
.keylist{display:grid;grid-template-columns:auto 1fr;gap:10px 16px;align-items:center;margin:14px 0 0}
.keylist dt{margin:0;white-space:nowrap}.keylist dd{margin:0;color:var(--ink2);font-size:14px}
.keylist .kbd{font-size:13px;padding:1px 7px;min-width:12px;text-align:center}
.keylist .keytab{display:inline-block;margin:6px 10px 0 0;white-space:nowrap}
/* "Your networks" on the title screen: one big tap target per network, a small ⋯ for export and delete. */
.slots{display:flex;flex-direction:column;gap:7px;margin-bottom:6px;max-height:min(46vh,330px);overflow:auto;padding:2px 2px 5px}

View file

@ -51,6 +51,27 @@ test('- and = zoom the map out and in around its middle, within the zoom limits'
assert.deepEqual(errors, []);
});
test('n opens the NOC dashboard, and n followed by a letter opens one of its tabs', () => {
const { ev, dom, errors } = load();
const key = keyer(dom), open = () => !ev("$('dash').hidden"), tab = () => ev("UI.dtab||'overview'");
ev(start);
key('n'); assert.ok(open(), 'n opens it');
assert.equal(tab(), 'overview');
key('c'); assert.equal(tab(), 'conn', 'n c: Connections');
key('n'); assert.ok(open(), 'n does not close it, so n c can switch tabs without a flash');
key('u'); assert.equal(tab(), 'cust');
for (const [l, t] of [['o', 'overview'], ['t', 'traffic'], ['r', 'infra'], ['l', 'lease'], ['c', 'conn']]) { key('n'); key(l); assert.equal(tab(), t, 'n ' + l); }
key('o'); assert.equal(tab(), 'conn', 'a letter on its own does nothing');
key('n'); key('Shift'); key('T'); assert.equal(tab(), 'traffic', 'Shift on the way does not cancel it');
key('n'); ev('keyLead=Date.now()-KEY_LEAD-1'); key('c'); assert.equal(tab(), 'traffic', 'too late: the letter stands alone');
key('n'); key('x'); key('c'); assert.equal(tab(), 'traffic', 'another key in between ends the wait');
key('Escape'); assert.ok(!open(), 'Escape closes it');
key('n'); key('c', null, { ctrlKey: true }); assert.equal(tab(), 'traffic', 'not with Ctrl');
ev("$('dash').hidden=true;ACT.rename()"); key('n', dom.window.document.getElementById('rnIn')); key('n');
assert.ok(!open(), 'not while typing or behind a window');
assert.deepEqual(errors, []);
});
test('? shows every keyboard shortcut and closes again; Help links to it on a computer, not on a phone', () => {
const { ev, dom, errors } = load();
const doc = dom.window.document, key = keyer(dom);
@ -58,9 +79,9 @@ test('? shows every keyboard shortcut and closes again; Help links to it on a co
key('?');
assert.equal(ev("$('modal').className"), 'keys', '? opens the list');
const txt = doc.getElementById('modalCard').textContent;
for (const s of ['Keyboard shortcuts', 'Space', 'Pause or play', 'Find a city', 'Previous or next of your POPs', 'Zoom the map out or in', 'Esc', 'Show this list'])
for (const s of ['Keyboard shortcuts', 'Space', 'Pause or play', 'Find a city', 'Previous or next of your POPs', 'Zoom the map out or in', 'NOC dashboard', 'Connections', 'Leased lines', 'Esc', 'Show this list'])
assert.ok(txt.includes(s), s);
for (const k of ['[', ']', '-', '=', '/', '?', '0', '4']) assert.ok([...doc.querySelectorAll('#modalCard .kbd')].some(e => e.textContent === k), k);
for (const k of ['[', ']', '-', '=', '/', '?', '0', '4', 'n', 'o', 'u', 'c', 't', 'r', 'l']) assert.ok([...doc.querySelectorAll('#modalCard .kbd')].some(e => e.textContent === k), k);
key('?', null, { repeat: true }); assert.equal(ev("$('modal').hidden"), false, 'holding ? does not flicker it');
key('?'); assert.equal(ev("$('modal').hidden"), true, '? again closes it');
key('?'); key('Escape'); assert.equal(ev("$('modal').hidden"), true, 'so does Escape');