diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fc7080..0530511 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] +- Backbone, Auto-TE and DDoS settings now open from a Routing & DDoS button at the top of the NOC tab. They used to sit at the very bottom, below every notification; a red dot on the button says when Auto-TE is paused. +- The tabs above the left panel no longer run off its edge on smaller screens and tablets. Counts such as finished goals now sit on the corner of their tab. - Networks you reach through an exchange's route server now stay "via RS" (#265). With an Open peering policy, the peering desk used to turn some of them into separate sessions of their own. - The intern's "Light more fiber" order has a new Optics setting: light new fiber with the biggest optic it can afford, to save channels for later (#262). Once a fiber is lit, the intern still adds more of the same optic and never swaps what is in there. - Gaming customers no longer warn that they attract attacks in modes without DDoS attacks, such as Change Freeze. diff --git a/scripts/lib/fuzz-page.js b/scripts/lib/fuzz-page.js index c495355..4586d55 100644 --- a/scripts/lib/fuzz-page.js +++ b/scripts/lib/fuzz-page.js @@ -58,7 +58,14 @@ if (w.where === 'city') { UI.sel = { type: 'city', id: w.city }; UI.tab = w.tab; renderAll(); return btns($('panel')); } if (w.where === 'link') { if (!S.links.some((l) => l.id === w.id)) return []; UI.sel = { type: 'link', id: w.id }; renderAll(); return btns($('panel')); } if (w.where === 'dash') { $('dash').hidden = false; UI.dtab = w.tab; renderDash(); const b = btns($('dash')); return b; } - if (w.where === 'left') { UI.left = w.tab; UI.leftOpen = true; renderLeft(); return btns($('leftBody')); } + if (w.where === 'left') { + UI.left = w.tab; UI.leftOpen = true; renderLeft(); let b = btns($('leftBody')); + if (w.tab !== 'noc') return b; + // The backbone, Auto-TE and DDoS settings moved from the NOC tab into the Routing & DDoS modal: offer them here on + // both pages, in one order, so main's page (settings in the tab) and this one (behind the button) stay in lockstep. + if (typeof routingBody === 'function' && b.some((x) => x.act === 'routingOpen')) { const d = document.createElement('div'); d.innerHTML = routingBody(); b = b.filter((x) => x.act !== 'routingOpen').concat(btns(d)); } + return b.sort((x, y) => (sig(x) < sig(y) ? -1 : sig(x) > sig(y) ? 1 : 0)); + } if (w.where === 'openLink') { if (!S.pops[w.a]) return []; openLinkModal(w.a, w.b); return modalOpen() ? btns($('modal')) : []; } return []; }; diff --git a/site/i18n/de.js b/site/i18n/de.js index c40d05b..b0830a1 100644 --- a/site/i18n/de.js +++ b/site/i18n/de.js @@ -3524,6 +3524,9 @@ "routescript.write_rules_check_them_against_live":"Schreib Regeln, prüfe sie gegen den Live-Traffic, dann deploye sie. Ein schlechtes Deployment ist ein sehr realer Weg, dein Netz kaputt zu machen.", "routescript.writing_a_script":"Ein Skript schreiben", "routescript.written_by_ai_prompt_make_my":"# ✨ Geschrieben von {ai}. Prompt: „mach mein Netz gut“.", +"routing.ddos_defence":"DDoS-Abwehr", +"routing.how_traffic_crosses_your_backbone":"Wie Traffic über deinen Backbone läuft und was passiert, wenn eine Flut kommt.", +"routing.routing_and_ddos":"Routing & DDoS", "routing_and_routers.maintenance_window_in_city":"Wartungsfenster in {city}", "routing_and_routers.model_unlocks_at_customer_level_lv":"{model} wird ab Kundenlevel {lv} freigeschaltet.", "routing_and_routers.new_router_in_city_swapped_before":"Neuer Router in {city}
Getauscht, bevor irgendwas eingesteckt war: null Ausfallzeit, null wütende Kunden.", diff --git a/site/i18n/es.js b/site/i18n/es.js index ffd4c71..45a48e2 100644 --- a/site/i18n/es.js +++ b/site/i18n/es.js @@ -3522,6 +3522,9 @@ "routescript.write_rules_check_them_against_live":"Escribe reglas, compruébalas con el tráfico en vivo y luego despliega. Un mal despliegue es una forma muy real de romper tu red.", "routescript.writing_a_script":"Escribir un script", "routescript.written_by_ai_prompt_make_my":"# ✨ Escrito por {ai}. Prompt: «haz que mi red sea buena».", +"routing.ddos_defence":"Defensa DDoS", +"routing.how_traffic_crosses_your_backbone":"Cómo cruza el tráfico tu backbone y qué pasa cuando llega una inundación.", +"routing.routing_and_ddos":"Routing y DDoS", "routing_and_routers.maintenance_window_in_city":"Ventana de mantenimiento en {city}", "routing_and_routers.model_unlocks_at_customer_level_lv":"{model} se desbloquea en el nivel de cliente {lv}.", "routing_and_routers.new_router_in_city_swapped_before":"Router nuevo en {city}
Cambiado antes de conectar nada: cero inactividad, cero clientes enfadados.", diff --git a/site/i18n/fr.js b/site/i18n/fr.js index fc7c8eb..51cc12c 100644 --- a/site/i18n/fr.js +++ b/site/i18n/fr.js @@ -3522,6 +3522,9 @@ "routescript.write_rules_check_them_against_live":"Écris des règles, vérifie-les sur le trafic réel, puis déploie. Un mauvais déploiement est un moyen très concret de casser ton réseau.", "routescript.writing_a_script":"Écrire un script", "routescript.written_by_ai_prompt_make_my":"# ✨ Écrit par {ai}. Prompt : « rends mon réseau bien ».", +"routing.ddos_defence":"Défense DDoS", +"routing.how_traffic_crosses_your_backbone":"Comment le trafic traverse ton backbone, et ce qui se passe quand une attaque déferle.", +"routing.routing_and_ddos":"Routage et DDoS", "routing_and_routers.maintenance_window_in_city":"Fenêtre de maintenance à {city}", "routing_and_routers.model_unlocks_at_customer_level_lv":"Le {model} se débloque au niveau client {lv}.", "routing_and_routers.new_router_in_city_swapped_before":"Nouveau routeur à {city}
Remplacé avant que quoi que ce soit ne soit branché : zéro interruption, zéro client fâché.", diff --git a/site/i18n/it.js b/site/i18n/it.js index c8c3c98..e01b0e5 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -3522,6 +3522,9 @@ "routescript.write_rules_check_them_against_live":"Scrivi le regole, verificale sul traffico reale, poi fai il deploy. Un deploy sbagliato è un modo molto concreto per rompere la tua rete.", "routescript.writing_a_script":"Scrivere uno script", "routescript.written_by_ai_prompt_make_my":"# ✨ Scritto da {ai}. Prompt: “rendi buona la mia rete”.", +"routing.ddos_defence":"Difesa DDoS", +"routing.how_traffic_crosses_your_backbone":"Come il traffico attraversa il tuo backbone e cosa succede quando arriva un attacco.", +"routing.routing_and_ddos":"Routing e DDoS", "routing_and_routers.maintenance_window_in_city":"Finestra di manutenzione a {city}", "routing_and_routers.model_unlocks_at_customer_level_lv":"{model} si sblocca al livello clienti {lv}.", "routing_and_routers.new_router_in_city_swapped_before":"Nuovo router a {city}
Sostituito prima che ci fosse collegato qualcosa: zero downtime, zero clienti arrabbiati.", diff --git a/site/i18n/pt.js b/site/i18n/pt.js index 6c984f1..d05bfb2 100644 --- a/site/i18n/pt.js +++ b/site/i18n/pt.js @@ -3522,6 +3522,9 @@ "routescript.write_rules_check_them_against_live":"Escreva regras, teste no tráfego real e faça o deploy. Um deploy ruim é um jeito bem real de quebrar sua rede.", "routescript.writing_a_script":"Escrevendo um script", "routescript.written_by_ai_prompt_make_my":"# ✨ Escrito por {ai}. Prompt: “deixa minha rede boa”.", +"routing.ddos_defence":"Defesa DDoS", +"routing.how_traffic_crosses_your_backbone":"Como o tráfego cruza seu backbone e o que acontece quando chega uma enxurrada.", +"routing.routing_and_ddos":"Roteamento e DDoS", "routing_and_routers.maintenance_window_in_city":"Janela de manutenção em {city}", "routing_and_routers.model_unlocks_at_customer_level_lv":"{model} desbloqueia no nível de cliente {lv}.", "routing_and_routers.new_router_in_city_swapped_before":"Roteador novo em {city}
Trocado antes de qualquer coisa estar conectada: zero downtime, zero clientes bravos.", diff --git a/src/game/90-actions/85-routing-and-routers.js b/src/game/90-actions/85-routing-and-routers.js index 995c150..6a6822f 100644 --- a/src/game/90-actions/85-routing-and-routers.js +++ b/src/game/90-actions/85-routing-and-routers.js @@ -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();}}, diff --git a/src/game/93-ui/10-dom.js b/src/game/93-ui/10-dom.js index 43ecc9e..ffb1f61 100644 --- a/src/game/93-ui/10-dom.js +++ b/src/game/93-ui/10-dom.js @@ -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;} diff --git a/src/game/93-ui/40-hud-and-panels.js b/src/game/93-ui/40-hud-and-panels.js index 3dc6ffc..953dfa2 100644 --- a/src/game/93-ui/40-hud-and-panels.js +++ b/src/game/93-ui/40-hud-and-panels.js @@ -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')}${ndone}/${GOALS.length}`],['deals',`${tr('common.deals')}${S.offers.length?`${S.offers.length}`:''}`],['noc',`NOC${S.inc.length?``:''}`],['nets',tr('common.networks')]]; + const tabs=[['goals',`${tr('common.goals')}${ndone}/${GOALS.length}`],['deals',`${tr('common.deals')}${S.offers.length?`${S.offers.length}`:''}`],['noc',`NOC${S.inc.length?``:''}`],['nets',`${tr('common.networks')}`]]; $('leftTabs').innerHTML=tabs.map(([k,l])=>``).join('')+(innerWidth<760?``:''); let h=''; if(UI.left==='goals'){ @@ -48,17 +48,13 @@ function renderLeft(){checkLayer(); h+=`
${esc(o.name)}
${esc(BIZ_T[o.type].l)} · ${CITY[o.city].name}${o.city2?' ⇄ '+CITY[o.city2].name:''} · ${bTerms(o)} · ${tr('ui.n_d_left',{n:o.exp-S.day})}${(o.reqs||[]).length?` · ${trn('hud_and_panels.n_special_requirement',o.reqs.length)}`:''}
${spotWhy(o)}${bRisk(o)}${reqList(o)}
${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')}
${has?'':`
${tr('hud_and_panels.needs_a_pop_in_cities',{cities:bCities(o).filter(x=>!S.pops[x]).map(x=>CITY[x].name).join(', ')})}
`}
`;} }else if(UI.left==='noc'){ - h+=`
${btn(tr('hud_and_panels.open_noc_dashboard'),'dash',{},'pink')}${btn(tr('common.connections'),'connOpen',{},'')}${btn(tr('common.traceroute'),'trace',{},'')}
`; + h+=`
${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()?'':''}`,'routingOpen',{},'')}
`; h+=`

${tr('hud_and_panels.your_network_operations_center_every')}

`; 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+=`
${incTitle(i.type)}
${esc(i.msg)}
${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)})}`:''}
${i.cost?`
${btn(`${esc(i.fix||tr('common.rush_repair'))} ${fmt$(i.cost)}`,'fixInc',{id:i.id},'red sm',S.cash`:''}
`;} h+=logSection();UI.logSeen=Date.now(); - h+=ddosSettings(); if(S.grace&&S.grace.until>S.day&&R.graceNets)h+=`
${tr('common.courtesy_route')}${tr('hud_and_panels.n_networks_d_days_left',{n:R.graceNets,d:S.grace.until-S.day})}

${tr('hud_and_panels.reaches_networks_from_the_last')}

`; - h+=corePanel(); - h+=S.te&&!coreTE()?`
Auto-TE${tr('core.paused')}

${tr('core.auto_te_is_paused_it_needs')}

`:S.te?`
Auto-TE${S.te.on?tr('hud_and_panels.on_moving_g_onto_alternate_paths',{g:fmtG(R.teMoved||0)}):tr('common.off')}
${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')}
${S.te.script?`

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)})}`:''}

`:''}` - :`
Auto-TE${lvl()<3?tr('hud_and_panels.unlocks_at_customer_level_3'):tr('common.not_installed')}

${tr('hud_and_panels.traffic_takes_the_shortest_path_even')}

${coreTE()?'':`

${tr('core.auto_te_needs_an_rsvp_te_or')}

`}
${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`; 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+=`

${tr('common.congested_links')}

${S.te&&S.te.on?'':'

'+tr('hud_and_panels.raise_a_full_link_s_metric')+'

'}`+hot.map(l=>`
${CITY[l.a].name} ⇄ ${CITY[l.b].name}
${capName(l)} · ${tr('hud_and_panels.p_full',{p:pct((R.load[l.id]||0)/capOf(l))})}
${btn(tr('common.inspect'),'selLink',{id:l.id},'pink sm')}
`).join('');} h+=hwCard(); diff --git a/src/game/93-ui/46-routing-modal.js b/src/game/93-ui/46-routing-modal.js new file mode 100644 index 0000000..5d2aae1 --- /dev/null +++ b/src/game/93-ui/46-routing-modal.js @@ -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()?`
Auto-TE${tr('core.paused')}

${tr('core.auto_te_is_paused_it_needs')}

`:S.te?`
Auto-TE${S.te.on?tr('hud_and_panels.on_moving_g_onto_alternate_paths',{g:fmtG(R.teMoved||0)}):tr('common.off')}
${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')}
${S.te.script?`

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)})}`:''}

`:''}` + :`
Auto-TE${lvl()<3?tr('hud_and_panels.unlocks_at_customer_level_3'):tr('common.not_installed')}

${tr('hud_and_panels.traffic_takes_the_shortest_path_even')}

${coreTE()?'':`

${tr('core.auto_te_needs_an_rsvp_te_or')}

`}
${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`;} +// What the modal holds, without its title (scripts/lib/fuzz-page.js reads its buttons too). +function routingBody(){return corePanel()+`

${tr('common.traffic_engineering')}

${tePanel()}` + +`

${tr('routing.ddos_defence')}

${ddosSettings()}`;} +function routingModal(){if(!S)return;const card=$('modalCard'),open=!$('modal').hidden&&card.querySelector('[data-routing]'),st=open?card.scrollTop:0; + let h=`
NOC

${tr('routing.routing_and_ddos')}

+

${tr('routing.how_traffic_crosses_your_backbone')}

`; + 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();} diff --git a/src/i18n/en.js b/src/i18n/en.js index 4f400fc..4f4386e 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -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":"{model} unlocks at customer level {lv}.", "routing_and_routers.new_router_in_city_swapped_before":"New router in {city}
Swapped before anything was plugged in: zero downtime, zero angry customers.", diff --git a/src/styles/20-drawers.css b/src/styles/20-drawers.css index 5f510ec..31fc819 100644 --- a/src/styles/20-drawers.css +++ b/src/styles/20-drawers.css @@ -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} diff --git a/src/styles/50-tablet.css b/src/styles/50-tablet.css index 80a7ac2..9efb1c2 100644 --- a/src/styles/50-tablet.css +++ b/src/styles/50-tablet.css @@ -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} diff --git a/tests/backbone-core.test.js b/tests/backbone-core.test.js index e8a9074..5e7bba9 100644 --- a/tests/backbone-core.test.js +++ b/tests/backbone-core.test.js @@ -160,7 +160,7 @@ test('the backbone panel and the router panels, on a phone too', () => { for (const w of [1280, 360]) { const { ev, dom, errors } = load(); ev("ACT.start({});if(UI.pendGame)ACT.pitchSkip()"); - ev(`window.innerWidth=${w};` + start.replace('ACT.start({});', '') + `;ACT.buildPop({city:'ams'});S.pops.fra.rgen=${g('Disco 8K')};ACT.coreUp();ACT.coreUp();ACT.leftTab({t:'noc'});renderAll()`); + ev(`window.innerWidth=${w};` + start.replace('ACT.start({});', '') + `;ACT.buildPop({city:'ams'});S.pops.fra.rgen=${g('Disco 8K')};ACT.coreUp();ACT.coreUp();ACT.leftTab({t:'noc'});ACT.routingOpen();renderAll()`); const txt = dom.window.document.body.textContent; assert.match(txt, /RSVP-TE\/MPLS/, `${w}px`); assert.match(txt, /outside the backbone/, 'Amsterdam is left out'); diff --git a/tests/ddos-model.test.js b/tests/ddos-model.test.js index 72e318b..774692b 100644 --- a/tests/ddos-model.test.js +++ b/tests/ddos-model.test.js @@ -170,12 +170,12 @@ test('saves before 2.2 load: an attack on a city finds its target, and an IX bla test('the NOC card fits a phone and the sandbox can send a test flood', () => { const { ev, errors, dom } = load(); - ev("beginGame('T','fra',{mode:'sandbox',preset:'sandbox'});if(UI.pendGame)ACT.pitchSkip();ACT.launchBB({city:'fra'});ACT.buyTransit({city:'fra',net:'cog',tier:1});UI.left='noc';renderLeft()"); - const b = dom.window.document.querySelector('[data-act=ddosTest]'); + ev("beginGame('T','fra',{mode:'sandbox',preset:'sandbox'});if(UI.pendGame)ACT.pitchSkip();ACT.launchBB({city:'fra'});ACT.buyTransit({city:'fra',net:'cog',tier:1});UI.left='noc';renderLeft();ACT.routingOpen()"); + const b = dom.window.document.querySelector('#modal [data-act=ddosTest]'); assert.ok(b, 'a test flood button in Sandbox'); b.click(); assert.equal(ev('ddosAll().length'), 1); - ev("UI.left='noc';renderLeft()"); + ev("closeModal();UI.left='noc';renderLeft()"); const card = dom.window.document.querySelector('#left .inc.ddos'); assert.ok(card, 'the card is shown'); assert.ok(card.querySelectorAll('.btns').length <= 2, 'one suggestion, the rest behind More'); diff --git a/tests/game.test.js b/tests/game.test.js index bb70119..c182655 100644 --- a/tests/game.test.js +++ b/tests/game.test.js @@ -290,7 +290,8 @@ test('notifications: the NOC keeps the last ten minutes, folds repeats and opens ev("UI.left='noc';UI.leftOpen=true;UI.sel=null;renderLeft();renderHUD()"); const body = doc.getElementById('leftBody').textContent; assert.match(body, /Notifications\s*last 10 minutes/); - assert.ok(body.indexOf('Notifications') < body.indexOf('DDoS scrubbing'), 'near the top, not at the bottom'); + assert.ok(body.indexOf('Notifications') < body.indexOf('Incidents so far'), 'near the top, not at the bottom'); + assert.doesNotMatch(body, /DDoS scrubbing/, 'the settings moved to Routing & DDoS'); assert.match(body, /×5/); assert.match(body, /just now/); assert.equal(doc.querySelectorAll('#leftBody [data-act=logOpen]').length, 2, 'Open only where it leads somewhere (2 of the 5 shown)'); assert.equal(ev("logUnread()"), 0); diff --git a/tests/issues.test.js b/tests/issues.test.js index f8e8de9..39057ba 100644 --- a/tests/issues.test.js +++ b/tests/issues.test.js @@ -992,7 +992,7 @@ test('#63 incidents you can fix with one click sit above hot ports in the NOC', assert.ok(fix >= 0 && hot >= 0 && free >= 0, 'all three are shown'); assert.ok(fix < hot, 'the paid fix comes before the hot ports'); assert.ok(fix < free, 'and before incidents without a fix'); - assert.ok(t.indexOf('DDoS scrubbing') > fix, 'status lines come after the incidents'); + assert.ok(t.indexOf('Incidents so far') > fix, 'status lines come after the incidents'); assert.deepEqual(errors, []); }); diff --git a/tests/routing-modal.test.js b/tests/routing-modal.test.js new file mode 100644 index 0000000..1516086 --- /dev/null +++ b/tests/routing-modal.test.js @@ -0,0 +1,45 @@ +const test = require('node:test'); +const assert = require('node:assert/strict'); +const { load } = require('./harness'); + +const start = "ACT.start({});if(UI.pendGame)ACT.pitchSkip();S.cash=1e8;S.lvl=4;S.nextFail=1e9;S.nextEvent=1e9;ACT.launchBB({city:'fra'})"; + +test('the backbone, Auto-TE and DDoS settings open from a button at the top of the NOC tab', () => { + const { ev, dom, errors } = load(); + const doc = dom.window.document; + ev(start + ";UI.left='noc';UI.leftOpen=true;UI.sel=null;renderLeft()"); + const left = doc.getElementById('leftBody'); + const b = left.querySelector('[data-act=routingOpen]'); + assert.ok(b, 'the button is there'); + assert.ok(left.querySelector('.btns').contains(b), 'in the first row of buttons, above the notifications'); + assert.doesNotMatch(left.textContent, /Auto-RTBH|Install Auto-TE/, 'the settings no longer sit in the tab'); + b.click(); + assert.equal(ev("$('modal').hidden"), false); + const m = () => doc.getElementById('modalCard').textContent; + assert.match(m(), /Routing & DDoS/); + assert.match(m(), /Backbone/); assert.match(m(), /Auto-TE/); assert.match(m(), /Auto-RTBH: off/); + // An action inside redraws the modal in place. + doc.querySelector('#modalCard [data-act=ddosAuto]').click(); + assert.equal(ev('S.ddosAuto.rtbh'), true); + assert.match(m(), /Auto-RTBH: on/); + doc.querySelector('#modalCard [data-act=coreUp]').click(); + assert.equal(ev('S.core.lv'), 1); + assert.equal(ev("$('modal').hidden"), false, 'still open after buying'); + assert.ok(doc.querySelector('#modalCard [data-act=coreSet]'), 'with the new level to pick'); + // Other modals are left alone. + ev("closeModal();ACT.opsOpen()"); + assert.doesNotMatch(m(), /Auto-RTBH/); + assert.deepEqual(errors, []); +}); + +test('a paused Auto-TE shows on the button, and the modal works on a phone', () => { + const { ev, dom, errors } = load(); + ev("window.innerWidth=360;" + start + ";S.te={on:true,day:S.day};S.core.run=0;UI.left='noc';UI.leftOpen=true;renderLeft()"); + const b = dom.window.document.querySelector('#leftBody [data-act=routingOpen]'); + assert.ok(b.querySelector('.cnt.dot'), 'a red dot when Auto-TE is paused'); + ev('ACT.routingOpen()'); + assert.match(dom.window.document.getElementById('modalCard').textContent, /Auto-TE is paused/); + ev("closeModal();S.core.run=S.core.lv=2;renderLeft()"); + assert.equal(dom.window.document.querySelector('#leftBody [data-act=routingOpen] .cnt'), null); + assert.deepEqual(errors, []); +});