From 2680f3d82b2569c06bda4872690a9744c5cee4fa Mon Sep 17 00:00:00 2001 From: Charlie Allom Date: Tue, 3 Nov 2026 10:31:42 +0000 Subject: [PATCH 1/4] The arrow keys and W A S D move the map while held The map moves at 700 px a second on screen at any zoom. The keys run their own frame loop only while one is down, so the game loop does no extra work. Letting go, a window opening or leaving the browser window stops it, and a slow frame moves at most 50 ms worth. Arrows still scroll the NOC dashboard when it is open, and Alt or Cmd with an arrow stays the browser's. --- CHANGELOG.md | 2 +- site/i18n/de.js | 1 + site/i18n/es.js | 1 + site/i18n/fr.js | 1 + site/i18n/it.js | 1 + site/i18n/pt.js | 1 + src/game/93-ui/82-keys.js | 16 ++++++++++++++-- src/i18n/en.js | 1 + tests/keyboard-shortcuts.test.js | 33 ++++++++++++++++++++++++++++++-- 9 files changed, 52 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe14d8c..bf07b1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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, 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. +- New keyboard shortcuts: the arrow keys and W A S D move the map, [ and ] step through your POPs, - and = zoom 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 diff --git a/site/i18n/de.js b/site/i18n/de.js index 149fc64..5a3312c 100644 --- a/site/i18n/de.js +++ b/site/i18n/de.js @@ -2374,6 +2374,7 @@ "keys.esc":"Esc", "keys.game_speed":"Spielgeschwindigkeit: ½×, 1×, 2×, 4×, 8×", "keys.keyboard_shortcuts":"Tastenkürzel", +"keys.move_around_the_map":"Karte verschieben", "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", diff --git a/site/i18n/es.js b/site/i18n/es.js index c6d55a7..0f9312e 100644 --- a/site/i18n/es.js +++ b/site/i18n/es.js @@ -2372,6 +2372,7 @@ "keys.esc":"Esc", "keys.game_speed":"Velocidad del juego: ½×, 1×, 2×, 4×, 8×", "keys.keyboard_shortcuts":"Atajos de teclado", +"keys.move_around_the_map":"Mover el mapa", "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", diff --git a/site/i18n/fr.js b/site/i18n/fr.js index 43d5054..c0c9f01 100644 --- a/site/i18n/fr.js +++ b/site/i18n/fr.js @@ -2372,6 +2372,7 @@ "keys.esc":"Échap", "keys.game_speed":"Vitesse du jeu : ½×, 1×, 2×, 4×, 8×", "keys.keyboard_shortcuts":"Raccourcis clavier", +"keys.move_around_the_map":"Déplacer la carte", "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", diff --git a/site/i18n/it.js b/site/i18n/it.js index 0ac558c..1881b8e 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -2372,6 +2372,7 @@ "keys.esc":"Esc", "keys.game_speed":"Velocità di gioco: ½×, 1×, 2×, 4×, 8×", "keys.keyboard_shortcuts":"Scorciatoie da tastiera", +"keys.move_around_the_map":"Sposta la mappa", "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", diff --git a/site/i18n/pt.js b/site/i18n/pt.js index 422017c..5478bed 100644 --- a/site/i18n/pt.js +++ b/site/i18n/pt.js @@ -2372,6 +2372,7 @@ "keys.esc":"Esc", "keys.game_speed":"Velocidade do jogo: ½×, 1×, 2×, 4×, 8×", "keys.keyboard_shortcuts":"Atalhos de teclado", +"keys.move_around_the_map":"Mover o mapa", "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", diff --git a/src/game/93-ui/82-keys.js b/src/game/93-ui/82-keys.js index 334a05c..8bbde0c 100644 --- a/src/game/93-ui/82-keys.js +++ b/src/game/93-ui/82-keys.js @@ -1,13 +1,21 @@ -/* ---------- Keyboard shortcuts: [ ] step through your POPs, - = zoom, n (then a letter) the NOC, ? lists every key ---------- +/* ---------- Keyboard shortcuts: arrows/WASD move, [ ] 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)):[]; // 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; +// Arrow keys and WASD move the map while held, at a steady speed on screen. Their own frame loop runs only while one is +// down, so the game loop does no extra work; letting go, a window opening or leaving the browser window stops it. +const PAN_KEYS={ArrowUp:[0,-1],w:[0,-1],ArrowDown:[0,1],s:[0,1],ArrowLeft:[-1,0],a:[-1,0],ArrowRight:[1,0],d:[1,0]},PAN_SPEED=700; +const panHeld=new Set();let panAt=null; +function panFrame(t){if(!panHeld.size||!$('modal').hidden||!$('dash').hidden){panHeld.clear();return;} + // A slow frame (a busy day, a background tab) moves at most 50 ms worth, not a jump across the map. + const dt=panAt==null?0:Math.min(0.05,(t-panAt)/1000);panAt=t;let dx=0,dy=0;for(const k of panHeld){dx+=PAN_KEYS[k][0];dy+=PAN_KEYS[k][1];} + cam.x+=dx*PAN_SPEED*dt/cam.z;cam.y+=dy*PAN_SPEED*dt/cam.z;wrapCam();requestAnimationFrame(panFrame);} function showKeys(){const k=s=>`${s}`,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])=>`${k(l)} ${TN[t]}`).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')}
${tabs}`],[k(tr('keys.esc')),tr('keys.close_a_window_or_deselect')],[k('?'),tr('keys.show_this_list')]]; + const rows=[[[...'←↑↓→'].map(k).join(' ')+'
'+[...'wasd'].map(k).join(' '),tr('keys.move_around_the_map')],[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')}
${tabs}`],[k(tr('keys.esc')),tr('keys.close_a_window_or_deselect')],[k('?'),tr('keys.show_this_list')]]; openModal(`

⌨️ ${tr('keys.keyboard_shortcuts')}

${rows.map(([a,b])=>`
${a}
${b}
`).join('')}
${btn(UI.started?tr('common.back_to_the_map'):tr('common.got_it'),'helpClose',{},'big')}
`,'keys');} document.addEventListener('keydown',e=>{ @@ -18,5 +26,9 @@ document.addEventListener('keydown',e=>{ 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;} + // Alt with an arrow is the browser's Back and Forward. + if(!e.altKey&&PAN_KEYS[k]){if(!S||!UI.started||!$('modal').hidden||!$('dash').hidden)return;e.preventDefault();if(!panHeld.size){panAt=null;requestAnimationFrame(panFrame);}panHeld.add(k);return;} if(!(step||zoom)||!S||!UI.started||!$('modal').hidden)return; e.preventDefault();if(step)ACT.popStep({d:step});else ACT.zoomStep({d:zoom});}); +document.addEventListener('keyup',e=>panHeld.delete(e.key.length===1?e.key.toLowerCase():e.key)); +addEventListener('blur',()=>panHeld.clear()); diff --git a/src/i18n/en.js b/src/i18n/en.js index 6c710c1..beef4d8 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -2373,6 +2373,7 @@ "keys.esc":"Esc", "keys.game_speed":"Game speed: ½×, 1×, 2×, 4×, 8×", "keys.keyboard_shortcuts":"Keyboard shortcuts", +"keys.move_around_the_map":"Move around the map", "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", diff --git a/tests/keyboard-shortcuts.test.js b/tests/keyboard-shortcuts.test.js index 0590076..0b78ce9 100644 --- a/tests/keyboard-shortcuts.test.js +++ b/tests/keyboard-shortcuts.test.js @@ -51,6 +51,35 @@ test('- and = zoom the map out and in around its middle, within the zoom limits' assert.deepEqual(errors, []); }); +test('the arrow keys and W A S D move the map while held, at the same speed on screen at any zoom', (t) => { + const { ev, dom, errors } = load(); + // A key left held (a failed assertion) would keep the page's frame loop, and this test file, running. + t.after(() => dom.window.dispatchEvent(new dom.window.Event('blur'))); + const doc = dom.window.document, key = keyer(dom); + const up = k => doc.body.dispatchEvent(new dom.window.KeyboardEvent('keyup', { key: k, bubbles: true })); + const at = () => [ev('cam.x'), ev('cam.y')].map(v => Math.round(v * 100) / 100); + // Frames are driven by hand: panAt=null makes the first one a start, the next one 50 ms later moves. + const frames = (a, b) => ev(`panAt=null;panFrame(${a});panFrame(${b})`); + ev(start + ';cam.z=1;cam.x=1000;cam.y=500'); + key('ArrowRight'); frames(1000, 1050); assert.deepEqual(at(), [1035, 500], '700 px a second: 35 px in 50 ms'); + up('ArrowRight'); frames(1000, 1050); assert.deepEqual(at(), [1035, 500], 'letting go stops it'); + key('w'); key('a'); frames(0, 50); assert.deepEqual(at(), [1000, 465], 'W and A together: up and left'); + up('w'); up('A'); + assert.equal(ev('panHeld.size'), 0, 'a key let go with Shift held still counts'); + ev('cam.z=2'); key('s'); frames(0, 50); assert.deepEqual(at(), [1000, 482.5], 'zoomed in, the same 35 px on screen'); + frames(0, 2000); assert.deepEqual(at(), [1000, 500], 'a slow frame moves at most 50 ms worth'); + up('s'); + key('ArrowDown'); key('ArrowDown', null, { repeat: true }); assert.equal(ev('panHeld.size'), 1, 'key repeat is the same key'); + dom.window.dispatchEvent(new dom.window.Event('blur')); assert.equal(ev('panHeld.size'), 0, 'leaving the window lets go'); + key('d'); ev('ACT.keys()'); frames(0, 50); assert.deepEqual(at(), [1000, 500], 'a window opening stops it'); + assert.equal(ev('panHeld.size'), 0); + ev('closeModal();ACT.dash()'); key('ArrowLeft'); assert.equal(ev('panHeld.size'), 0, 'arrows scroll the NOC dashboard instead'); + ev("$('dash').hidden=true;ACT.rename()"); key('a', doc.getElementById('rnIn')); key('a'); assert.equal(ev('panHeld.size'), 0, 'not while typing or behind a window'); + ev('closeModal()'); key('ArrowLeft', null, { altKey: true }); key('ArrowLeft', null, { metaKey: true }); + assert.equal(ev('panHeld.size'), 0, 'Alt or Cmd with an arrow is the browser\'s'); + 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'"); @@ -79,9 +108,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', 'NOC dashboard', 'Connections', 'Leased lines', 'Esc', 'Show this list']) + for (const s of ['Keyboard shortcuts', 'Move around the map', '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', 'n', 'o', 'u', 'c', 't', 'r', 'l']) assert.ok([...doc.querySelectorAll('#modalCard .kbd')].some(e => e.textContent === k), k); + for (const k of ['←', '↑', '↓', '→', 'w', 'a', 's', 'd', '[', ']', '-', '=', '/', '?', '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'); From daec638bfc84c1ba973d8a2fc2a4598f6222602b Mon Sep 17 00:00:00 2001 From: Charlie Allom Date: Tue, 3 Nov 2026 10:39:00 +0000 Subject: [PATCH 2/4] MCP: classify popStep, zoomStep and keys, the keyboard shortcuts' actions, as views --- scripts/lib/mcp-commands.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/lib/mcp-commands.js b/scripts/lib/mcp-commands.js index e21df6e..a58a451 100644 --- a/scripts/lib/mcp-commands.js +++ b/scripts/lib/mcp-commands.js @@ -543,6 +543,9 @@ const API_VIEW={ linkCheck:{args:[['id','entityId']],doc:'Open the redundancy check for a link: what a single cut would drop, without changing anything.'}, findOpen:{args:[],doc:'Open the city finder (the 🔍 in the top bar).'}, findGo:{args:[['city','cityId']],doc:'Close the finder and jump to a city.'}, + popStep:{args:[['d','integer']],doc:'Select and centre the previous (d<0) or next (d>0) of your POPs, by name: the [ and ] keys.'}, + zoomStep:{args:[['d','integer']],doc:'Zoom the map out (d<0) or in (d>0) around its middle: the - and = keys.'}, + keys:{args:[],doc:'Open the list of keyboard shortcuts (the ? key).'}, routingOpen:{args:[],doc:'Open the Routing & DDoS window: backbone, Auto-TE and DDoS settings (the button at the top of the NOC tab).'}, opsOpen:{args:[],doc:'Open the Ops sheet: the NOC intern\'s mood, weekly shift report and standing orders.'}, opsCity:{args:[['v','cityId',false]],doc:'Show one POP\'s standing-order exceptions in the Ops sheet.'}, From 3192f42b5a9daedde3015bc908d38875d3d1b7ac Mon Sep 17 00:00:00 2001 From: Charlie Allom Date: Tue, 3 Nov 2026 10:47:51 +0000 Subject: [PATCH 3/4] $ steps through the open offers, soonest to expire first $ moves the map to the next offer's city, in the Deals list's order, opens the Customers tab on a POP and marks the offer under Offers here (UI.offerAt, the existing .row.on style). Two offers in one city each get a press; any other selection clears the mark. With nothing on the table it says so with the Deals tab's own "No open offers" text. --- CHANGELOG.md | 2 +- scripts/lib/mcp-commands.js | 1 + site/i18n/de.js | 1 + site/i18n/es.js | 1 + site/i18n/fr.js | 1 + site/i18n/it.js | 1 + site/i18n/pt.js | 1 + src/game/90-actions/10-interface.js | 4 ++++ src/game/90-actions/90-action-helpers.js | 2 +- src/game/93-ui/70-link-panels.js | 2 +- src/game/93-ui/82-keys.js | 10 +++++---- src/i18n/en.js | 1 + tests/keyboard-shortcuts.test.js | 26 ++++++++++++++++++++++-- 13 files changed, 44 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5c6874..c33ad11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ All notable changes to this project are documented here. The project follows - Three new cities in northern Australia: Port Hedland, Townsville and Alice Springs (#255). Port Hedland lands a new cable up the coast to Darwin and a branch of Darwin's cable out to Singapore; Alice Springs has no sea at all. In the wet season, November to April, fiber cuts in the tropical north, Darwin included, take twice as long to reach. - Traceroute no longer shows an "embedded cache in your rack" hop on paths that leave over transit, an exchange or a PNI. Only traffic that really ends at one of your cache boxes shows it now. -- New keyboard shortcuts: the arrow keys and W A S D move the map, [ and ] step through your POPs, - and = zoom 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. +- New keyboard shortcuts: the arrow keys and W A S D move the map, [ and ] step through your POPs, $ through the open offers, - and = zoom 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 diff --git a/scripts/lib/mcp-commands.js b/scripts/lib/mcp-commands.js index a58a451..ecf818e 100644 --- a/scripts/lib/mcp-commands.js +++ b/scripts/lib/mcp-commands.js @@ -544,6 +544,7 @@ const API_VIEW={ findOpen:{args:[],doc:'Open the city finder (the 🔍 in the top bar).'}, findGo:{args:[['city','cityId']],doc:'Close the finder and jump to a city.'}, popStep:{args:[['d','integer']],doc:'Select and centre the previous (d<0) or next (d>0) of your POPs, by name: the [ and ] keys.'}, + offerStep:{args:[],doc:'Select the next open offer (soonest to expire first), centre its city and mark it under Offers here: the $ key.'}, zoomStep:{args:[['d','integer']],doc:'Zoom the map out (d<0) or in (d>0) around its middle: the - and = keys.'}, keys:{args:[],doc:'Open the list of keyboard shortcuts (the ? key).'}, routingOpen:{args:[],doc:'Open the Routing & DDoS window: backbone, Auto-TE and DDoS settings (the button at the top of the NOC tab).'}, diff --git a/site/i18n/de.js b/site/i18n/de.js index 6a941ba..02ee679 100644 --- a/site/i18n/de.js +++ b/site/i18n/de.js @@ -2380,6 +2380,7 @@ "keys.game_speed":"Spielgeschwindigkeit: ½×, 1×, 2×, 4×, 8×", "keys.keyboard_shortcuts":"Tastenkürzel", "keys.move_around_the_map":"Karte verschieben", +"keys.next_open_offer_soonest_to":"Nächstes offenes Angebot, das bald ablaufende zuerst", "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", diff --git a/site/i18n/es.js b/site/i18n/es.js index 5936e6e..b57accb 100644 --- a/site/i18n/es.js +++ b/site/i18n/es.js @@ -2378,6 +2378,7 @@ "keys.game_speed":"Velocidad del juego: ½×, 1×, 2×, 4×, 8×", "keys.keyboard_shortcuts":"Atajos de teclado", "keys.move_around_the_map":"Mover el mapa", +"keys.next_open_offer_soonest_to":"Siguiente oferta abierta, primero la que caduca antes", "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", diff --git a/site/i18n/fr.js b/site/i18n/fr.js index f6ceb6f..450612a 100644 --- a/site/i18n/fr.js +++ b/site/i18n/fr.js @@ -2378,6 +2378,7 @@ "keys.game_speed":"Vitesse du jeu : ½×, 1×, 2×, 4×, 8×", "keys.keyboard_shortcuts":"Raccourcis clavier", "keys.move_around_the_map":"Déplacer la carte", +"keys.next_open_offer_soonest_to":"Offre ouverte suivante, celle qui expire le plus tôt d’abord", "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", diff --git a/site/i18n/it.js b/site/i18n/it.js index a2e7e8f..d7a1708 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -2378,6 +2378,7 @@ "keys.game_speed":"Velocità di gioco: ½×, 1×, 2×, 4×, 8×", "keys.keyboard_shortcuts":"Scorciatoie da tastiera", "keys.move_around_the_map":"Sposta la mappa", +"keys.next_open_offer_soonest_to":"Prossima offerta aperta, prima quella che scade prima", "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", diff --git a/site/i18n/pt.js b/site/i18n/pt.js index da20e40..1d77128 100644 --- a/site/i18n/pt.js +++ b/site/i18n/pt.js @@ -2378,6 +2378,7 @@ "keys.game_speed":"Velocidade do jogo: ½×, 1×, 2×, 4×, 8×", "keys.keyboard_shortcuts":"Atalhos de teclado", "keys.move_around_the_map":"Mover o mapa", +"keys.next_open_offer_soonest_to":"Próxima oferta aberta, primeiro a que vence antes", "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", diff --git a/src/game/90-actions/10-interface.js b/src/game/90-actions/10-interface.js index ef3e4fa..17e2953 100644 --- a/src/game/90-actions/10-interface.js +++ b/src/game/90-actions/10-interface.js @@ -49,6 +49,10 @@ const ACT={ findGo:({city})=>{if(!isCity(city))return;closeModal();$('dash').hidden=true;ACT.focusCity({city});}, focusCity:({city})=>{selectCity(city);const C=CITY[city];cam.x=C.x;cam.y=C.y;cam.z=Math.max(cam.z,1.2);if(innerWidth<760)UI.leftOpen=false;renderLeft();}, popStep:({d})=>{const L=popOrder(),n=L.length;if(!n)return;const i=UI.sel&&UI.sel.type==='city'?L.indexOf(UI.sel.id):-1;$('dash').hidden=true;ACT.focusCity({city:L[i<0?(d>0?0:n-1):(i+(d>0?1:n-1))%n]});}, + // The offer stays marked in its city's Offers here until something else is selected, so two offers in one city each get a press. + offerStep:()=>{const L=offerOrder(),n=L.length;if(!n){toast(tr('hud_and_panels.no_open_offers_right_now_businesses'));return;} + const i=L.findIndex(o=>o.id===UI.offerAt),o=L[(i+1)%n];$('dash').hidden=true;ACT.focusCity({city:o.city});UI.offerAt=o.id;if(S.pops[o.city])UI.tab='cust';renderPanel(); + const r=document.querySelector('#panelBody .row.on');if(r&&r.scrollIntoView)r.scrollIntoView({block:'nearest'});}, zoomStep:({d})=>zoomAt(CW/2,CH/2,d>0?1.25:0.8), keys:()=>showKeys(), selLink:({id})=>{selectLink(id);focusLink(id);}, diff --git a/src/game/90-actions/90-action-helpers.js b/src/game/90-actions/90-action-helpers.js index 7a76942..806665c 100644 --- a/src/game/90-actions/90-action-helpers.js +++ b/src/game/90-actions/90-action-helpers.js @@ -46,5 +46,5 @@ function focusLink(id){if(pzOn())return;const l=S.links.find(x=>x.id===id);if(!l // Phones leave a thin strip above the sheet: a fixed margin would eat most of it. const m=(a,b)=>Math.max(40,b-a-Math.min(100,(b-a)*0.3)),fw=m(fl,fr),fh=m(ft,fb),z=clamp(Math.min(fw/Math.max(1,x1-x0),fh/Math.max(1,y1-y0),Math.max(cam.z,1.2)),ZMIN,ZMAX); cam.z=z;cam.x=(x0+x1)/2-((fl+fr)/2-CW/2)/z;cam.y=(y0+y1)/2-((ft+fb)/2-CH/2)/z;wrapCam();} -function selectCity(c){UI.sel={type:'city',id:c};UI.confirm=null;if(isTablet()||isPhone())UI.leftOpen=false;const P=$('panel');if(P)P.classList.remove('full');if(!S.pops[c])UI.tab='cust';renderPanel();} +function selectCity(c){UI.sel={type:'city',id:c};UI.confirm=null;UI.offerAt=null;if(isTablet()||isPhone())UI.leftOpen=false;const P=$('panel');if(P)P.classList.remove('full');if(!S.pops[c])UI.tab='cust';renderPanel();} diff --git a/src/game/93-ui/70-link-panels.js b/src/game/93-ui/70-link-panels.js index c64aa1d..c531742 100644 --- a/src/game/93-ui/70-link-panels.js +++ b/src/game/93-ui/70-link-panels.js @@ -137,7 +137,7 @@ function dfPanel(l){ } function offersHere(c){ const os=S.offers.filter(o=>bCities(o).includes(c));if(!os.length)return ''; - return `

${tr('common.offers_here')}

${os.map(o=>`
${esc(o.name)}
${esc(BIZ_T[o.type].l)}${o.city2?` ${CITY[o.city].name} ⇄ ${CITY[o.city2].name}`:''} · ${bTerms(o)} · ${tr('ui.n_d_left',{n:o.exp-S.day})}
${spotWhy(o)}${R.reach<0.99&&!BIZ_T[o.type].l2?`
${tr('link_panels.they_need_the_full_internet_your',{pct:pct(R.reach)})}
`:''}${o.type==='scrub'&&!hasScrub()?`
${tr('link_panels.needs_your_own_scrubbing_center')}
`:''}${bRisk(o)}${reqList(o)}${bHas(o)?'':`
${tr('link_panels.needs_a_pop_in_cities_too',{cities:bCities(o).filter(x=>!S.pops[x]).map(x=>CITY[x].name).join(', ')})}
`}
${bHas(o)?btn(tr('common.accept'),'accept',{id:o.id},'green sm'):''}${btn(tr('common.no'),'decline',{id:o.id},'ghost sm')}
`).join('')}
`; + return `

${tr('common.offers_here')}

${os.map(o=>`
${esc(o.name)}
${esc(BIZ_T[o.type].l)}${o.city2?` ${CITY[o.city].name} ⇄ ${CITY[o.city2].name}`:''} · ${bTerms(o)} · ${tr('ui.n_d_left',{n:o.exp-S.day})}
${spotWhy(o)}${R.reach<0.99&&!BIZ_T[o.type].l2?`
${tr('link_panels.they_need_the_full_internet_your',{pct:pct(R.reach)})}
`:''}${o.type==='scrub'&&!hasScrub()?`
${tr('link_panels.needs_your_own_scrubbing_center')}
`:''}${bRisk(o)}${reqList(o)}${bHas(o)?'':`
${tr('link_panels.needs_a_pop_in_cities_too',{cities:bCities(o).filter(x=>!S.pops[x]).map(x=>CITY[x].name).join(', ')})}
`}
${bHas(o)?btn(tr('common.accept'),'accept',{id:o.id},'green sm'):''}${btn(tr('common.no'),'decline',{id:o.id},'ghost sm')}
`).join('')}
`; } function linkPanel(id){ const l=S.links.find(x=>x.id===id);if(!l){UI.sel=null;return '';} diff --git a/src/game/93-ui/82-keys.js b/src/game/93-ui/82-keys.js index 8bbde0c..323bbd5 100644 --- a/src/game/93-ui/82-keys.js +++ b/src/game/93-ui/82-keys.js @@ -1,7 +1,9 @@ -/* ---------- Keyboard shortcuts: arrows/WASD move, [ ] step through your POPs, - = zoom, n (then a letter) the NOC, ? lists every key ---------- +/* ---------- Keyboard shortcuts: arrows/WASD move, [ ] step through your POPs, $ through the offers, - = 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)):[]; +// Open offers in the Deals list's order, soonest to expire first, so $ walks the same list. +const offerOrder=()=>S&&S.offers?S.offers.filter(o=>isCity(o.city)).sort((a,b)=>a.exp-b.exp):[]; // 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; @@ -15,7 +17,7 @@ function panFrame(t){if(!panHeld.size||!$('modal').hidden||!$('dash').hidden){pa cam.x+=dx*PAN_SPEED*dt/cam.z;cam.y+=dy*PAN_SPEED*dt/cam.z;wrapCam();requestAnimationFrame(panFrame);} function showKeys(){const k=s=>`${s}`,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])=>`${k(l)} ${TN[t]}`).join(' '); - const rows=[[[...'←↑↓→'].map(k).join(' ')+'
'+[...'wasd'].map(k).join(' '),tr('keys.move_around_the_map')],[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')}
${tabs}`],[k(tr('keys.esc')),tr('keys.close_a_window_or_deselect')],[k('?'),tr('keys.show_this_list')]]; + const rows=[[[...'←↑↓→'].map(k).join(' ')+'
'+[...'wasd'].map(k).join(' '),tr('keys.move_around_the_map')],[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('$'),tr('keys.next_open_offer_soonest_to')],[k('-')+' '+k('='),tr('keys.zoom_the_map_out_or')],[k('n'),`${tr('keys.noc_dashboard_a_letter_right')}
${tabs}`],[k(tr('keys.esc')),tr('keys.close_a_window_or_deselect')],[k('?'),tr('keys.show_this_list')]]; openModal(`

⌨️ ${tr('keys.keyboard_shortcuts')}

${rows.map(([a,b])=>`
${a}
${b}
`).join('')}
${btn(UI.started?tr('common.back_to_the_map'):tr('common.got_it'),'helpClose',{},'big')}
`,'keys');} document.addEventListener('keydown',e=>{ @@ -28,7 +30,7 @@ document.addEventListener('keydown',e=>{ 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;} // Alt with an arrow is the browser's Back and Forward. if(!e.altKey&&PAN_KEYS[k]){if(!S||!UI.started||!$('modal').hidden||!$('dash').hidden)return;e.preventDefault();if(!panHeld.size){panAt=null;requestAnimationFrame(panFrame);}panHeld.add(k);return;} - if(!(step||zoom)||!S||!UI.started||!$('modal').hidden)return; - e.preventDefault();if(step)ACT.popStep({d:step});else ACT.zoomStep({d:zoom});}); + if(!(step||zoom||k==='$')||!S||!UI.started||!$('modal').hidden)return; + e.preventDefault();if(step)ACT.popStep({d:step});else if(zoom)ACT.zoomStep({d:zoom});else ACT.offerStep();}); document.addEventListener('keyup',e=>panHeld.delete(e.key.length===1?e.key.toLowerCase():e.key)); addEventListener('blur',()=>panHeld.clear()); diff --git a/src/i18n/en.js b/src/i18n/en.js index 8d691b0..aa08dd2 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -2379,6 +2379,7 @@ "keys.game_speed":"Game speed: ½×, 1×, 2×, 4×, 8×", "keys.keyboard_shortcuts":"Keyboard shortcuts", "keys.move_around_the_map":"Move around the map", +"keys.next_open_offer_soonest_to":"Next open offer, soonest to expire first", "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", diff --git a/tests/keyboard-shortcuts.test.js b/tests/keyboard-shortcuts.test.js index 0b78ce9..578db56 100644 --- a/tests/keyboard-shortcuts.test.js +++ b/tests/keyboard-shortcuts.test.js @@ -36,6 +36,28 @@ test('[ and ] step through your POPs in name order, wrap around, and move the ma assert.deepEqual(errors, []); }); +test('$ steps through the open offers, soonest to expire first, and marks each one in its city', () => { + const { ev, dom, errors } = load(); + const doc = dom.window.document, key = keyer(dom); + ev(start + ";S.offers=[];for(let i=0;i<60&&S.offers.length<3;i++)spawnOffer()"); + assert.equal(ev('S.offers.length'), 3); + // Two offers in Frankfurt (a POP) and one in Tokyo (no POP), expiring Tokyo first, then both in Frankfurt. + ev("(([a,b,c])=>{Object.assign(a,{city:'fra',city2:null,exp:S.day+30,name:'Alpha'});Object.assign(b,{city:'tok',city2:null,exp:S.day+10,name:'Bravo'});Object.assign(c,{city:'fra',city2:null,exp:S.day+20,name:'Charlie'});})(S.offers);UI.tab='up'"); + const sel = () => ev('UI.sel&&UI.sel.id'), marked = () => [...doc.querySelectorAll('#panelBody .row.on .nm')].map(e => e.textContent); + key('$'); assert.equal(sel(), 'tok'); assert.deepEqual(marked(), ['Bravo'], 'the soonest to expire first, marked in its city'); + assert.equal(ev('cam.x'), ev('CITY.tok.x'), 'with the map on it'); + key('$'); assert.equal(sel(), 'fra'); assert.equal(ev('UI.tab'), 'cust', 'a POP opens on Customers, where its offers are'); + assert.deepEqual(marked(), ['Charlie']); + key('$'); assert.equal(sel(), 'fra'); assert.deepEqual(marked(), ['Alpha'], 'a second offer in the same city gets its own press'); + key('$'); assert.deepEqual(marked(), ['Bravo'], 'and round again'); + ev("selectCity('ams')"); assert.equal(ev('UI.offerAt'), null, 'selecting something else clears the mark'); + key('$'); assert.deepEqual(marked(), ['Bravo'], 'so $ starts from the top'); + ev('ACT.decline({id:UI.offerAt})'); key('$'); assert.deepEqual(marked(), ['Charlie'], 'a declined offer drops out'); + ev('S.offers=[]'); key('$'); + assert.match(doc.getElementById('toasts').textContent, /No open offers right now/, 'no offers: it says so'); + assert.deepEqual(errors, []); +}); + test('- and = zoom the map out and in around its middle, within the zoom limits', () => { const { ev, dom, errors } = load(); const key = keyer(dom); @@ -108,9 +130,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', 'Move around the map', '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']) + for (const s of ['Keyboard shortcuts', 'Move around the map', 'Space', 'Pause or play', 'Find a city', 'Previous or next of your POPs', 'Next open offer, soonest to expire first', '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 ['←', '↑', '↓', '→', 'w', 'a', 's', 'd', '[', ']', '-', '=', '/', '?', '0', '4', 'n', 'o', 'u', 'c', 't', 'r', 'l']) assert.ok([...doc.querySelectorAll('#modalCard .kbd')].some(e => e.textContent === k), k); + for (const k of ['←', '↑', '↓', '→', 'w', 'a', 's', 'd', '[', ']', '$', '-', '=', '/', '?', '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'); From 41d5bc8b2118d3de49df59dc35a522eb12b17227 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Tue, 3 Nov 2026 12:47:12 +0100 Subject: [PATCH 4/4] Northern Australia, keyboard shortcuts, faster subsea cables (2.7.0) --- CHANGELOG.md | 6 ++++-- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb140d8..1be58e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,12 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] -- You can pay to hurry the survey, permits and factory of your own subsea cable, 30 days at a time (#258). Money only goes so far: the cable still has to be made, about two months plus a day for every 80 km, before the lay ships sail. +## [2.7.0] — 2026-11-03 + - Three new cities in northern Australia: Port Hedland, Townsville and Alice Springs (#255). Port Hedland lands a new cable up the coast to Darwin and a branch of Darwin's cable out to Singapore; Alice Springs has no sea at all. In the wet season, November to April, fiber cuts in the tropical north, Darwin included, take twice as long to reach. -- Traceroute no longer shows an "embedded cache in your rack" hop on paths that leave over transit, an exchange or a PNI. Only traffic that really ends at one of your cache boxes shows it now. - New keyboard shortcuts: the arrow keys and W A S D move the map, [ and ] step through your POPs, $ through the open offers, - and = zoom 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. +- You can pay to hurry the survey, permits and factory of your own subsea cable, 30 days at a time (#258). Money only goes so far: the cable still has to be made, about two months plus a day for every 80 km, before the lay ships sail. +- Traceroute no longer shows an "embedded cache in your rack" hop on paths that leave over transit, an exchange or a PNI. Only traffic that really ends at one of your cache boxes shows it now. ## [2.6.0] — 2026-11-03 diff --git a/package-lock.json b/package-lock.json index b5daef6..1696905 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "seriesoftubes", - "version": "2.6.0", + "version": "2.7.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "seriesoftubes", - "version": "2.6.0", + "version": "2.7.0", "license": "MIT", "devDependencies": { "jsdom": "24.1.3", diff --git a/package.json b/package.json index 44ea9c6..d59e08e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "seriesoftubes", - "version": "2.6.0", + "version": "2.7.0", "description": "A cartoon browser game about building the internet.", "private": true, "license": "MIT",