Show a cable's name and a repair button from a save as text
The city panel put the name of your own subsea cable and an incident's repair label into its HTML as they came from the save. Both are escaped now, and sanitize() keeps a cable's name to a string of 60 characters.
This commit is contained in:
parent
7f4fdf6043
commit
aef744af50
4 changed files with 35 additions and 3 deletions
|
|
@ -22,7 +22,7 @@ function cityPanel(c){
|
|||
h+=`<nav class="tabs">${tabs.map(([k,l])=>`<button class="${UI.tab===k?'on':''}" data-act="tab" data-args='{"t":"${k}"}'>${l}</button>`).join('')}</nav><div class="scroll">`;
|
||||
if(C.cn&&UI.tab==='cust')h+=chinaSection(c);
|
||||
const sf=sfOf(R,c),dem=R.cityDem[c]||0;
|
||||
if(down){const i=S.inc.filter(x=>x.ref===c&&POPDOWN.includes(x.type)).sort((a,b)=>b.until-a.until)[0];h+=`<section><h3 style="color:var(--bad)">${tr('city_panel.this_pop_is_down')}</h3><p class="lead">${i?esc(i.msg):''} ${tr('city_panel.customers_here_get_nothing_until_it')}</p>${i&&i.cost?btn(`${i.fix} ${fmt$(i.cost)}`,'fixInc',{id:i.id},'red'):''}</section>`;}
|
||||
if(down){const i=S.inc.filter(x=>x.ref===c&&POPDOWN.includes(x.type)).sort((a,b)=>b.until-a.until)[0];h+=`<section><h3 style="color:var(--bad)">${tr('city_panel.this_pop_is_down')}</h3><p class="lead">${i?esc(i.msg):''} ${tr('city_panel.customers_here_get_nothing_until_it')}</p>${i&&i.cost?btn(`${esc(i.fix||tr('common.rush_repair'))} ${fmt$(i.cost)}`,'fixInc',{id:i.id},'red'):''}</section>`;}
|
||||
if(UI.tab==='cust'){
|
||||
{const nl=R.nodeLoad[c]||0,nc=R.nodeCap[c]||1;if(nl>=nc*0.95)h+=`<section><h3 style="color:var(--bad)">${tr('city_panel.router_maxed_out')}</h3><p class="lead">${tr('city_panel.your_routers_here_are_forwarding',{load:fmtG(nl),cap:fmtG(nc)})}</p>${btn(tr('common.open_infra'),'tab',{t:'links'},'pink sm')}</section>`;}
|
||||
h+=`<section><h3>${tr('common.home_broadband')}</h3>`;
|
||||
|
|
@ -104,7 +104,7 @@ function cityPanel(c){
|
|||
h+=`<section><h3>${tr('city_panel.fiber_from_city',{city:C.name})}</h3><p class="lead">${tr('city_panel.drag_from_this_router_to_any')}</p>`;
|
||||
if(!ls.length)h+=`<p class="empty">${tr('common.no_links_yet')}</p>`;
|
||||
for(const l of ls){const o=l.a===c?l.b:l.a,u=capOf(l)?(R.load[l.id]||0)/capOf(l):0,cut=linkDown(l);
|
||||
h+=`<div class="row"><div class="grow"><div class="nm">→ ${CITY[o].name}${l.mult>1?' · '+tr('common.diverse'):''} ${cut?'<span class="tag restrictive">'+tr('common.cut')+'</span>':''}</div><div class="meta">${capName(l)} · ${l.km.toLocaleString()} km ${l.kind==='vxc'?tr('city_panel.virtual_circuit_via_fab',{fab:esc(FAB[l.prov].name)}):l.kind==='df'?(l.own?(l.sub&&l.cname?tr('city_panel.your_own_subsea_cable_name',{name:l.cname}):tr('common.own_dark_fiber')):tr('city_panel.dark_fiber_iru'))+(l.ready>S.day?` · ${tr('city_panel.ready_in_n_d',{n:l.ready-S.day})}`:''):l.sub?tr('common.subsea'):tr('common.terrestrial')} · ${tr('common.price_mo',{price:fmt$(l.mo)})}</div><div class="bar ${barCls(u)}"><i style="width:${u*100}%"></i></div></div>${btn(tr('common.open'),'selLink',{id:l.id},'ghost sm')}</div>`;}
|
||||
h+=`<div class="row"><div class="grow"><div class="nm">→ ${CITY[o].name}${l.mult>1?' · '+tr('common.diverse'):''} ${cut?'<span class="tag restrictive">'+tr('common.cut')+'</span>':''}</div><div class="meta">${capName(l)} · ${l.km.toLocaleString()} km ${l.kind==='vxc'?tr('city_panel.virtual_circuit_via_fab',{fab:esc(FAB[l.prov].name)}):l.kind==='df'?(l.own?(l.sub&&l.cname?tr('city_panel.your_own_subsea_cable_name',{name:esc(l.cname)}):tr('common.own_dark_fiber')):tr('city_panel.dark_fiber_iru'))+(l.ready>S.day?` · ${tr('city_panel.ready_in_n_d',{n:l.ready-S.day})}`:''):l.sub?tr('common.subsea'):tr('common.terrestrial')} · ${tr('common.price_mo',{price:fmt$(l.mo)})}</div><div class="bar ${barCls(u)}"><i style="width:${u*100}%"></i></div></div>${btn(tr('common.open'),'selLink',{id:l.id},'ghost sm')}</div>`;}
|
||||
h+=`</section>`;
|
||||
if(Object.keys(S.pops).length>1)h+=`<section><h3>${tr('common.decommission')}</h3><p class="lead">${tr('city_panel.shut_this_pop_down_its_links')}</p><div class="btns">${btn(tr('city_panel.decommission_city',{city:C.name}),'decomOpen',{city:c},'ghost sm')}${btn(tr('city_panel.decommission_several_pops'),'decomOpen',{},'ghost sm')}</div></section>`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue