Fit the left tabs on small screens; move routing settings into a modal

The left panel's four tabs overflowed its 272px width on tablets and small
laptops: Goals wrapped its count, Networks ran off the edge. Counts now sit
on the tab's corner, labels stay on one line and shrink last.

Backbone, Auto-TE and DDoS settings sat below every notification in the NOC
tab. A Routing & DDoS button at the top opens them in a modal that redraws
in place after each action, with a red dot when Auto-TE is paused.
This commit is contained in:
Frederic Jung 2026-11-03 09:44:38 +01:00
parent 4a66bbf998
commit 3048c18b14
No known key found for this signature in database
19 changed files with 110 additions and 17 deletions

View file

@ -6,6 +6,7 @@ Object.assign(ACT,{
toast(tr('core.your_backbone_now_runs_lv',{lv:tr(CORE_LV[n])})+(out?' '+trn('core.n_pops_stay_outside',out):''),'good');sfx('build');after();},
coreLab:()=>{if(!coreOn()||S.core.lab||S.core.lv<1)return;if(!spend(CORE_LAB))return;
S.core.lab=true;toast(tr('core.interop_lab_open_vendors_now'),'good');sfx('coin');after();},
routingOpen:()=>{if(S&&!pzOn())routingModal();},
coreSet:({v})=>{if(!S.core)return;v=+v;if(!(v>=0&&v<=S.core.lv)||(v===S.core.run&&!S.core.legacy))return;S.core.run=v;delete S.core.legacy;sfx('click');after();},
via:({v})=>{UI.via=v;if(UI.pending)openLinkModal(UI.pending.a,UI.pending.b);},
setRoute:({id,m})=>{if(!own(RT,m))return;const b=S.biz.find(x=>x.id===id);if(b){b.route=m;sfx('click');after();}},

View file

@ -22,6 +22,6 @@ function morphKids(a,b){let x=a.firstChild,y=b.firstChild;
else if(x.nodeValue!==y.nodeValue)x.nodeValue=y.nodeValue;
x=x&&x.nextSibling;y=ny;}
while(x){const nx=x.nextSibling;a.removeChild(x);x=nx;}}
function renderAll(){if(isTablet()&&!UI.sel)UI.leftOpen=false;renderHUD();renderLeft();renderPanel();renderHint();renderMega();renderCoach();pzRender();}
function renderAll(){if(isTablet()&&!UI.sel)UI.leftOpen=false;renderHUD();renderLeft();renderPanel();renderHint();renderMega();renderCoach();pzRender();routingRefresh();}
function renderMega(){const el=$('mega');if(!el)return;const on=!!(S&&S.ev&&S.ev.php>S.day);if(el.hidden===!on)return;el.hidden=!on;}

View file

@ -31,7 +31,7 @@ function renderLeft(){checkLayer();
renderTabbar();
if(!S||pzOn()){L.hidden=true;return;}L.hidden=false;
const ndone=GOALS.filter(g=>S.done[g.id]!==undefined).length;
const tabs=[['goals',`${tr('common.goals')}<span class="cnt">${ndone}/${GOALS.length}</span>`],['deals',`${tr('common.deals')}${S.offers.length?`<span class="cnt">${S.offers.length}</span>`:''}`],['noc',`NOC${S.inc.length?`<span class="cnt red dot" aria-hidden="true"></span>`:''}`],['nets',tr('common.networks')]];
const tabs=[['goals',`<span class="tl">${tr('common.goals')}</span><span class="cnt">${ndone}/${GOALS.length}</span>`],['deals',`<span class="tl">${tr('common.deals')}</span>${S.offers.length?`<span class="cnt">${S.offers.length}</span>`:''}`],['noc',`<span class="tl">NOC</span>${S.inc.length?`<span class="cnt red dot" aria-hidden="true"></span>`:''}`],['nets',`<span class="tl">${tr('common.networks')}</span>`]];
$('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('common.close')}">×</button>`:'');
let h='';
if(UI.left==='goals'){
@ -48,17 +48,13 @@ function renderLeft(){checkLayer();
h+=`<div class="row"><div class="grow"><div class="nm">${esc(o.name)}</div><div class="meta">${esc(BIZ_T[o.type].l)} · ${CITY[o.city].name}${o.city2?' ⇄ '+CITY[o.city2].name:''} · <b>${bTerms(o)}</b> · ${tr('ui.n_d_left',{n:o.exp-S.day})}${(o.reqs||[]).length?` · ${trn('hud_and_panels.n_special_requirement',o.reqs.length)}`:''}</div>${spotWhy(o)}${bRisk(o)}${reqList(o)}
<div class="btns">${has?btn(tr('common.accept'),'accept',{id:o.id},'green sm'):btn(tr('common.go_there'),'focusCity',{city:bCities(o).find(c=>!S.pops[c])},'ghost sm')}${btn(tr('common.decline'),'decline',{id:o.id},'ghost sm')}</div>${has?'':`<div class="why">${tr('hud_and_panels.needs_a_pop_in_cities',{cities:bCities(o).filter(x=>!S.pops[x]).map(x=>CITY[x].name).join(', ')})}</div>`}</div></div>`;}
}else if(UI.left==='noc'){
h+=`<div class="btns" style="margin-bottom:8px">${btn(tr('hud_and_panels.open_noc_dashboard'),'dash',{},'pink')}${btn(tr('common.connections'),'connOpen',{},'')}${btn(tr('common.traceroute'),'trace',{},'')}</div>`;
h+=`<div class="btns" style="margin-bottom:8px">${btn(tr('hud_and_panels.open_noc_dashboard'),'dash',{},'pink')}${btn(tr('common.connections'),'connOpen',{},'')}${btn(tr('common.traceroute'),'trace',{},'')}${btn(`⚙️ ${tr('routing.routing_and_ddos')}${S.te&&!coreTE()?'<span class="cnt red dot" aria-hidden="true"></span>':''}`,'routingOpen',{},'')}</div>`;
h+=`<p class="lead">${tr('hud_and_panels.your_network_operations_center_every')}</p>`;
h+=opsCard()+mkCard()+ddosPanel();
// Incidents come first, the ones you can fix with one click at the top (#63): no scrolling past hot ports to replace an optic.
for(const i of S.inc.filter(i=>i.type!=='ddos').sort((a,b)=>(b.cost?1:0)-(a.cost?1:0)||(b.impact||0)-(a.impact||0))){h+=`<div class="inc"><div class="nm">${incTitle(i.type)}</div><div class="meta">${esc(i.msg)}</div><div class="meta">${shipSea(i)?'🚢 '+esc(shipStatus(i)):trn('hud_and_panels.auto_fix_in_n_day',i.until-S.day)}${i.impact?` · ${tr('hud_and_panels.g_lost',{g:fmtG(i.impact)})}`:''}</div>${i.cost?`<div class="btns">${btn(`${esc(i.fix||tr('common.rush_repair'))} ${fmt$(i.cost)}`,'fixInc',{id:i.id},'red sm',S.cash<i.cost)}</div>`:''}</div>`;}
h+=logSection();UI.logSeen=Date.now();
h+=ddosSettings();
if(S.grace&&S.grace.until>S.day&&R.graceNets)h+=`<div class="kv"><span>${tr('common.courtesy_route')}</span><b>${tr('hud_and_panels.n_networks_d_days_left',{n:R.graceNets,d:S.grace.until-S.day})}</b></div><p class="meta" style="margin:0 0 6px">${tr('hud_and_panels.reaches_networks_from_the_last')}</p>`;
h+=corePanel();
h+=S.te&&!coreTE()?`<div class="kv"><span>Auto-TE</span><b>${tr('core.paused')}</b></div><p class="why">${tr('core.auto_te_is_paused_it_needs')}</p>`:S.te?`<div class="kv"><span>Auto-TE</span><b>${S.te.on?tr('hud_and_panels.on_moving_g_onto_alternate_paths',{g:fmtG(R.teMoved||0)}):tr('common.off')}</b></div><div class="btns">${btn(S.te.on?tr('hud_and_panels.turn_auto_te_off'):tr('hud_and_panels.turn_auto_te_on'),'teToggle',{},'ghost sm')}${btn(S.te.script?tr('common.edit_routescript'):tr('hud_and_panels.write_a_routescript'),'teEdit',{},'pink sm')}</div>${S.te.script?`<p class="meta" style="margin:2px 0 6px">RouteScript: ${teRules()?tr('hud_and_panels.n_rules_live',{n:teRules().n}):S.te.on?tr('hud_and_panels.has_errors_not_running'):tr('common.controller_off')}${R.teBlack?` · ${tr('hud_and_panels.blackholing_g',{g:fmtG(R.teBlack)})}`:''}</p>`:''}`
:`<div class="kv"><span>Auto-TE</span><b>${lvl()<3?tr('hud_and_panels.unlocks_at_customer_level_3'):tr('common.not_installed')}</b></div><p class="meta" style="margin:2px 0 6px">${tr('hud_and_panels.traffic_takes_the_shortest_path_even')}</p>${coreTE()?'':`<p class="why">${tr('core.auto_te_needs_an_rsvp_te_or')}</p>`}<div class="btns">${btn(tr('hud_and_panels.install_auto_te_cost_mo_mo',{cost:fmt$(TE_COST),mo:fmt$(TE_MO)}),'buyTE',{},'pink sm',lvl()<3||S.cash<TE_COST||!coreTE())}</div>`;
const hot=S.links.filter(l=>!linkDown(l)&&capOf(l)>0&&(R.load[l.id]||0)/capOf(l)>=0.85).sort((a,b)=>(R.load[b.id]/capOf(b))-(R.load[a.id]/capOf(a)));
if(hot.length){h+=`<h3 style="font-size:15px;margin:4px 0">${tr('common.congested_links')}</h3>${S.te&&S.te.on?'':'<p class="meta" style="margin:0 0 4px">'+tr('hud_and_panels.raise_a_full_link_s_metric')+'</p>'}`+hot.map(l=>`<div class="row"><div class="grow"><div class="nm">${CITY[l.a].name} ⇄ ${CITY[l.b].name}</div><div class="meta">${capName(l)} · ${tr('hud_and_panels.p_full',{p:pct((R.load[l.id]||0)/capOf(l))})}</div></div>${btn(tr('common.inspect'),'selLink',{id:l.id},'pink sm')}</div>`).join('');}
h+=hwCard();

View file

@ -0,0 +1,16 @@
/* ---------- Routing & DDoS: one modal for the network-wide settings ----------
The backbone, Auto-TE and DDoS automation used to sit at the bottom of the NOC tab, below every incident and
the log, where nobody found them. A button at the top of the NOC tab opens them here. */
// Auto-TE: paused, installed or for sale.
function tePanel(){
return S.te&&!coreTE()?`<div class="kv"><span>Auto-TE</span><b>${tr('core.paused')}</b></div><p class="why">${tr('core.auto_te_is_paused_it_needs')}</p>`:S.te?`<div class="kv"><span>Auto-TE</span><b>${S.te.on?tr('hud_and_panels.on_moving_g_onto_alternate_paths',{g:fmtG(R.teMoved||0)}):tr('common.off')}</b></div><div class="btns">${btn(S.te.on?tr('hud_and_panels.turn_auto_te_off'):tr('hud_and_panels.turn_auto_te_on'),'teToggle',{},'ghost sm')}${btn(S.te.script?tr('common.edit_routescript'):tr('hud_and_panels.write_a_routescript'),'teEdit',{},'pink sm')}</div>${S.te.script?`<p class="meta" style="margin:2px 0 6px">RouteScript: ${teRules()?tr('hud_and_panels.n_rules_live',{n:teRules().n}):S.te.on?tr('hud_and_panels.has_errors_not_running'):tr('common.controller_off')}${R.teBlack?` · ${tr('hud_and_panels.blackholing_g',{g:fmtG(R.teBlack)})}`:''}</p>`:''}`
:`<div class="kv"><span>Auto-TE</span><b>${lvl()<3?tr('hud_and_panels.unlocks_at_customer_level_3'):tr('common.not_installed')}</b></div><p class="meta" style="margin:2px 0 6px">${tr('hud_and_panels.traffic_takes_the_shortest_path_even')}</p>${coreTE()?'':`<p class="why">${tr('core.auto_te_needs_an_rsvp_te_or')}</p>`}<div class="btns">${btn(tr('hud_and_panels.install_auto_te_cost_mo_mo',{cost:fmt$(TE_COST),mo:fmt$(TE_MO)}),'buyTE',{},'pink sm',lvl()<3||S.cash<TE_COST||!coreTE())}</div>`;}
// What the modal holds, without its title (scripts/lib/fuzz-page.js reads its buttons too).
function routingBody(){return corePanel()+`<h3 style="font-size:15px;margin:8px 0 4px">${tr('common.traffic_engineering')}</h3>${tePanel()}`
+`<h3 style="font-size:15px;margin:8px 0 4px">${tr('routing.ddos_defence')}</h3>${ddosSettings()}`;}
function routingModal(){if(!S)return;const card=$('modalCard'),open=!$('modal').hidden&&card.querySelector('[data-routing]'),st=open?card.scrollTop:0;
let h=`<div data-routing style="display:flex;align-items:center"><div><div class="eyebrow">NOC</div><h2 style="font-size:26px">${tr('routing.routing_and_ddos')}</h2></div><button class="x" data-act="closeModal" aria-label="${tr('common.close')}">×</button></div>
<p class="tagline">${tr('routing.how_traffic_crosses_your_backbone')}</p>`;
openModal(h+routingBody());if(open)card.scrollTop=st;}
// Actions taken in the modal re-render the game through after(); this keeps the open modal in step.
function routingRefresh(){if(S&&!$('modal').hidden&&$('modalCard').querySelector('[data-routing]'))routingModal();}

View file

@ -3523,6 +3523,9 @@
"routescript.write_rules_check_them_against_live":"Write rules, check them against live traffic, then deploy. A bad deploy is a very real way to break your network.",
"routescript.writing_a_script":"Writing a script",
"routescript.written_by_ai_prompt_make_my":"# ✨ Written by {ai}. Prompt: “make my network good”.",
"routing.ddos_defence":"DDoS defence",
"routing.how_traffic_crosses_your_backbone":"How traffic crosses your backbone, and what happens when a flood arrives.",
"routing.routing_and_ddos":"Routing & DDoS",
"routing_and_routers.maintenance_window_in_city":"Maintenance window in {city}",
"routing_and_routers.model_unlocks_at_customer_level_lv":"<b>{model} unlocks at customer level {lv}.</b>",
"routing_and_routers.new_router_in_city_swapped_before":"<b>New router in {city}</b><br>Swapped before anything was plugged in: zero downtime, zero angry customers.",

View file

@ -2,10 +2,15 @@
#left{position:fixed;top:calc(env(safe-area-inset-top,0px) + 76px);left:max(12px,env(safe-area-inset-left,0px));width:300px;max-height:calc(100% - 96px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));display:flex;flex-direction:column;z-index:4}
#panel{position:fixed;top:calc(env(safe-area-inset-top,0px) + 76px);right:max(12px,env(safe-area-inset-right,0px));width:370px;max-height:calc(100% - 96px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));display:flex;flex-direction:column;z-index:4}
.scroll{overflow:auto;padding:12px 14px 14px;overscroll-behavior:contain}
/* Labels stay on one line and give way (with an ellipsis) before the bar overflows the panel; the counts sit on
the tab's corner so they cost no width. */
.tabs{display:flex;gap:4px;padding:8px 8px 0;border-bottom:3px solid var(--ink);flex:none}
.tabs button{border:2.5px solid var(--ink);border-bottom:none;border-radius:11px 11px 0 0;background:var(--soft);padding:4px 10px 3px;font-family:var(--display);font-weight:800;cursor:pointer;font-size:13.5px;position:relative;top:3px}
.tabs button.on{background:var(--paper);padding-bottom:6px}
.tabs .cnt{display:inline-block;background:var(--me);color:#fff;border-radius:9px;padding:0 6px;font-size:11px;margin-left:4px}
#leftTabs{padding-top:11px}
.tabs button{border:2.5px solid var(--ink);border-bottom:none;border-radius:11px 11px 0 0;background:var(--soft);padding:4px 10px 3px;font-family:var(--display);font-weight:800;cursor:pointer;font-size:13.5px;position:relative;top:3px;flex:0 1 auto;min-width:0;display:flex;align-items:center}
.tabs .tl{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
.tabs button.on{background:var(--paper);padding-bottom:6px;flex-shrink:0}
.tabs .cnt{position:absolute;top:-10px;right:-6px;z-index:1;background:var(--me);color:#fff;border:1.5px solid var(--ink);border-radius:9px;padding:0 5px;font-size:10.5px;line-height:15px;white-space:nowrap}
.tabs .cnt.dot{top:-5px;right:-4px;width:11px;height:11px}
.tabs .cnt.red{background:var(--bad)}
#leftToggle{display:none}

View file

@ -2,6 +2,8 @@
bigger touch targets so the map keeps some room in the middle. */
@media (min-width:761px) and (max-width:1200px){
#left{width:272px}
#leftTabs{gap:3px;padding-left:6px;padding-right:6px}
#leftTabs button{padding-left:6px;padding-right:6px;font-size:12.5px}
#panel{width:336px}
#left.closed{display:none}
#leftToggle{display:flex;position:fixed;left:max(12px,env(safe-area-inset-left,0px));bottom:calc(env(safe-area-inset-bottom,0px) + 14px);z-index:4}