Merge v2 into v2-inbox

This commit is contained in:
Frederic Jung 2026-10-29 21:37:17 +01:00
commit 9ba7f197f1
No known key found for this signature in database
11 changed files with 14 additions and 15 deletions

View file

@ -1998,7 +1998,6 @@
"hud_and_panels.n_incident":{"one":"{n} Störung","other":"{n} Störungen"},
"hud_and_panels.n_more_networks":{"one":"+{n} weiteres Netz","other":"+{n} weitere Netze"},
"hud_and_panels.n_networks_d_days_left":"{n} Netze · noch {d} Tage",
"hud_and_panels.n_new_notification":{"one":"{n} neue Benachrichtigung","other":"{n} neue Benachrichtigungen"},
"hud_and_panels.n_rules_live":"{n} Regeln aktiv",
"hud_and_panels.n_small_networks":"{n} kleine Netze",
"hud_and_panels.n_special_requirement":{"one":"{n} Sonderwunsch","other":"{n} Sonderwünsche"},

View file

@ -1996,7 +1996,6 @@
"hud_and_panels.n_incident":{"one":"{n} incidente","other":"{n} incidentes"},
"hud_and_panels.n_more_networks":{"one":"+{n} red más","other":"+{n} redes más"},
"hud_and_panels.n_networks_d_days_left":"{n} redes · quedan {d} días",
"hud_and_panels.n_new_notification":{"one":"{n} notificación nueva","other":"{n} notificaciones nuevas"},
"hud_and_panels.n_rules_live":"{n} reglas activas",
"hud_and_panels.n_small_networks":"{n} redes pequeñas",
"hud_and_panels.n_special_requirement":{"one":"{n} requisito especial","other":"{n} requisitos especiales"},

View file

@ -1996,7 +1996,6 @@
"hud_and_panels.n_incident":{"one":"{n} incident","other":"{n} incidents"},
"hud_and_panels.n_more_networks":{"one":"+{n} autre réseau","other":"+{n} autres réseaux"},
"hud_and_panels.n_networks_d_days_left":"{n} réseaux · {d} j restants",
"hud_and_panels.n_new_notification":{"one":"{n} nouvelle notification","other":"{n} nouvelles notifications"},
"hud_and_panels.n_rules_live":"{n} règles actives",
"hud_and_panels.n_small_networks":"{n} petits réseaux",
"hud_and_panels.n_special_requirement":{"one":"{n} exigence spéciale","other":"{n} exigences spéciales"},

View file

@ -1996,7 +1996,6 @@
"hud_and_panels.n_incident":{"one":"{n} incidente","other":"{n} incidenti"},
"hud_and_panels.n_more_networks":{"one":"+{n} altra rete","other":"+{n} altre reti"},
"hud_and_panels.n_networks_d_days_left":"{n} reti · {d} giorni rimasti",
"hud_and_panels.n_new_notification":{"one":"{n} nuova notifica","other":"{n} nuove notifiche"},
"hud_and_panels.n_rules_live":"{n} regole attive",
"hud_and_panels.n_small_networks":"{n} piccole reti",
"hud_and_panels.n_special_requirement":{"one":"{n} requisito speciale","other":"{n} requisiti speciali"},

View file

@ -1996,7 +1996,6 @@
"hud_and_panels.n_incident":{"one":"{n} incidente","other":"{n} incidentes"},
"hud_and_panels.n_more_networks":{"one":"+{n} rede a mais","other":"+{n} redes a mais"},
"hud_and_panels.n_networks_d_days_left":"{n} redes · faltam {d} dias",
"hud_and_panels.n_new_notification":{"one":"{n} notificação nova","other":"{n} notificações novas"},
"hud_and_panels.n_rules_live":"{n} regras ativas",
"hud_and_panels.n_small_networks":"{n} redes pequenas",
"hud_and_panels.n_special_requirement":{"one":"{n} requisito especial","other":"{n} requisitos especiais"},

View file

@ -3,10 +3,10 @@ const isPhone=()=>innerWidth<=760||(innerHeight<=500&&matchMedia('(pointer:coars
const SPEEDS=[0.5,1,2,4,8];
function renderTabbar(){const tb=$('tabbar');if(!tb||(pressing&&UI.ticking))return;if(!isPhone()||!S||!UI.started||pzOn()){tb.hidden=true;document.body.classList.toggle('sheet-open',pzOn()&&isPhone()&&!!UI.sel);return;}tb.hidden=false;
const open=UI.leftOpen&&!UI.sel,cur=UI.left||'goals',ndone=GOALS.filter(g=>S.done[g.id]!==undefined).length;
const tab=(k,ic,l,cnt,red)=>`<button class="${open&&cur===k?'on':''}" data-act="phoneTab" data-args='{"t":"${k}"}' aria-label="${esc(l)}"><span class="ic" aria-hidden="true">${ic}</span>${esc(l)}${cnt?`<span class="cnt${red?' red':''}">${cnt}</span>`:''}</button>`;
const tab=(k,ic,l,cnt,red)=>`<button class="${open&&cur===k?'on':''}" data-act="phoneTab" data-args='{"t":"${k}"}' aria-label="${esc(l)}"><span class="ic" aria-hidden="true">${ic}</span>${esc(l)}${cnt?(cnt===' '?`<span class="cnt red dot"></span>`:`<span class="cnt${red?' red':''}">${cnt}</span>`):''}</button>`;
const h=(rule('clock')?`<button class="play${UI.speed?'':' paused'}" data-act="phonePlay" aria-label="${UI.speed?tr('common.pause'):tr('common.play')}"><span class="ic" aria-hidden="true">${UI.speed?'❚❚':'▶'}</span>${UI.speed?tr('common.pause'):tr('common.play')}</button>`+
`<button data-act="phoneSpeed" aria-label="${tr('common.game_speed')}"><span class="ic" aria-hidden="true">${UI.speed===0.5?'½':(UI.lastSpeed||UI.speed||1)}×</span>${tr('common.speed')}</button>`:'')+
(()=>{const P=scnProg();return tab('goals','🎯',tr('common.goals'),P&&!S.scn.done&&!S.scn.failed?`${Math.round(P.f*100)}%`:`${ndone}/${GOALS.length}`);})()+(()=>{const u=custStats().unhappy;return u?tab('deals','💼',tr('common.deals'),u,true):tab('deals','💼',tr('common.deals'),S.offers.length||'');})()+tab('noc','🚨','NOC',S.inc.length||(UI.left==='noc'&&UI.leftOpen?'':logUnread())||'',S.inc.length>0)+tab('nets','🌐',tr('common.networks'),'');
(()=>{const P=scnProg();return tab('goals','🎯',tr('common.goals'),P&&!S.scn.done&&!S.scn.failed?`${Math.round(P.f*100)}%`:`${ndone}/${GOALS.length}`);})()+(()=>{const u=custStats().unhappy;return u?tab('deals','💼',tr('common.deals'),u,true):tab('deals','💼',tr('common.deals'),S.offers.length||'');})()+tab('noc','🚨','NOC',S.inc.length?' ':'',true)+tab('nets','🌐',tr('common.networks'),'');
if(h!==UI._tb){UI._tb=h;tb.innerHTML=h;}
document.body.classList.toggle('sheet-open',!!(UI.sel||UI.leftOpen));}
function haptic(ms){if(UI.muted)return;try{navigator.vibrate&&navigator.vibrate(ms||12);}catch(e){}}

View file

@ -20,7 +20,7 @@ function renderHUD(){
$('hDate').textContent=dateStr(S.day);
{const bo=(S.loanOffers||[]).length,hb=$('hBank');hb.hidden=!bo;hb.textContent=bo;}
{const st=custStats(),hc=$('hCust');hc.hidden=!st.n;if(st.n){$('hCustVal').innerHTML=`${st.avg>=80?'😀':st.avg>=60?'🙂':st.avg>=30?'😟':'😡'} ${Math.round(st.avg)}%${st.unhappy?` <span class="cnt red">${st.unhappy}</span>`:''}`;hc.classList.toggle('hot',st.furious>0);}}
const n=S.inc.length;$('hNoc').classList.toggle('hot',n>0);{const u=UI.left==='noc'&&UI.leftOpen?0:logUnread(),b=$('hNocNew');if(b){b.hidden=!u;b.textContent=u>99?'99+':String(u);b.title=trn('hud_and_panels.n_new_notification',u);}}$('hNocVal').textContent=n?trn('hud_and_panels.n_incident',n):tr('common.all_quiet');
const n=S.inc.length;$('hNoc').classList.toggle('hot',n>0);{const b=$('hNocNew');if(b)b.hidden=true;}$('hNocVal').textContent=n?trn('hud_and_panels.n_incident',n):tr('common.all_quiet');
if(!window.__TUBES_TEST__)fitHud();
renderTabbar();
}
@ -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">${S.inc.length}</span>`:''}`],['nets',tr('common.networks')]];
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')]];
$('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'){

View file

@ -1997,7 +1997,6 @@
"hud_and_panels.n_incident":{"one":"{n} incident","other":"{n} incidents"},
"hud_and_panels.n_more_networks":{"one":"+{n} more network","other":"+{n} more networks"},
"hud_and_panels.n_networks_d_days_left":"{n} networks · {d} days left",
"hud_and_panels.n_new_notification":{"one":"{n} new notification","other":"{n} new notifications"},
"hud_and_panels.n_rules_live":"{n} rules live",
"hud_and_panels.n_small_networks":"{n} small networks",
"hud_and_panels.n_special_requirement":{"one":"{n} special requirement","other":"{n} special requirements"},

View file

@ -83,3 +83,5 @@ section h3{font-size:17px;margin-bottom:6px;display:flex;align-items:center;gap:
.inc .nm{font-weight:900}
.inc .meta{font-size:12px;color:var(--ink2);margin-top:2px;line-height:1.35}
/* The NOC tab only says whether something is broken, never how many notifications wait (2.0). */
.cnt.dot{min-width:0;width:9px;height:9px;padding:0;border-radius:50%;vertical-align:middle}

View file

@ -35,6 +35,7 @@ button,.chip,.b,a{touch-action:manipulation;-webkit-tap-highlight-color:transpar
#tabbar button.play.paused{background:#FFE3F0}
#tabbar .cnt{position:absolute;top:2px;right:calc(50% - 22px);min-width:16px;height:16px;padding:0 4px;border-radius:8px;background:var(--me);color:#fff;font-size:10px;line-height:16px;box-sizing:border-box}
#tabbar .cnt.red{background:var(--bad)}
#tabbar .cnt.dot{min-width:0;width:10px;height:10px;padding:0;top:6px;right:calc(50% - 16px)}
#left,#panel{top:auto !important;left:0 !important;right:0 !important;width:auto !important;bottom:var(--tabbar) !important;max-height:min(62%,calc(100% - var(--tabbar) - 70px)) !important;border-radius:20px 20px 0 0 !important;border-bottom:0 !important;box-shadow:0 -3px 0 var(--ink) !important;transition:max-height .22s ease,transform .22s ease;z-index:7}
#left.full,#panel.full{max-height:calc(100% - var(--tabbar) - 56px - env(safe-area-inset-top,0px)) !important}
#left.closed{display:none}

View file

@ -483,14 +483,13 @@ test('notifications: the NOC keeps the last ten minutes, folds repeats and opens
assert.equal(ev("S.log.length"), 6, 'a minute later it starts a new line');
// the NOC shows them right after the incidents, with Open where there is something to open
assert.equal(ev("logUnread()"), 6);
ev("renderHUD()"); assert.equal(doc.getElementById('hNocNew').hidden, false); assert.equal(doc.getElementById('hNocNew').textContent, '6');
ev("renderHUD()"); assert.equal(doc.getElementById('hNocNew').hidden, true, 'no unread count on the NOC button (2.0)');
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.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(doc.getElementById('hNocNew').hidden, true, 'read once the NOC is open');
assert.equal(ev("logUnread()"), 0);
ev("ACT.logAll()"); assert.equal(doc.querySelectorAll('#leftBody .note').length, 6); assert.equal(doc.querySelectorAll('#leftBody [data-act=logOpen]').length, 3);
// Open goes there
@ -506,12 +505,15 @@ test('notifications: the NOC keeps the last ten minutes, folds repeats and opens
ev("S.log.push({t:'old',k:'weird',o:{a:'city',v:'atlantis'},n:'many'},{t:5},{t:'x',o:{a:'tab',v:'evil'}},{t:'y',o:{a:'link',v:'l1'},at:'soon'});S=sanitize(S)");
const tail = JSON.parse(ev("JSON.stringify(S.log.slice(-3))"));
assert.deepEqual(tail.map(e => [e.t, e.k, e.o, e.n, e.at]), [['old', '', null, 1, 0], ['x', '', null, 1, 0], ['y', '', { a: 'link', v: 'l1' }, 1, 0]]);
// phones: the NOC tab carries the count
// phones: the NOC tab shows no numbers, only a red dot while something is broken
ev("__tick(1000);toast('<b>Router crashed</b><br>Your router in London is rebooting.','bad');UI.left='goals';UI.leftOpen=false");
dom.window.innerWidth = 360; ev("renderAll&&renderAll()");
const nocTab = [...doc.querySelectorAll('#tabbar [data-act=phoneTab]')].find(b => JSON.parse(b.dataset.args).t === 'noc');
assert.equal(nocTab.querySelector('.cnt').textContent, '1', 'one unread notification on the NOC tab');
assert.equal(nocTab.querySelector('.cnt').classList.contains('red'), false, 'not red: red is for incidents');
assert.equal(nocTab.querySelector('.cnt'), null, 'no number for unread notifications on the NOC tab');
ev("S.inc.push({id:'x1',type:'crash',city:'lon',msg:'',until:S.day+3});renderAll()");
const nocTab2 = [...doc.querySelectorAll('#tabbar [data-act=phoneTab]')].find(b => JSON.parse(b.dataset.args).t === 'noc');
assert.ok(nocTab2.querySelector('.cnt.dot.red'), 'a live incident shows a red dot');
assert.equal(nocTab2.querySelector('.cnt').textContent, '', 'and no number');
assert.deepEqual(errors, []);
});