$ 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.
This commit is contained in:
parent
daec638bfc
commit
3192f42b5a
13 changed files with 44 additions and 9 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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).'},
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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);},
|
||||
|
|
|
|||
|
|
@ -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();}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 `<section><h3>${tr('common.offers_here')}</h3>${os.map(o=>`<div class="row"><div class="grow"><div class="nm">${esc(o.name)}</div><div class="meta">${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})}</div>${spotWhy(o)}${R.reach<0.99&&!BIZ_T[o.type].l2?`<div class="why">${tr('link_panels.they_need_the_full_internet_your',{pct:pct(R.reach)})}</div>`:''}${o.type==='scrub'&&!hasScrub()?`<div class="why">${tr('link_panels.needs_your_own_scrubbing_center')}</div>`:''}${bRisk(o)}${reqList(o)}${bHas(o)?'':`<div class="why">${tr('link_panels.needs_a_pop_in_cities_too',{cities:bCities(o).filter(x=>!S.pops[x]).map(x=>CITY[x].name).join(', ')})}</div>`}</div>${bHas(o)?btn(tr('common.accept'),'accept',{id:o.id},'green sm'):''}${btn(tr('common.no'),'decline',{id:o.id},'ghost sm')}</div>`).join('')}</section>`;
|
||||
return `<section><h3>${tr('common.offers_here')}</h3>${os.map(o=>`<div class="row${o.id===UI.offerAt?' on':''}"><div class="grow"><div class="nm">${esc(o.name)}</div><div class="meta">${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})}</div>${spotWhy(o)}${R.reach<0.99&&!BIZ_T[o.type].l2?`<div class="why">${tr('link_panels.they_need_the_full_internet_your',{pct:pct(R.reach)})}</div>`:''}${o.type==='scrub'&&!hasScrub()?`<div class="why">${tr('link_panels.needs_your_own_scrubbing_center')}</div>`:''}${bRisk(o)}${reqList(o)}${bHas(o)?'':`<div class="why">${tr('link_panels.needs_a_pop_in_cities_too',{cities:bCities(o).filter(x=>!S.pops[x]).map(x=>CITY[x].name).join(', ')})}</div>`}</div>${bHas(o)?btn(tr('common.accept'),'accept',{id:o.id},'green sm'):''}${btn(tr('common.no'),'decline',{id:o.id},'ghost sm')}</div>`).join('')}</section>`;
|
||||
}
|
||||
function linkPanel(id){
|
||||
const l=S.links.find(x=>x.id===id);if(!l){UI.sel=null;return '';}
|
||||
|
|
|
|||
|
|
@ -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=>`<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=[[[...'←↑↓→'].map(k).join(' ')+'<br>'+[...'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')}<br>${tabs}`],[k(tr('keys.esc')),tr('keys.close_a_window_or_deselect')],[k('?'),tr('keys.show_this_list')]];
|
||||
const rows=[[[...'←↑↓→'].map(k).join(' ')+'<br>'+[...'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')}<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=>{
|
||||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue