Goals gets a Tier 1 card once it is the current goal (or the title was lost): transit ports left, Tier 1 PNIs with the missing ones named, the club requirements they wait for, and reach without transit with the networks you would lose. The Networks tab gains an 'out of reach without transit' filter and a single-network view with every PNI city and exchange, your POPs first, then nearest. The NOC transit to-do list names the nearest city and links to the network. Routing counts reach without transit in the same pass. Places and distances are cached until the POP set changes, and exchange membership once per routing pass, so the Networks tab costs what it did.
This commit is contained in:
parent
c336e963a5
commit
9d6ad94035
6 changed files with 137 additions and 10 deletions
|
|
@ -6,6 +6,7 @@ All notable changes to this project are documented here. The project follows
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
- A new Road to Tier 1 card in Goals shows what still stands between you and Tier 1 (#111, #121, #12). It counts the transit ports left to cancel, names the Tier 1s you still need a PNI with and what they want from you first, and shows how much of the internet you would still reach without transit. The Networks tab can list just the networks you reach only through transit, biggest first, each with why it is not peering with you yet and where to meet it: the cities for a PNI and the exchanges it sits on, your POPs first, then the nearest. Who your transit carries, in the NOC, names the nearest city when a network is not in yours and takes you straight to it.
|
||||
- Your own subsea cables now come in three designs, from the budget route to one as fast as the fastest cable on the map, and two upgrades carry faster channels further (#65). Each design shows its latency, price and build time before you order: optimized costs three times as much and low latency seven times, and both take months longer. Premium terminals and optical engineering light longer routes at higher speeds, so a cable as long as New York to Sydney can now carry traffic, and the order screen tells you which upgrade a route needs. Calling off a cable while it is being laid refunds what you actually paid for it.
|
||||
- Only Spätzle-IX can now be won with peering alone (#114). The goal is now 45% reach and 300 Gbps served, and the scenario card shows your reach as well as your traffic.
|
||||
- Series of Tubes now speaks French. The game follows your browser's language the first time, and you can switch to Français under Settings or on the title screen.
|
||||
|
|
|
|||
|
|
@ -2600,4 +2600,17 @@
|
|||
"This design’s route is {km} km: too long for any optics, even with both upgrades. A shorter design can make it.":"Le tracé de cette conception fait {km} km : trop long pour toute optique, même avec les deux améliorations. Une conception plus courte peut y arriver.",
|
||||
"{km} km is too far for your optics on their own. Add {what} to light this cable.":"{km} km, c’est trop loin pour tes optiques seules. Ajoute {what} pour allumer ce câble.",
|
||||
"Estimated latency":"Latence estimée",
|
||||
"Out of reach without transit <small>{n}</small>":"Hors couverture sans transit <small>{n}</small>",
|
||||
"Nothing: every network is reachable without transit.":"Aucun : chaque réseau est joignable sans transit.",
|
||||
"Open peer, but not on any IX where you have a POP. Nearest: {city}":"Peer ouvert, mais sur aucun IX où tu as un POP. Le plus proche : {city}",
|
||||
"Not in your cities yet. Nearest: {city}":"Pas encore dans tes villes. La plus proche : {city}",
|
||||
"Where to meet them":"Où les trouver",
|
||||
"Goal":"Objectif",
|
||||
"Road to Tier 1":"En route vers le Tier 1",
|
||||
"Transit ports to cancel":"Ports de transit à résilier",
|
||||
"PNIs with every Tier 1":"PNI avec chaque Tier 1",
|
||||
"Tier 1s only take a PNI from a network with {list}.":"Les Tier 1 n’acceptent un PNI que d’un réseau avec {list}.",
|
||||
"Reach without transit":"Couverture sans transit",
|
||||
"All {n} out of reach":"Les {n} hors couverture",
|
||||
"Where?":"Où ?",
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2600,4 +2600,17 @@
|
|||
"This design’s route is {km} km: too long for any optics, even with both upgrades. A shorter design can make it.":"Il percorso di questo progetto è di {km} km: troppo lungo per qualsiasi ottica, anche con entrambi i miglioramenti. Un progetto più corto ce la fa.",
|
||||
"{km} km is too far for your optics on their own. Add {what} to light this cable.":"{km} km sono troppi per le tue ottiche da sole. Aggiungi {what} per accendere questo cavo.",
|
||||
"Reach 45% of the internet and serve 300 Gbps":"Raggiungi il 45% di internet e servi 300 Gbps",
|
||||
"Out of reach without transit <small>{n}</small>":"Fuori copertura senza transit <small>{n}</small>",
|
||||
"Nothing: every network is reachable without transit.":"Nessuna: ogni rete è raggiungibile senza transit.",
|
||||
"Open peer, but not on any IX where you have a POP. Nearest: {city}":"Peer aperto, ma non su nessun IX dove hai un POP. Il più vicino: {city}",
|
||||
"Not in your cities yet. Nearest: {city}":"Non ancora nelle tue città. La più vicina: {city}",
|
||||
"Where to meet them":"Dove trovarli",
|
||||
"Goal":"Obiettivo",
|
||||
"Road to Tier 1":"Verso il Tier 1",
|
||||
"Transit ports to cancel":"Porte transit da disdire",
|
||||
"PNIs with every Tier 1":"PNI con ogni Tier 1",
|
||||
"Tier 1s only take a PNI from a network with {list}.":"I Tier 1 accettano un PNI solo da una rete con {list}.",
|
||||
"Reach without transit":"Copertura senza transit",
|
||||
"All {n} out of reach":"Tutte le {n} fuori copertura",
|
||||
"Where?":"Dove?",
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2600,4 +2600,17 @@
|
|||
"{km} km is too far for your optics on their own. Add {what} to light this cable.":"{km} km é longe demais para as suas ópticas sozinhas. Adicione {what} para acender este cabo.",
|
||||
"Estimated latency":"Latência estimada",
|
||||
"Reach 45% of the internet and serve 300 Gbps":"Alcance 45% da internet e atenda 300 Gbps",
|
||||
"Out of reach without transit <small>{n}</small>":"Fora de alcance sem transit <small>{n}</small>",
|
||||
"Nothing: every network is reachable without transit.":"Nenhuma: toda rede é alcançável sem transit.",
|
||||
"Open peer, but not on any IX where you have a POP. Nearest: {city}":"Peer aberto, mas em nenhum IX onde você tem POP. O mais próximo: {city}",
|
||||
"Not in your cities yet. Nearest: {city}":"Ainda não está nas suas cidades. A mais próxima: {city}",
|
||||
"Where to meet them":"Onde encontrá-los",
|
||||
"Goal":"Meta",
|
||||
"Road to Tier 1":"Rumo ao Tier 1",
|
||||
"Transit ports to cancel":"Portas de transit a cancelar",
|
||||
"PNIs with every Tier 1":"PNIs com cada Tier 1",
|
||||
"Tier 1s only take a PNI from a network with {list}.":"Os Tier 1 só aceitam PNI de uma rede com {list}.",
|
||||
"Reach without transit":"Alcance sem transit",
|
||||
"All {n} out of reach":"Todas as {n} fora de alcance",
|
||||
"Where?":"Onde?",
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1423,7 +1423,7 @@ const GOALS=[
|
|||
let S=null, R=emptyR();
|
||||
const UI={sel:null,tab:'cust',left:'goals',speed:1,hover:null,drag:null,snap:null,pending:null,confirm:null,leftOpen:false,muted:false,startCity:'fra',hintOff:false};
|
||||
let uidN=1; const uid=()=>'i'+(Date.now()%1e7).toString(36)+(uidN++);
|
||||
function emptyR(){return {teBlack:0,tNet:{},egT:{},netEg:{},l2lat:{},nodeLoad:{},nodeCap:{},div:{},l2:{},gfwLost:0,gfwCross:0,ef:{},egDesc:{},p95:{},peered:0,peerShare:0,load:{},useT:{},useIx:{},usePni:{},useCache:{},cityDem:{},citySrv:{},cityEye:{},demTo:{},served:0,demand:0,reach:0,sessions:0,revMo:0,costMo:0,cost:{},rev:{},reachable:{}};}
|
||||
function emptyR(){return {nt:{},reachNT:0,teBlack:0,tNet:{},egT:{},netEg:{},l2lat:{},nodeLoad:{},nodeCap:{},div:{},l2:{},gfwLost:0,gfwCross:0,ef:{},egDesc:{},p95:{},peered:0,peerShare:0,load:{},useT:{},useIx:{},usePni:{},useCache:{},cityDem:{},citySrv:{},cityEye:{},demTo:{},served:0,demand:0,reach:0,sessions:0,revMo:0,costMo:0,cost:{},rev:{},reachable:{}};}
|
||||
/* ================= BANKS & LOANS =================
|
||||
Lenders make offers now and then (more often when you are broke). Each loan
|
||||
is a fixed monthly payment that shows up in your costs; conditions are checked
|
||||
|
|
@ -1950,7 +1950,7 @@ function compute(){
|
|||
const ekN={};for(const e of E){e.ek=e.k+':'+e.id;ekN[e.ek]=(ekN[e.ek]||0)+1;}
|
||||
// dup: shares its key with another exit (a hand-edited save), so R.egDesc shows whichever pushed last.
|
||||
for(const e of E){e.desc={lab:e.lab,city:e.city,k:e.k};e.dup=ekN[e.ek]>1;e.told=false;e.hp=e.pref==='high'?0:1;e.ci=CIDX[e.city];e.cn=cnCity(e.city);e.vis=0;for(const n of e.nets||NET_IDS){const L=okBy[n];if(L&&L[L.length-1]!==e&&e.ok(n))L.push(e);}}
|
||||
for(const n of NETS){R2.reachable[n.id]=okBy[n.id].some(e=>e.rank>0);if(R2.reachable[n.id])R2.reach+=NSH[n.id];}
|
||||
for(const n of NETS){R2.reachable[n.id]=okBy[n.id].some(e=>e.rank>0);if(R2.reachable[n.id])R2.reach+=NSH[n.id];if(okBy[n.id].some(e=>e.rank>0&&e.k!=='t')){R2.nt[n.id]=1;R2.reachNT+=NSH[n.id];}}
|
||||
const cacheNets=new Set(S.caches.filter(c=>popUp(c.city)).map(c=>c.net));
|
||||
const viral=(ev.viral>day?1.25:1)*(ev.php&&ev.php>day?0.7:1);
|
||||
// Every flow has the same shape and carries what routing asks about it again and again (nj: its network's index).
|
||||
|
|
@ -2893,6 +2893,9 @@ const ACT={
|
|||
closeModal:()=>closeModal(),
|
||||
tab:({t})=>{UI.tab=t;UI.confirm=null;renderPanel();},
|
||||
leftTab:({t})=>{UI.left=t;UI.leftOpen=true;renderLeft();},
|
||||
netFocus:({id})=>{if(!NET[id])return;$('dash').hidden=true;UI.netFocus=id;UI.nf='all';UI.left='nets';UI.leftOpen=true;UI.sel=null;renderPanel();renderLeft();const b=$('leftBody');if(b)b.scrollTop=0;},
|
||||
netFilter:({f})=>{UI.nf=f==='out'?'out':'all';UI.netFocus=null;$('dash').hidden=true;UI.left='nets';UI.leftOpen=true;UI.sel=null;renderPanel();renderLeft();const b=$('leftBody');if(b)b.scrollTop=0;},
|
||||
meetGo:({city})=>{if(!isCity(city))return;$('dash').hidden=true;ACT.focusCity({city});if(S.pops[city]){UI.tab='peer';renderPanel();}},
|
||||
toggleLeft:()=>{UI.leftOpen=!UI.leftOpen;renderLeft();},
|
||||
phoneTab:({t})=>{if(!['goals','deals','noc','nets'].includes(t))return;haptic(8);if(UI.leftOpen&&UI.left===t&&!UI.sel){UI.leftOpen=false;}else{UI.left=t;UI.leftOpen=true;UI.sel=null;renderPanel();}$('left').classList.remove('full');renderLeft();},
|
||||
phonePlay:()=>{haptic(10);if(UI.speed){UI.lastSpeed=UI.speed;UI.speed=0;}else UI.speed=UI.lastSpeed||1;renderHUD();},
|
||||
|
|
@ -3286,7 +3289,7 @@ function renderLeft(){checkLayer();
|
|||
$('leftTabs').innerHTML=tabs.map(([k,l])=>`<button class="${UI.left===k?'on':''}" data-act="leftTab" data-args='{"t":"${k}"}'>${l}</button>`).join('')+(innerWidth<760?`<button data-act="toggleLeft" style="margin-left:auto" aria-label="${tr('Close')}">×</button>`:'');
|
||||
let h='';
|
||||
if(UI.left==='goals'){
|
||||
h+=scnCard()+lvlCard();
|
||||
h+=scnCard()+lvlCard()+t1Card();
|
||||
const cur=GOALS.find(g=>S.done[g.id]===undefined);
|
||||
h+=GOALS.map(g=>{const d=S.done[g.id]!==undefined,c=g===cur;return `<div class="goal ${d?'done':''} ${c?'cur':''}"><div class="ck">${d?'✓':''}</div><div><div class="gt">${esc(g.t)}</div>${c||!d?`<div class="gd">${esc(g.d)}</div>`:''}${!d&&g.r?`<div class="gr">${tr('Reward {cash}',{cash:fmt$(g.r)})}</div>`:''}</div></div>`;}).join('');
|
||||
h+=badgeGrid();
|
||||
|
|
@ -3322,9 +3325,12 @@ function renderLeft(){checkLayer();
|
|||
h+=`<p class="lead">${tr("Every network on the map. Traffic share is how much of your users' traffic goes to them. Tap a connection to jump to its POP.")}</p>`;
|
||||
{const nc=conns().length;if(nc)h+=`<div class="btns" style="margin-bottom:8px">${btn(tr('All connections <small>{n}</small>',{n:nc}),'connOpen',{},'pink sm')}</div>`;}
|
||||
const where=netWhereIdx(),tl=NETS.filter(n=>n.tail),tlOn=tl.filter(n=>where(n.id).some(x=>x[2]==='ix')).length;
|
||||
for(const n of NETS){if(n.tail&&!UI.tailOpen)continue;
|
||||
h+=`<div class="row">${logo(n)}<div class="grow"><div class="nm">${esc(n.name)} <span class="meta">AS${n.asn}</span></div><div class="meta"><span class="tag ${n.type}">${TYPE_L[n.type]}</span> <span class="tag ${n.pol}">${n.pol}</span> · ${tr('{p}% of traffic',{p:(NSH[n.id]*100).toFixed(1)})}${n.price?` · ${tr('transit ${price}/Gbps',{price:(n.price*S.priceMul).toFixed(2)})}`:''}</div><div class="meta">${esc(n.blurb)}</div>${netWhere(n,where)}</div></div>`;}
|
||||
h+=`<div class="row"><div class="grow"><div class="nm">${tr('The long tail')} <span class="meta">${tr('{n} small networks',{n:tl.length})}</span></div><div class="meta">${tr('{p}% of traffic between them, scattered across exchanges. You peer with {n}.',{p:(tl.reduce((a,n)=>a+NSH[n.id],0)*100).toFixed(1),n:tlOn})}</div></div>${btn(UI.tailOpen?tr('Hide'):tr('Show'),'tailTog',{},'ghost sm')}</div>`;
|
||||
const foc=UI.netFocus&&NET[UI.netFocus]?NET[UI.netFocus]:null,out=!foc&&UI.nf==='out',lostN=ntLost().length;
|
||||
h+=`<div class="btns" style="margin-bottom:8px">${btn(tr('All networks'),'netFilter',{f:'all'},!foc&&!out?'sm':'ghost sm')}${btn(tr('Out of reach without transit <small>{n}</small>',{n:lostN}),'netFilter',{f:'out'},out?'sm':'ghost sm')}</div>`;
|
||||
if(out&&!lostN)h+=`<p class="empty">${tr('Nothing: every network is reachable without transit.')}</p>`;
|
||||
for(const n of foc?[foc]:out?ntLost():NETS){if(n.tail&&!UI.tailOpen&&!foc&&!out)continue;
|
||||
h+=`<div class="row">${logo(n)}<div class="grow"><div class="nm">${esc(n.name)} <span class="meta">AS${n.asn}</span></div><div class="meta"><span class="tag ${n.type}">${TYPE_L[n.type]}</span> <span class="tag ${n.pol}">${n.pol}</span> · ${tr('{p}% of traffic',{p:(NSH[n.id]*100).toFixed(1)})}${n.price?` · ${tr('transit ${price}/Gbps',{price:(n.price*S.priceMul).toFixed(2)})}`:''}</div><div class="meta">${esc(n.blurb)}</div>${netWhere(n,where)}${(foc||out)&&!R.nt[n.id]?`<p class="why">${esc(offTransitHint(n.id))}</p>`:''}${foc||out&&!R.nt[n.id]?meetLine(n,foc?24:4):''}</div></div>`;}
|
||||
if(!foc&&!out)h+=`<div class="row"><div class="grow"><div class="nm">${tr('The long tail')} <span class="meta">${tr('{n} small networks',{n:tl.length})}</span></div><div class="meta">${tr('{p}% of traffic between them, scattered across exchanges. You peer with {n}.',{p:(tl.reduce((a,n)=>a+NSH[n.id],0)*100).toFixed(1),n:tlOn})}</div></div>${btn(UI.tailOpen?tr('Hide'):tr('Show'),'tailTog',{},'ghost sm')}</div>`;
|
||||
}
|
||||
if(h!==UI._lh){UI._lh=h;morph($('leftBody'),h);}
|
||||
}
|
||||
|
|
@ -3591,15 +3597,17 @@ function svgChart(rows,stackKeys,lines,fmtY){
|
|||
g+=`<text x="${L}" y="${H-5}" font-size="10" fill="#55608A" font-weight="700">${dateStr(rows[0].d)}</text><text x="${W-Rr}" y="${H-5}" text-anchor="end" font-size="10" fill="#55608A" font-weight="700">${dateStr(rows[rows.length-1].d)}</text>`;
|
||||
return `<svg class="chart" viewBox="0 0 ${W} ${H}" role="img">${g}</svg>`;}
|
||||
// For a network you currently reach over transit: the cheapest way to move it to peering.
|
||||
// Exchange members as sets, rebuilt once per routing pass: hints are asked for many networks at a time.
|
||||
let IXMR=null,IXMC={};const ixHas=(x,id)=>{if(IXMR!==R){IXMR=R;IXMC={};}return (IXMC[x]||(IXMC[x]=new Set(ixMembers(x)))).has(id);};
|
||||
function offTransitHint(id,city){const n=NET[id];if(n.type==='t1')return tr('Tier 1: only a PNI, and only once you are big enough for the Tier 1 club');
|
||||
const ixc=Object.keys(S.pops).flatMap(ixIdsIn).filter(x=>ixMembers(x).includes(id)),here=city&&ixIdsIn(city).find(x=>ixMembers(x).includes(id))||null,pick1=here||ixc.find(x=>S.ixp[x]!==undefined)||ixc[0];
|
||||
if(n.pol==='open')return pick1?(here?tr('Open peer: join the route server at {ix}',{ix:ixName(pick1)}):tr('Open peer: join the route server at {ix} ({city})',{ix:ixName(pick1),city:CITY[ixCity(pick1)].name})):tr('Open peer, but not on any IX where you have a POP');
|
||||
const ixc=Object.keys(S.pops).flatMap(ixIdsIn).filter(x=>ixHas(x,id)),here=city&&ixIdsIn(city).find(x=>ixHas(x,id))||null,pick1=here||ixc.find(x=>S.ixp[x]!==undefined)||ixc[0];
|
||||
if(n.pol==='open'){if(pick1)return here?tr('Open peer: join the route server at {ix}',{ix:ixName(pick1)}):tr('Open peer: join the route server at {ix} ({city})',{ix:ixName(pick1),city:CITY[ixCity(pick1)].name});const x=nearestSpot(id);return x?tr('Open peer, but not on any IX where you have a POP. Nearest: {city}',{city:CITY[x.c].name}):tr('Open peer, but not on any IX where you have a POP');}
|
||||
if(n.pol==='paid')return paidFree(n)?tr('Peers with you for free over a PNI. You got too big to charge.'):n.freeLv?tr('Paid peering only: a PNI costs {price}/mo. Free from customer level {n}.',{price:fmt$(n.paidFee),n:n.freeLv}):tr('Paid peering only: a PNI costs {price}/mo',{price:fmt$(n.paidFee)});
|
||||
const pniC=Object.keys(S.pops).filter(c=>n.pops.includes(c));const ixOk=pick1?peerOk(id,'ix',pick1):null,pOk=pniC.length?peerOk(id,'pni',pniC.includes(city)?city:pniC[0]):null;
|
||||
if(pOk&&pOk.ok)return tr('Ready for a PNI in {city}',{city:CITY[pniC.includes(city)?city:pniC[0]].name});
|
||||
if(ixOk&&ixOk.ok)return tr('Will peer at {ix}: request a session',{ix:ixName(pick1)});
|
||||
if(ixOk)return `${ixName(pick1)}: ${ixOk.why}`;
|
||||
return pniC.length?tr('PNI in {city}: {why}',{city:CITY[pniC[0]].name,why:pOk.why}):tr('Not present in any of your cities yet');}
|
||||
if(pniC.length)return tr('PNI in {city}: {why}',{city:CITY[pniC[0]].name,why:pOk.why});{const x=nearestSpot(id);return x?tr('Not in your cities yet. Nearest: {city}',{city:CITY[x.c].name}):tr('Not present in any of your cities yet');}}
|
||||
function transitTop(ids,k=5){const m={};for(const id of ids)for(const [n,v] of Object.entries(R.tNet[id]||{}))m[n]=(m[n]||0)+v;return Object.entries(m).filter(([,v])=>v>0.01).sort((a,b)=>b[1]-a[1]).slice(0,k);}
|
||||
/* ---------- scenario and level progress (#34) ---------- */
|
||||
const pSrv=g=>({l:tr('Traffic served'),v:R.served,max:g,txt:`${fmtG(R.served)} / ${fmtG(g)}`});
|
||||
|
|
@ -3627,6 +3635,37 @@ function lvlItems(){const lv=S.lvl||1,pk=S.stats.peak||0,pops=Object.keys(S.pops
|
|||
const t1Note=()=>S.won&&!isTier1()?`<p class="why">${tr('Not Tier 1 right now: {why}.',{why:esc(t1Why())})}</p>`:'';
|
||||
function lvlCard(){const lv=S.lvl||1,nx=LEVELS[lv];
|
||||
return `<div class="pcard lv"><div class="eyebrow">${tr('Customer level {lv} of {max}',{lv,max:LEVELS.length})}</div><div class="pt">${esc(LEVELS[lv-1].n)}</div><div class="meta"><i>${esc(LEVELS[lv-1].q)}</i></div>${t1Note()}${nx?`<div class="meta">${tr('Next: {name} unlocks {what}',{name:esc(nx.n),what:esc(lc1(nx.unlock))})}</div>${lvlItems().map(pRow).join('')}`:`<div class="meta">${tr('Every customer type is unlocked. Go get those terabits.')}</div>`}</div>`;}
|
||||
/* ---------- where to meet a network (#12, #111, #121) ---------- */
|
||||
// Static: the cities where a network takes PNIs and the exchanges it sits on. Built once, on first use.
|
||||
let PLACES=null;
|
||||
function netPlaces(id){if(!PLACES){PLACES={};for(const n of NETS)PLACES[n.id]={p:n.pops.filter(c=>CITY[c]),x:[]};
|
||||
for(const c of CITIES)if(c.ix)for(const n of NETS)if(n.ix==='ALL'||(Array.isArray(n.ix)&&n.ix.includes(c.id)))PLACES[n.id].x.push(c.id);
|
||||
for(const X of XIX)for(const m of X.members)if(PLACES[m])PLACES[m].x.push(X.id);}return PLACES[id];}
|
||||
// km from each city to your nearest POP, cached until the set of POPs changes.
|
||||
let NEARK='',NEARM=null;
|
||||
function popNear(){const ps=Object.keys(S.pops),k=ps.join();if(k!==NEARK||!NEARM){NEARK=k;NEARM={};for(const c of CITIES)NEARM[c.id]=ps.length?Math.min(...ps.map(q=>q===c.id?0:kmBetween(q,c.id))):0;}return NEARM;}
|
||||
// One entry per city: can you PNI there, which of its exchanges have them. Your POPs first, then nearest.
|
||||
let SPOTK='',SPOTM={};
|
||||
function meetSpots(id){const near=popNear();if(SPOTK!==NEARK){SPOTK=NEARK;SPOTM={};}if(SPOTM[id])return SPOTM[id];const P=netPlaces(id),m={};if(!P)return [];
|
||||
for(const c of P.p)(m[c]||(m[c]={c,pni:false,ix:[]})).pni=true;
|
||||
for(const x of P.x){const c=ixCity(x);if(CITY[c])(m[c]||(m[c]={c,pni:false,ix:[]})).ix.push(x);}
|
||||
return SPOTM[id]=Object.values(m).sort((a,b)=>(!!S.pops[b.c]-!!S.pops[a.c])||(near[a.c]-near[b.c])||(a.c<b.c?-1:1));}
|
||||
function meetLine(n,max){const sp=meetSpots(n.id);if(!sp.length)return '';
|
||||
const lab=x=>[x.pni?'PNI':'',...x.ix.map(ixName)].filter(Boolean).join(' · ');
|
||||
return `<div class="meta" style="margin-top:4px"><b>${tr('Where to meet them')}</b></div><div class="btns">${sp.slice(0,max).map(x=>btn(`${esc(CITY[x.c].name)} <small>${esc(lab(x))}</small>`,'meetGo',{city:x.c},S.pops[x.c]?'sm':'ghost sm')).join('')}${sp.length>max?btn(tr('+{n} more',{n:sp.length-max}),'netFocus',{id:n.id},'ghost sm'):''}</div>`;}
|
||||
// The nearest place to meet a network you have no POP for, for one-line hints.
|
||||
function nearestSpot(id){const x=meetSpots(id)[0];return x&&!S.pops[x.c]?x:null;}
|
||||
// Networks you reach only through transit, biggest first: what stands between you and Tier 1.
|
||||
const ntLost=()=>NETS.filter(n=>!R.nt[n.id]).sort((a,b)=>NSH[b.id]-NSH[a.id]);
|
||||
function t1Card(){const cur=GOALS.find(g=>S.done[g.id]===undefined);if(!((cur&&cur.id==='t1')||S.won)||isTier1())return '';
|
||||
const need=t1Need(),miss=need.filter(n=>!S.pni.some(p=>p.net===n.id)),club=t1Club(),lost=ntLost(),nb=n=>btn(esc(n.name),'netFocus',{id:n.id},'ghost sm');
|
||||
let h=`<div class="pcard"><div class="eyebrow">${tr('Goal')} · ${tr('Go transit-free: Tier 1!')}</div><div class="pt">${tr('Road to Tier 1')}</div>`;
|
||||
h+=pRow({l:tr('Transit ports to cancel'),v:S.transit.length?0:1,max:1,txt:S.transit.length?String(S.transit.length):'✓'});
|
||||
h+=pRow({l:tr('PNIs with every Tier 1'),v:need.length-miss.length,max:need.length,txt:`${need.length-miss.length} / ${need.length}`});
|
||||
if(miss.length)h+=`<div class="btns">${miss.map(nb).join('')}</div>`+(club.ok?'':`<p class="why">${tr('Tier 1s only take a PNI from a network with {list}.',{list:club.missing.join(', ')})}</p>`);
|
||||
h+=pRow({l:tr('Reach without transit'),v:Math.min(R.reachNT,0.999),max:0.999,txt:`${reachPct(R.reachNT)} / 99.9%`});
|
||||
if(lost.length)h+=`<div class="btns">${lost.slice(0,3).map(nb).join('')}${btn(trn('All {n} out of reach','All {n} out of reach',lost.length),'netFilter',{f:'out'},'pink sm')}</div>`;
|
||||
return h+'</div>';}
|
||||
/* ---------- customers overview (#13, #14, #15) ---------- */
|
||||
const bizMo=b=>{const T=BIZ_T[b.type];return T.event?0:T.fiber?b.rate:b.bw*b.rate;};
|
||||
// Why a customer is unhappy, in the same terms the daily mood update uses.
|
||||
|
|
@ -3784,7 +3823,7 @@ function renderDash(){checkLayer();
|
|||
if(DT==='conn')h+=connSection();
|
||||
if(DT==='traffic')h+=`<div class="panel2" style="margin-top:12px"><h3>${tr('Traffic by network (ASN)')}</h3><p class="note" style="margin-top:0">${tr("Where your users' traffic comes from, and how it gets to you. Transit is the only part you pay per gigabit; caches, PNIs and IX peering are free or flat-rate. Tap a column to sort.")}</p><div class="legend" style="margin:0 0 6px">${['c','p','ix','t'].map(k=>`<span><i style="background:${EGC[k][1]}"></i>${EGC[k][0]}</span>`).join('')}</div><div class="tscroll"><table class="tbl"><thead><tr>${[['name',tr('Network'),''],['asn','AS',''],['type',tr('Type'),''],['traffic',tr('Traffic'),'r'],['mix',tr('How it arrives'),''],['cost',tr('Transit cost'),'r'],['lost',tr('Lost'),'r']].map(([k,l,c])=>`<th class="${c}">${k==='mix'?l:`<button class="thb" data-act="dashSort" data-args="${esc(JSON.stringify({k}))}">${l}${UI.dashSort===k?(UI.dashDir>0?' ▲':' ▼'):''}</button>`}</th>`).join('')}</tr></thead><tbody>
|
||||
${nets.map(({n,e,t,want})=>{return `<tr><td><span style="display:inline-flex;align-items:center;gap:6px">${logo(n)}<b>${esc(n.name)}</b></span></td><td>${n.asn}</td><td><span class="tag ${n.type}">${TYPE_L[n.type]}</span></td><td class="r">${fmtG(t)}</td><td><div class="mix" title="${['c','p','ix','t'].filter(k=>e[k]>0.01).map(k=>EGC[k][0]+' '+fmtG(e[k])).join(' · ')||tr('nothing yet')}">${['c','p','ix','t'].map(k=>`<i style="width:${t?e[k]/t*100:0}%;background:${EGC[k][1]}"></i>`).join('')}</div></td><td class="r">${e.t>0.01?tr('{price}/mo',{price:fmt$((R.cost.transit||0)*e.t/tT)}):'—'}</td><td class="r" style="color:${want-t>want*0.05?'var(--bad)':'inherit'}">${want>0.01?pct(Math.max(0,1-t/want)):'—'}</td></tr>`;}).join('')}</tbody></table></div></div>`;
|
||||
if(DT==='traffic'){const top=transitTop(S.transit.map(t=>t.id),8);if(top.length)h+=`<div class="panel2" style="margin-top:12px"><h3>${tr('Who your transit carries')}</h3><p class="note" style="margin-top:0">${tr('The networks you pay transit to reach, biggest first, and the cheapest way to move each one to peering. This is your to-do list on the way to Tier 1.')}</p>${top.map(([id,v])=>`<div class="row">${logo(NET[id])}<div class="grow"><div class="nm">${esc(NET[id].name)} <span class="meta">AS${NET[id].asn} · ${fmtG(v)} · ${tr('about {price}/mo',{price:fmt$((R.cost.transit||0)*v/tT)})}</span></div><div class="meta">${esc(offTransitHint(id))}</div></div></div>`).join('')}</div>`;}
|
||||
if(DT==='traffic'){const top=transitTop(S.transit.map(t=>t.id),8);if(top.length)h+=`<div class="panel2" style="margin-top:12px"><h3>${tr('Who your transit carries')}</h3><p class="note" style="margin-top:0">${tr('The networks you pay transit to reach, biggest first, and the cheapest way to move each one to peering. This is your to-do list on the way to Tier 1.')}</p>${top.map(([id,v])=>`<div class="row">${logo(NET[id])}<div class="grow"><div class="nm">${esc(NET[id].name)} <span class="meta">AS${NET[id].asn} · ${fmtG(v)} · ${tr('about {price}/mo',{price:fmt$((R.cost.transit||0)*v/tT)})}</span></div><div class="meta">${esc(offTransitHint(id))}</div></div>${btn(tr('Where?'),'netFocus',{id},'ghost sm')}</div>`).join('')}</div>`;}
|
||||
const ls=S.links.filter(l=>capOf(l)>0).map(l=>({l,u:(R.load[l.id]||0)/capOf(l)})).sort((a,b)=>b.u-a.u).slice(0,8);
|
||||
const rs=Object.keys(S.pops).map(c=>({c,u:(R.nodeLoad[c]||0)/(R.nodeCap[c]||1)})).sort((a,b)=>b.u-a.u).slice(0,6);
|
||||
if(DT==='infra')h+=`<div class="dcols" style="margin-top:12px"><div class="panel2"><h3>${tr('Busiest links')}</h3>${ls.length?ls.map(({l,u})=>`<div class="row"><div class="grow"><div class="nm">${CITY[l.a].name} ⇄ ${CITY[l.b].name} <span class="meta">${capName(l)} · ${linkLat(l).toFixed(1)} ms</span></div><div class="bar ${barCls(u)}"><i style="width:${Math.min(100,u*100)}%"></i></div></div><b class="num" style="min-width:42px;text-align:right">${pct(u)}</b>${btn(tr('Open'),'dashLink',{id:l.id},'ghost sm')}</div>`).join(''):'<p class="empty">'+tr('No links yet.')+'</p>'}</div>
|
||||
|
|
|
|||
|
|
@ -1158,3 +1158,51 @@ test('#110 PNI buttons show the monthly port fee, not just the one-off setup', (
|
|||
assert.match(ev("connUp(conns().find(r=>r.k==='p'&&r.id==='p1')).replace(/<[^>]+>/g,'')"), /Upgrade 100G \$2\.3k \+ \$350\/mo/);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('#111 #121 #12 the road to Tier 1: what is missing, and where to meet each network', () => {
|
||||
const { ev, errors, dom } = load();
|
||||
ev("ACT.start({});S.cash=1e9;S.lvl=6;for(const g of GOALS)if(g.id!=='t1')S.done[g.id]=0");
|
||||
ev("for(const c of ['fra','ams','nyc']){ACT.buildPop({city:c});S.pops[c].rgen=3;}ACT.buyTransit({city:'fra',net:'cog',tier:2});for(const x of ixIdsIn('ams'))ACT.buyIx({city:x,tier:2,signed:true});compute();ACT.peerAll({city:'ams'});compute()");
|
||||
const body = () => dom.window.document.getElementById('leftBody').textContent;
|
||||
// transit hides how much you would lose without it
|
||||
assert.ok(ev('R.reach') > 0.99 && ev('R.reachNT') < ev('R.reach'), 'reach without transit is counted separately');
|
||||
assert.equal(ev("NETS.filter(n=>R.nt[n.id]).reduce((a,n)=>a+NSH[n.id],0).toFixed(6)"), ev('R.reachNT.toFixed(6)'));
|
||||
// #111: the goal card lists the missing Tier 1 PNIs and the networks out of reach
|
||||
ev("UI.left='goals';UI.leftOpen=true;UI.sel=null;renderLeft()");
|
||||
assert.match(body(), /Road to Tier 1/);
|
||||
assert.match(body(), new RegExp(`PNIs with every Tier 1\\s*0 / ${ev('t1Need().length')}`));
|
||||
assert.match(body(), /Transit ports to cancel\s*1/);
|
||||
assert.match(body(), new RegExp(ev('t1Need()[0].name')));
|
||||
assert.match(body(), /Tier 1s only take a PNI from a network with/);
|
||||
assert.match(body(), /out of reach/);
|
||||
// the filter lists exactly the networks you reach only through transit, biggest first
|
||||
ev("ACT.netFilter({f:'out'})");
|
||||
const shown = JSON.parse(ev("JSON.stringify(ntLost().map(n=>n.id))"));
|
||||
assert.ok(shown.length > 0 && shown.length === ev("NETS.filter(n=>!R.nt[n.id]).length"));
|
||||
const reached = ev("NETS.find(n=>R.nt[n.id]&&!n.tail).name");
|
||||
assert.ok(!body().includes(reached + ' AS'), 'networks you already reach are not on the list');
|
||||
assert.ok(ev("ntLost().every((n,i,a)=>!i||NSH[a[i-1].id]>=NSH[n.id])"));
|
||||
// #12, #121: every place to meet a network, your POPs first, then the nearest
|
||||
const far = ev("NETS.find(n=>!n.tail&&n.ix!=='ALL'&&n.pops.length&&n.pops.every(c=>!S.pops[c])).id");
|
||||
const spots = JSON.parse(ev(`JSON.stringify(meetSpots('${far}').map(x=>x.c))`));
|
||||
assert.ok(spots.length >= 1);
|
||||
const near = JSON.parse(ev("JSON.stringify(popNear())"));
|
||||
assert.ok(spots.every((c, i) => !i || near[spots[i - 1]] <= near[c]), 'nearest first');
|
||||
assert.ok(ev(`NET['${far}'].pops.every(c=>meetSpots('${far}').some(x=>x.c===c&&x.pni))`), 'every PNI city is listed');
|
||||
assert.match(ev(`offTransitHint('${far}')`), new RegExp('Nearest: ' + ev(`CITY['${spots[0]}'].name`)));
|
||||
ev(`ACT.netFocus({id:'${far}'})`);
|
||||
assert.match(body(), /Where to meet them/);
|
||||
assert.match(body(), new RegExp(ev(`CITY['${spots[0]}'].name`)));
|
||||
ev(`ACT.meetGo({city:'${spots[0]}'})`);
|
||||
assert.equal(ev('UI.sel&&UI.sel.id'), spots[0]);
|
||||
// the NOC to-do list has a way to the network's entry
|
||||
ev("for(const c of Object.keys(S.pops))ACT.launchBB({city:c});for(let i=0;i<3;i++)dayTick();$('dash').hidden=false;UI.dtab='traffic';renderDash()");
|
||||
assert.match(dom.window.document.getElementById('dash').innerHTML, /data-act="netFocus"/);
|
||||
// Tier 1 reached: the card goes away
|
||||
ev("S.transit=[];for(const n of t1Need())S.pni.push({id:'t'+n.id,net:n.id,city:n.pops[0],tier:0});compute();R.reach=1;R.reachNT=1;for(const n of NETS)R.reachable[n.id]=R.nt[n.id]=1;UI.left='goals';renderLeft()");
|
||||
assert.equal(ev('isTier1()'), true);
|
||||
assert.doesNotMatch(body(), /Road to Tier 1/);
|
||||
// phones: the same views in the bottom sheet
|
||||
dom.window.innerWidth = 360; ev("ACT.netFilter({f:'out'});renderAll&&renderAll()");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue